YAFLogo

Soham
  • Soham
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
13 years ago
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.

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

Sponsor
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.1 BETA
Soham
  • Soham
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
13 years ago
Thank you very much. I modified the source code to fix the issue.
Soham
  • Soham
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
13 years ago
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

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

private void DisplayPostFooter_PreRender([NotNull] object sender, [NotNull] EventArgs e)

{

// report posts

if (this.Get().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

bbobb
  • bbobb
  • 100% (Exalted)
  • YAF Developer
13 years ago
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
  • Soham
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
13 years ago
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
  • bbobb
  • 100% (Exalted)
  • YAF Developer
13 years ago
Use YAF Providers. The YAF ProfileProvider as linked to YAF Membership provider.

YAF has sync membership functions. Look in search for details.

SteveGIMP
13 years ago
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
13 years ago

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.

Originally Posted by: SteveGIMP 

.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
13 years ago

.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.

Originally Posted by: squirrel 

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

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
  • logan
  • 100% (Exalted)
  • YAF Leader
13 years ago
I think your profileprovider needs to inherit the YAF provider



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

test