Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies

前端 未结 18 1734
夕颜
夕颜 2021-01-31 07:02

I have an MVC4 Web API project. While running the service project I am getting an error

Could not load file or assembly \'WebGrease, Version=1.5.1.25624,

18条回答
  •  伪装坚强ぢ
    2021-01-31 07:47

    The issue I observed matched closely what Jidheesh Rajan mentioned. However, updating the package from Nuget package manager (without specifying version) did not fix the issue. Here is what I had to do to fix the issue. (Essentially, I explicity updated WebGrease to version 1.6)

    From within the package manager console in Visual Studio, explicitly update WebGrease to version 1.6 . here is the command.

    Install-Package WebGrease -Version 1.6
    

    Output should be

    Removing 'WebGrease 1.5.2' from {project name}
    

    Adding 'WebGrease 1.6.0' to {project name} Successfully added 'WebGrease 1.6.0' to {project name} Uninstalling 'WebGrease 1.5.2'. Successfully uninstalled 'WebGrease 1.5.2'.

    This ended up updating web.config with

        assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /
        bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" 
    

    This also resulted in the removal of a line from the csproj file.

    ..\packages\WebGrease.1.5.2\lib
    

    and an update in this node in the csproj file

    
      ..\packages\WebGrease.1.5.2\lib\WebGrease.dll
      False
      True
    
    

    to this

    
      ..\packages\WebGrease.1.6.0\lib\WebGrease.dll
      False
      True
    
    

    Keep in mind that I didnt have an issue on my local machine, just on a stage web server. I wanted to try my best to resolve the issue without updating the package, but this was the only fix I had.

提交回复
热议问题