Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingMethodException - ASP.NET Core 2.1 Application Running Under .NET Full Framework #585

Closed
bt-Knodel opened this issue Jan 5, 2023 · 13 comments

Comments

@bt-Knodel
Copy link

bt-Knodel commented Jan 5, 2023

Company uses an ASP.NET Core 2.1 application running under .NET Full Framework. Unfortunately, it seems that LightInject after 6.6.x is no longer compatible with this API. The exception is:

Exception Info: System.MissingMethodException at LightInject.Microsoft.DependencyInjection.PerRootScopeLifetime.RegisterForDisposal(System.Object) at LightInject.Microsoft.DependencyInjection.PerRootScopeLifetime.GetInstance(LightInject.GetInstanceDelegate, LightInject.Scope, System.Object[]) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(System.IServiceProvider, System.Type) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.IServiceProvider) at Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__4.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(Microsoft.AspNetCore.Hosting.IWebHost) at Clients.Api.Program.Main(System.String[])

Tracking this down, it appears LightInject's package "LightInject.Microsoft.AspNetCore.Hosting". This package appears to look for an overload requiring the parameter to be IDisposable, but it's now an "object" since IAsyncDisposable support...

@bt-Knodel bt-Knodel changed the title MissingMethodException - ASP.NET Core 2.2 Application Running Under .NET Full Framework MissingMethodException - ASP.NET Core 2.1 Application Running Under .NET Full Framework Jan 5, 2023
@seesharper
Copy link
Owner

The first thing to try is to try a clean build. Secondly ensure that all LightInject dependencies are up to date.

@seesharper
Copy link
Owner

ASP.NET Core 2.1 went out of support August 21, 2021 so I would recommend to upgrade to a supported version 👍

@bt-Knodel
Copy link
Author

bt-Knodel commented Jan 5, 2023

@seesharper ASP.NET Core on the full framework is still actively supported by microsoft.

See section "ASP.NET Core 2.1 on .NET Framework" here: https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core

To help facilitate migrating applications to ASP.NET Core on .NET Core, the following ASP.NET Core 2.1 (latest patched version only) packages will be supported on the .NET Framework and follow the support cycle for those .NET Framework versions. ASP.NET Core 2.1 is defined as "Tools" in the Microsoft Support Lifecycle Policy. A "Tool" requires a minimum of 12 months notification prior to the end of support. For more information, please see this KB Article.

@bt-Knodel
Copy link
Author

This was due to an upgrade to LightInject. I attempted to upgrade LightInject to version 6.6.x (all 6.6.x releases cause this issue) but it fails with ASP.NET Core 2.1 on full framework.

LightInject.Microsoft.AspNetCore.Hosting is running version 2.3.5, which is the latest version as well.

@seesharper
Copy link
Owner

"ASP.NET Core on the full framework is still actively supported by microsoft."

Actually I did not know it was still possible ?

aspnet/Announcements#324

@seesharper
Copy link
Owner

When you say .Net Full framework. What version are you using?

@bt-Knodel
Copy link
Author

.NET Framework 4.7.2

@seesharper
Copy link
Owner

Anyhows. There must be a binary mismatch somewhere in your dependencies. It is correct that the RegisterForDisposal has changed from IDisposable to object, but that should be okay if all LightInject related dependencies are up to date

@bt-Knodel
Copy link
Author

I cleaned, rebuilt, and even sent this on to a completely rebuilt from scratch environment. All of those situations resulted in this same error.

@seesharper
Copy link
Owner

Okay, I would need a repro project to debug this. I don't see where it could fail if all deps are up to date

@bt-Knodel
Copy link
Author

Alright, I stood up a demo project, and it turns out it has to do with the version of LightInject.Microsoft.DependencyInjection... The solution uses 3.3.6 of that package, with the latest being 3.6.3.

Apologies, it was an indirect reference (not referenced by the API project directly), so you were definitely correct that the latest version of all LightInject packages solves this issue.

@seesharper
Copy link
Owner

No problem. Glad you figured it out 👍😀

@bt-Knodel
Copy link
Author

Core2.1FullFramework.zip

Reproduction repo for future reference... Upgrading LightInject.Microsoft.DependencyInjection to 3.6.3 solves the issue. Thanks for helping narrow down the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants