Skip to content

Exception thrown: 'System.InvalidOperationException' in AspNetDependencyInjection.dll #28

Open
@HashTagDotNet

Description

@HashTagDotNet

I am running .Net 4.8 Web Forms application and getting InvalidOperationException. Any help would be appreciated.

 internal static void PreStart()
        {
            System.Diagnostics.Debug.WriteLine(nameof(RegisterServices) + "." + nameof(PreStart) + "() called.");

            // If you are using ASP.NET Web Forms without any ASP.NET MVC functionality, remove the call to `.AddMvcDependencyResolver()`.
            // If you are using ASP.NET MVC, regardless of whether you're using ASP.NET Web Forms, use `.AddMvcDependencyResolver()`:

            _di = new ApplicationDependencyInjectionBuilder()
                .ConfigureServices(ConfigureServices)
                //.AddMvcDependencyResolver() // Uncomment this out if you're using ASP.NET MVC.
                //.AddWebApiDependencyResolver() // Uncomment this out if you're using ASP.NET Web API.
                //.AddScopedSignalRDependencyResolver() // Uncomment this out if you're using ASP.NET SignalR (and want to use services scoped to request or operation lifetime). NOTE: You cannot have both `AddScopedSignalRDependencyResolver` and `AddUnscopedSignalRDependencyResolver` at the same time. You must also configure SignalR below.
                //.AddUnscopedSignalRDependencyResolver() // Uncomment this out if you're using ASP.NET SignalR (and only need Singleton or Transient lifetime services).
                .Build();
        }
        private static void ConfigureServices(IServiceCollection services)
        {
            // TODO: Add any dependencies needed here
            //services
            //    // Useful services built-in to AspNetDependencyInjection:
            //    .AddDefaultHttpContextAccessor() // Adds `IHttpContextAccessor`
            //    .AddWebConfiguration(); // Adds `IWebConfiguration`

            // Example services:
            //.AddScoped<Service1>()
            //.AddTransient<Service2>()
            //.AddScoped<IExampleRequestLifelongService, ExampleRequestLifelongService>()
            //.AddScoped<Service4>()
            //.AddSingleton<SingletonService>();
        }
        /// <summary>Invoked at the end of ASP.NET application start-up, after Global's Application_Start method runs. Dependency-injection re-configuration may be called here if you have services that depend on Global being initialized.</summary>
        internal static void PostStart()
        {
            System.Diagnostics.Debug.WriteLine(nameof(RegisterServices) + "." + nameof(PostStart) + "() called.");
        }

This error is happening during program startup and prevent the application from starting.
image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions