1

At random times, twice in the past two weeks, the we application will start to error and not work until I recycle the app pool in IIS.

The specific error and stacktrace are:

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidCastException: Unable to cast object of type 'System.Guid' to type 'System.String'.
   at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
   at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
   at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
   at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
   at DigitalScout.WEDS.Business.Slug.GetTeamPath(String teamID)
   at DigitalScout.WEDS.WebApp.Code.Navigator.TeamNavigator.Home(String teamID)
   at ASP.management_default_aspx.__DataBind__control7(Object sender, EventArgs e)
   at System.Web.UI.Control.OnDataBinding(EventArgs e)
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at System.Web.UI.Control.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource)
   at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e)
   at System.Web.UI.Control.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource)
   at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e)
   at DigitalScout.WEDS.WebApp.Management._default.Page_Load(Object sender, EventArgs e)
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at DigitalScout.WEDS.WebApp.Code.BaseClass.Pages.ManagementPage.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   --- End of inner exception stack trace ---
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.management_default_aspx.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

This error happens for every user of the system until the app pool is recycled. Any help on this would be helpful as we are not able to reproduce the error.

skaffman
  • 398,947
  • 96
  • 818
  • 769
John Boker
  • 82,559
  • 17
  • 97
  • 130
  • @Mitch Wheat, yes, that's the actual Error being thrown, but it's being thrown from inside the SqlClient code that Linq2Sql uses, not the code we've written. Also, this code works most of the time - until this error crops up every so often making it necessary to recycle the app pool. – John Boker Mar 17 '10 at 15:59
  • sorry I should have realised that. – Mitch Wheat Mar 17 '10 at 16:00
  • @Mitch Wheat, I'm going to look into your answer, thank you for your help on this :) – John Boker Mar 17 '10 at 16:02

1 Answers1

1

Apparently, the problem goes away if you Dispose your DataContexts:

Community
  • 1
  • 1
Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541