Server Error in '/' Application.

Sequence contains no matching element

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 matching element

Source Error:


Line 339:        //int lineNumber=oEx.StackTrace.Substring()
Line 340:        var LineNumber = new StackTrace(oEx, true).GetFrame(0).GetFileLineNumber();
Line 341:        var methodname = new StackTrace(oEx, true).GetFrames().Select(f => f.GetMethod()).First(m => m.Module.Assembly == Assembly.GetExecutingAssembly()).Name;
Line 342:        string methodName = site == null ? null : site.Name;
Line 343:        ErrorHandler.LogErrorInXML(oEx.Message + " line No:" + LineNumber + ", Method Name:" + methodname, Request.Url.ToString(), methodName);

Source File: c:\Sites\live\EcommerceBlog.aspx.cs    Line: 341

Stack Trace:


[InvalidOperationException: Sequence contains no matching element]
   System.Linq.Enumerable.First(IEnumerable`1 source, Func`2 predicate) +281
   EcommerceBlog.Page_Error(Object sender, EventArgs e) in c:\Sites\live\EcommerceBlog.aspx.cs:341
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
   System.Web.UI.TemplateControl.OnError(EventArgs e) +121
   System.Web.UI.Page.HandleError(Exception e) +86
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6787
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +250
   System.Web.UI.Page.ProcessRequest() +76
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +24
   System.Web.UI.Page.ProcessRequest(HttpContext context) +62
   ASP.ecommerceblog_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\374608f3\28e99558\App_Web_cokpl2mm.10.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +195
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +50
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +73


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4676.0