-
Notifications
You must be signed in to change notification settings - Fork 207
MissingMethodException on .NET Core 3 #158
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
Comments
Hi, @bigdnf . The latest major version of the package (3.x) targets |
I'm not sure I'm understand right so I will clarify. I'm using 3.2 version of serilog-aspnetcore which is .net standard 2.0 that is referencing Microsoft.AspNetCore.Hosting.Abstractions 2.0. Those abstractions nuget is obsolete in .NET Core 3.0 (dotnet/core#2194) and because of this when used in new core release WebHostBuilderContext have different content in property HostingEnvironment – it used to be IHostingEnvironment and now it is IWebHostEnvironment (https://andrewlock.net/ihostingenvironment-vs-ihost-environment-obsolete-types-in-net-core-3/). So in summary everything is compiling but is failing in runtime. For me library should multi target .net core 3.0 and net standard. |
@bigdnf thanks for the note! If a project builds, there should never be runtime If you're keen to submit a PR, the likely target is https://github.com/serilog/serilog-extensions-hosting - an explanatory code/CSPROJ sample would be needed, though. Also, if you're on 3.0, it's likely that you should be calling Hope this all helps! |
@bigdnf you are right, thanks for pointing to the article, makes sense 👍 PR probably will solve this. As workaround you can multitarget your shared configuration class library like article suggests: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="$(TargetFramework) == 'netcoreapp3.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup> So that for netcorapp3.0 runtime it will bind to a new type. But better is to move the configuration out of the |
I'm using UseSerilog overload that is using WebHostBuilderContext as action parameter. MS has changed WebHostBuilderContext implementation in 3.0 so HostingEnvironment is no longer of type IHostingEnvironment - now it is IWebHostEnvironment. Are there any plans to properly target .NET Core 3.0?
The text was updated successfully, but these errors were encountered: