简体   繁体   中英

ASP.NET core generated app.config invalid

I'm trying to port an old project to the net ASP.NET core platform. Running my web project gives the old incorrect DLL reference "Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0,". I'm not using any project or package that references 9.0.0, and all of the net aspnetcore components reference 9.0.1.

What I did find is that the compiler generates an *.exe.config file which has the following redirects for some referenced net45 projects:

  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="6.0.0.0" newVersion="9.0.0.0" />
    <bindingRedirect oldVersion="4.5.0.0" newVersion="9.0.0.0" />
    <bindingRedirect oldVersion="8.0.0.0" newVersion="9.0.0.0" />
  </dependentAssembly>

I assume this issue is that the newVersion is not matching the version resolved in the rest of the project. Is there a way to fix this? Is it a bug?

It's possible that updating your package to a minor version didn't modify the config completely. In your config file, change newVersion="9.0.0.0" to newVersion="9.0.1.0" to match the reference version.

You should also be able to combine the redirects to <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.1.0" />

I had the same problem after upgrading from RC2 to RTM. It turned out that old config file was never updated with the correct redirects. After deleting the file and rebuilding everything worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM