I integrated the yaf forum into our website and I'm facing an issue.
After going though a lot of steps (including changing the Yaf.Root in the app.config); I've managed to have it running until past the install. The BD has been created properly, the admin user too etc... (and I'm using my own provider).

Now I'm facing this issue: When I start to load the forum after the setup, at some point the Forum.GetPageSource() is called and I have a NullReferenceException in it.

After debugging I found out that the "_page" member is never assigned.
And if I look at the "pages" collection, there is only 3 ILocatablePage in it : "ModerateForumPage", "ForumPageRegistered" and "AdminPage".

There is no "forum" page, so the "_page" member is still at null while calling the next 2 lines.

f (this._page == null)
this._page = pages.GetPage("forum");

string[] src = { "{0}pages/{1}.ascx".FormatWith(YafForumInfo.ForumServerFileRoot, this._page.PageName) };
string controlOverride = this.Get<ITheme>().GetItem("PAGE_OVERRIDE", this._page.PageName.ToLower(), null);

Any idea of the root cause of this issue?

Thank you

I've faced with the same issue and it stopped us and our deployment plans(
So could you please suggest any workarounds ASAP...

I've found that the reason could be in incorrect calling of CreateContainer() method within
GlobalContainer, where all modules(pages as well) are registered during startup.
It sounds like CreateContainer() never fired in this case??
As soon as I understood the first calling of CreateContainer method should be made by
YafTaskModule->Init(all happen this way in the case of forum didnt reside inside website)
But in case forum is installed as webapplication within existing website the calling of this method is performed before
YafTaskModule->Init with unpredictable results(multithreading issue ???), f.e if registered user requests Forum/default.aspx page from website.

I included all sources of yafnet(YAF-v1.9.6.1-RTW-SRC ) to our site to debug it and in total Forum.GetPageSource() contains only 3 ILocatablePage in it : "ModerateForumPage", "ForumPageRegistered" and "AdminPage", so any other requested page could not be found(((

in our case yafnet forum recides in subdirectory within web site
so it can be reached like this: 

P.S. These are only my assumptions and findings and the reason might be another one...
please suggest any workarounds

Thanks in advance, Alex Borodkin.

I found a quick workaround:
I replaced the logic for fetching pages from container to simple setting their page names like this:
private string GetPageSource()
var pages = this.Get<IEnumerable<ILocatablePage>>();
var pageQuery = "forum";
if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("g") != null)
pageQuery = this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("g");

this._page = pages.GetPage(pageQuery);

if (this._page == null)
this._page = pages.GetPage("forum");

/*if (!this.IsValidForLockedForum(this._page))
/ YafBuildLink.Redirect(ForumPages.topics, "f={0}", this.LockedForum);

string[] src = { "{0}pages/{1}.ascx".FormatWith(YafForumInfo.ForumServerFileRoot, this._page == null ? pageQuery : this._page.PageName) };

string controlOverride = this.Get<ITheme>().GetItem("PAGE_OVERRIDE", this._page == null ? pageQuery : this._page.PageName.ToLower(), null);

if (controlOverride.IsSet())
src[0] = controlOverride;

var replacementPaths = new List<string> { "moderate", "admin", "help" };

foreach (var path in replacementPaths.Where(path => src[0].IndexOf("/{0}_".FormatWith(path)) >= 0))
src[0] = src[0].Replace("/{0}_".FormatWith(path), "/{0}/".FormatWith(path));

return src[0];

From now it's possible to get correct src source but I am afraid this can cause extra issues.
Could someone from support/dev teams review this solutions?

Thanks in advance, Alex Borodkin.
Hi guys,

I have had the same issue, and have been working on it for the past few days, it's really frustrating.
Now I've finally been able to "solve" it. It's not really a solution, but it makes it work, and as I think better than the workaround posted above.

What you have to do is set the "Assembly Name" attribute in the AssemblyInfo.cs (or in the project settings, if you like) to anything that BEGINS with "YAF", e.g "YAF_MyForum". You have to do this ONLY in the web application that contains the YAF forum. (Don't forget to update your web.config and your .aspx files to match the new name!)

This works for me, hope it also works for anyone with the same problem.


  •  bbobb
  • 100% (Exalted)
  • YAF Developer
YAF automatically registers every assembly with name that begins with YAF like YAF.MyAssembly.
Well, that's good to know. Would've saved quite a few hours of work.
So I'm guessing there is a way to change that behaviour?

Anyways, thanks for clearing things up.
This issue has also become a problem for me since I integrate within my application and do not have my UI project compile to a YAF*.dll.

Any help with a workaround for this one would be great as I'd rather not change my core application compile names.
Originally Posted by: bbobb 

YAF automatically registers every assembly with name that begins with YAF like YAF.MyAssembly.

Can you tell me where in the source code it is looking for all assemblies that start with YAF so I can adjust so it looks for additional assemblies, my web project is already named MAEU.Web and I don't want to have to preface it with YAF.


You can find them in the YAF.Core, under Modules. The file to edit is BaseModule.cs.

I added my DLL separately to keep it documented that way, although you could add probably just add it directly to the method. Look for my comments on adding the COMWebUI.dll.

        /// <summary>
        /// Initializes the <see cref="BaseModule"/> class.
        /// </summary>
        static BaseModule()
            // COMWeb added 2/15/2014 to include the COMWebUI.dll for the YAF additions.
            var COMWebUIDll = new YafModuleScanner()

            ExtensionAssemblies =
                new YafModuleScanner().GetModules("YAF*.dll")
                                a =>
								&& a.FullName.StartsWith("CookComputing.XmlRpcV2")
                                && a.FullName.StartsWith("FarsiLibrary")
                                && a.FullName.StartsWith("Intelligencia.UrlRewriter")
                                && a.FullName.StartsWith("nStuff.UpdateControls")
                                && a.FullName.StartsWith("Omu.ValueInjecter") 
								&& a.FullName.StartsWith("ServiceStack.")))
                    .Concat(COMWebUIDll) // COMWeb added 2/15/2014 to include the COMWebUI.dll for the YAF additions.
                    .Except(new[] { Assembly.GetExecutingAssembly() })
                    .Where(a => !a.IsDynamic)
                    .OrderByDescending(x => x.GetAssemblySortOrder())
            foreach (var s in ExtensionAssemblies)
                Debug.WriteLine("Extension Assembly: {0}", s);

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved