Skip to content

One-off "Cannot access a disposed object." during application startup #9

Description

@daiplusplus

In my current project, when I press the Start Debugging button in VS2017 I sometimes get this exception. Reloading the page while the application is running or simply loading another URI in the application resolves the issue - so it isn't a showstopper or even an annoyance (as I rarely want to use the startup webpage anyway).

Type: System.Web.HttpUnhandledException
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
TargetSite: Boolean HandleError(System.Exception)
HResult: -2147467259
Source: System.Web.
WebEventCode: 0
StackTrace:
   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.default_aspx.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0()
   at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

InnerException:

Type: System.ObjectDisposedException
Message: Cannot access a disposed object. Object name: 'IServiceProvider'.
Source: Microsoft.Extensions.DependencyInjection
StackTrace:
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
   at lambda_method(Closure , IServiceProvider , Object[] )
   at AspNetDependencyInjection.ObjectFactoryCache.GetRequiredService(IServiceProvider serviceProvider, Type serviceType) in C:\git\me\Unity.WebForms\Unity.WebForms\AspNetDependencyInjection\AspNetDependencyInjection\ObjectFactoryCache.cs:line 87
   at AspNetDependencyInjection.ObjectFactoryCache.GetRequiredService(Func`1 getServiceProvider, Type serviceType, Boolean useOverrides) in C:\git\me\Unity.WebForms\Unity.WebForms\AspNetDependencyInjection\AspNetDependencyInjection\ObjectFactoryCache.cs:line 55
   at __ASP.FastObjectFactory_myproject_merged.Create_ASP_page_master()
   at System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection)
   at System.Web.UI.Page.get_Master()
   at System.Web.UI.Page.ApplyMasterPage()
   at System.Web.UI.Page.PerformPreInit()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions