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

2019-03-31 00:21发布

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.

4条回答
贪生不怕死
2楼-- · 2019-03-31 01:08

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" />
查看更多
孤傲高冷的网名
3楼-- · 2019-03-31 01:09

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.

查看更多
Explosion°爆炸
4楼-- · 2019-03-31 01:15

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>
查看更多
Deceive 欺骗
5楼-- · 2019-03-31 01:17

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.

查看更多
登录 后发表回答