-->

Could not load file or assembly 'System.Web.Op

2019-03-31 00:22发布

问题:

I keep getting this error although I already installed the nuget packet for Microsoft.AspNet.Web.Optimization...

Could not load file or assembly 'System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

Apparently, the one in the Nuget is a v.1.13 while the one referenced in my solution somewhere is v.1.0.0 ...Problem is, I can't find the way to match these two. I can't find the install for v.1.0.0 or the way to delete or override the 1.0.0 for the 1.1.3.

Any help on this?

Any code you need to see, let me know and I'll update the question.

回答1:

I was able to fix this issue by adding the following to my web.config:

<configuration>
    <runtime>
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.1.3.0" />
        </dependentAssembly>
    </runtime>
</configuration>


回答2:

I think you have to change your "Target Framework", from your project properties. ".Net Framework 3.5" should be fine.

Another thing you must be sure that your "Platform target" is set right. You can change it from your project properties under the "Build" tab. If your running application is 64 bit, change it to x64 otherwise (32 bit) keep it x86. Be careful not to select "Any CPU".

Hope these will help you.

Arif.



回答3:

I ran into the same problem today by switching between branches in GIT.

If you want to use nuget to access a specific version of a package, there is a -version <value> option to very package, that have been installed.

Hence you could writeup an nuge uninstaller, then a nuget installer of the specific package with the additional version information.



回答4:

Here's how I fixed it. Re-installing the package using the command:

Install-Package Microsoft.AspNet.Web.Optimization

If you've already got it installed, you'll have to remove this line from packages.config:

<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />