Soham
  • Posts: 4
  • Joined: 04/01/2012
I am working on version 1.9.5.5. I have a SQL Server 2008 R2 database and I am running the forum in the debug mode off VS 2008.

When I attempt to create a fresh topic by clicking on the 'post' button in the 'post new topic' page I see the exception given below. Note that when I return to the forum I am able to see the new topic and post a reply to the topic.

I would be most appreciative of any help ou can give me. Thank you.

Quote:



Sequence contains no elements
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Sequence contains no elements

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: Sequence contains no elements]
System.Linq.Enumerable.First(IEnumerable`1 source) +732012
YAF.Pages.posts.BindData() +3086
YAF.Pages.posts.Page_Load(Object sender, EventArgs e) +6539
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627




tha_watcha
  • Posts: 4036
  • Joined: 06/03/2010
Its a known Bug, a solution to fix this can be found here

http://forum.yetanotherf...IS-server.aspx#post49762 

Or you upgrade to YAF 1.96 beta
UserPostedImage
Soham
  • Posts: 4
  • Joined: 04/01/2012
Thank you very much. I modified the source code to fix the issue.
Soham
  • Posts: 4
  • Joined: 04/01/2012
I am getting a new runtime exception because "this.PostData.UserProfile" (ln 284) is null in the DisplayPostFooter_PreRender event in DisplayPostFooter.ascx.cs. Given below is the detailed exception. I have also included the portion of the code that is causing the error and my profile provider setting in web.config. As always your help is greatly appreciated. I am running the project in the debug mode off VS 2010.

Detailed Exception

Quote:


Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 282:
Line 283: // home page
Line 284: this.Home.Visible = !this.PostData.PostDeleted && this.PostData.UserProfile.Homepage.IsSet();
Line 285: this.SetupThemeButtonWithLink(this.Home, this.PostData.UserProfile.Homepage);
Line 286:


Source File: C:\Users\schak3\Documents\Visual Studio 2010\Projects\YAF-v1.9.5.5-RTW-SRC\YetAnotherForum.NET\controls\DisplayPostFooter.ascx.cs Line: 284

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
YAF.Controls.DisplayPostFooter.DisplayPostFooter_PreRender(Object sender, EventArgs e) in C:\Users\schak3\Documents\Visual Studio 2010\Projects\YAF-v1.9.5.5-RTW-SRC\YetAnotherForum.NET\controls\DisplayPostFooter.ascx.cs:284
System.Web.UI.Control.OnPreRender(EventArgs e) +8695510
System.Web.UI.Control.PreRenderRecursiveInternal() +80
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842





Portion of the code that is failing in DisplayPostFooter.ascx.cs

Quote:


private void DisplayPostFooter_PreRender([NotNull] object sender, [NotNull] EventArgs e)
{
// report posts
if (this.Get<IPermissions>().Check(this.PageContext.BoardSettings.ReportPostPermissions) &&
!this.PostData.PostDeleted)
{
if (this.PageContext.IsGuest || (!this.PageContext.IsGuest && this.PageContext.User != null))
{
this.reportPostLink.Visible = true;

// vzrus Addition
this.reportPostLink.InnerText =
this.reportPostLink.Title = this.GetText("REPORTPOST" ) ;

this.reportPostLink.HRef = YafBuildLink.GetLink(ForumPages.reportpost, "m={0}", this.PostData.MessageId);
}
}

// private messages
this.Pm.Visible = this.PostData.UserId != this.PageContext.PageUserID && !this.IsGuest &&
!this.PostData.PostDeleted && this.PageContext.User != null &&
this.PageContext.BoardSettings.AllowPrivateMessages && !this.PostData.IsSponserMessage;
this.Pm.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.pmessage, "u={0}", this.PostData.UserId);

// emailing
this.Email.Visible = this.PostData.UserId != this.PageContext.PageUserID && !this.IsGuest &&
!this.PostData.PostDeleted && this.PageContext.User != null &&
this.PageContext.BoardSettings.AllowEmailSending && !this.PostData.IsSponserMessage;
this.Email.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_email, "u={0}", this.PostData.UserId);

// home page
this.Home.Visible = !this.PostData.PostDeleted && this.PostData.UserProfile.Homepage.IsSet();
this.SetupThemeButtonWithLink(this.Home, this.PostData.UserProfile.Homepage);
......................



Provider setup in web.config

Quote:


<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile defaultProvider="AspNetSqlProfileProvider">
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add connectionStringName="ApplicationServices" applicationName="/" name="YafProfileProvider" type="YAF.Providers.Profile.YafProfileProvider"/>
</providers>
</profile>
<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>

bbobb
  • Posts: 1558
  • Joined: 21/10/2008
Replace it with.
this.Home.Visible = !this.PostData.PostDeleted && this.PostData.UserProfile !=null && this.PostData.UserProfile.Homepage.IsSet();
Very strange. The profile should be initialized at the point. Did you any modifications which could cause it? Like a custom Membership? It was the first report about the problem as far as remember.
Soham
  • Posts: 4
  • Joined: 04/01/2012
Thank you bbobb. I have used the standard SqlProfileProvider, SqlMembershipProvider and SqlRoleProvider.

One further question. The following line also uses this.PostData.UserProfile.

this.SetupThemeButtonWithLink(this.Home, this.PostData.UserProfile.Homepage);

Should I put a check to not enter this statement if this.PostData.UserProfile is null?
bbobb
  • Posts: 1558
  • Joined: 21/10/2008
Use YAF Providers. The YAF ProfileProvider as linked to YAF Membership provider.
YAF has sync membership functions. Look in search for details.
SteveGIMP
  • Posts: 12
  • Joined: 12/01/2012
I'm getting the same error. I've looked at the link provided above but I'm confused about the suggested solution. It says to edit postmessage.ascx.cs but I don't have that file anywhere in my installation.

I'm a newbie so I'm probably looking stupid, but I'm stumped.

I'm working with version 1.9.5.5 in a hosted environment.
squirrel
  • Posts: 925
  • Joined: 14/01/2010
Originally Posted by: SteveGIMP

I'm getting the same error. I've looked at the link provided above but I'm confused about the suggested solution. It says to edit postmessage.ascx.cs but I don't have that file anywhere in my installation.

I'm a newbie so I'm probably looking stupid, but I'm stumped.

I'm working with version 1.9.5.5 in a hosted environment.



.CS files are part of the source-code version of YAF. You would need Visual Studio Express and to download the SOURCE version of YAF for the version you are running. Then you can edit the file and recompile (PUBLISH) the YAF part of the solution. The resulting files and DLLs would need to be uploaded to the server.
If you can't find it using the forum search, try my signature link -- searches this site using Google: Google is my Friend 
SteveGIMP
  • Posts: 12
  • Joined: 12/01/2012
Originally Posted by: squirrel



.CS files are part of the source-code version of YAF. You would need Visual Studio Express and to download the SOURCE version of YAF for the version you are running.


Thanks for your reply. I figured out this first part.

Quote:

Then you can edit the file and recompile (PUBLISH) the YAF part of the solution. The resulting files and DLLs would need to be uploaded to the server.


Unfortunately, this part I haven't a clue how to do.
logan
  • Posts: 309
  • Joined: 15/03/2008
I think your profileprovider needs to inherit the YAF provider



  <profile defaultProvider="AspNetSqlProfileProvider" inherits="YAF.Utils.YafUserProfile">

test
Forum Jump  
  • You cannot post new topics in this forum.
  • You cannot reply to topics in this forum.
  • You cannot delete your posts in this forum.
  • You cannot edit your posts in this forum.
  • You cannot create polls in this forum.
  • You cannot vote in polls in this forum.

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