Tags: asp.net
In Visual Studio, change project target framework to 4.8
Rebuild the project - if you get a warning about a package that needs to be reinstalled, you can reinstall it.
I also went to packages.config and renamed the targetFramework from net461 to net48 - not sure if that is needed If this project is being referenced by other projects
Remove the reference and add it again if you get a “Could not load file or assembly error”
Add binding redirect, to do this add these to the project’s .csproj file
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
Then reload the project, and rebuild it - in its bin folder, there should be a (project-name).dll.config file. look for the <runtime>
node inside that file and copy all the <assemblyBinding>
into the project’s Web.config <runtime>
node (btw, the runtime node should usually just be a direct child of the <configuration>
node). You can now delete the <PropertyGroup>
node you just added earlier
If you get errors in your razor .cshtml that it can’t recognize types from your .netstandard project In the project’s Web.config, go in
<system.web>
and add
<compilation debug="true" targetFramework="4.8">
<assemblies>
<add assembly="netstandard, Version=<your-version>, Culture=neutral, PublicKeyToken=<its-keyToken>" />
</assemblies>
</compilation>
Hopefully that would settle those errors. This is what worked for me, after hours of Googling and reading comments in Github and Stackoverflow posts. I also thought about the AutoGenerateBinding, and GenerateBindingRedirectsOutputType - since it generates a .config file in the bin folder, perhaps we don’t need to delete the lines below from the .csproj file - so we won’t need to copy the <assemblyBinding>
into Web.config (I didn’t test this though)
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>