Programing

파일 또는 어셈블리 'WebGrease, Version = 1.5.1.25624, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'또는 해당 종속성 중 하나를로드 할 수 없습니다.

lottogame 2020. 11. 3. 07:33
반응형

파일 또는 어셈블리 'WebGrease, Version = 1.5.1.25624, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'또는 해당 종속성 중 하나를로드 할 수 없습니다.


MVC4 웹 API 프로젝트가 있습니다. 서비스 프로젝트를 실행하는 동안 오류가 발생합니다.

파일 또는 어셈블리 'WebGrease, Version = 1.5.1.25624, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'또는 해당 종속성 중 하나를로드 할 수 없습니다. 시스템이 지정된 파일을 찾을 수 없습니다.

WebGrease.dll 파일을 추가했지만 여전히 오류가 발생합니다.

web.config 변경 시도

<bindingRedirect oldVersion="0.0.0.0-1.3.0.0"/>"

<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />

내가 놓친 것을 조언하십시오.


NuGet을 사용해 보셨습니까?

Install-Package WebGrease -Version 1.5.1

또는

Install-Package WebGrease -Version 1.5.2

나는 그것이 OP에 늦었다는 것을 알고 있지만 MVC 4 NuGet 패키지 용 Bootstrap 3을 시도하는 동안 동일한 문제가 발생 했습니다. 제 경우에는 Microsoft.AspNet.Web.Optimization 패키지와 관련이 있었고 간단한 해결책을 찾으십시오.

패키지 관리자 콘솔에서 다음 명령을 실행 해보십시오.

Install-Package Microsoft.AspNet.Web.Optimization
Update-Package WebGrease
Uninstall-Package Microsoft.AspNet.Web.Optimization
Uninstall-Package WebGrease
Install-Package Microsoft.AspNet.Web.Optimization
Update-Package WebGrease

처음 두 줄은 MVC 4 용 Bootstrap 3 패키지에 의해 이미 설치 및 업데이트 되었기 때문에 나에게 아무런 영향을 미치지 않았지만 어쨌든 실행 한 다음 모두 잘 컴파일되고 실행되었습니다.


이 오류는 Microsoft.AspNet.Web.Optimization 1.1.3내부적으로 참조 WebGrease 1.5.1.25624Nuget 패키지 자체가에 대한 종속성이있는 경우에도 WebGrease 1.5.2.14234. Nuget 패키지를 만드는 동안 누군가가 분명히 엉망으로 만들었습니다.

이 문제를 해결하려면이 어셈블리 바인딩을 Web.Config.

  <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.5.1.25624" newVersion="1.5.2.14234" />
  </dependentAssembly>

저에게는 위의 시나리오 중 어느 것도 효과가 없었습니다.

이틀 동안 노력한 끝에 마침내 해결책을 찾았습니다.

내가 한 일은 Microsoft.AspNet.Web.OptimizationWebGrease를 모두 제거 했습니다.

이 최적화 어셈블리가 내부적으로 WebGrease 1.5.1을 참조한다는 것을 알고있었습니다. 그래서 WebGrease 1.5.1을 참조하지 않는 최적화 버전을 선택했습니다.

모든 것이 작동하도록하기 위해 다음 명령을 실행했습니다.

Uninstall-Package Microsoft.AspNet.Web.Optimization
Uninstall-Package WebGrease
Install-Package Microsoft.AspNet.Web.Optimization -Version 1.1.0

위의 솔루션이 효과가없는 사람에게 좋은 도움이 될 수 있기를 바랍니다.

건배!


내가 관찰 한 문제는 Jidheesh Rajan이 언급 한 것과 거의 일치했습니다. 그러나 버전을 지정하지 않고 Nuget 패키지 관리자에서 패키지를 업데이트해도 문제가 해결되지 않았습니다. 문제를 해결하기 위해해야 ​​할 일은 다음과 같습니다. (본질적으로 WebGrease를 버전 1.6으로 명시 적으로 업데이트했습니다.)

Visual Studio의 패키지 관리자 콘솔에서 WebGrease를 버전 1.6으로 명시 적으로 업데이트합니다. 여기에 명령이 있습니다.

Install-Package WebGrease -Version 1.6

출력은

Removing 'WebGrease 1.5.2' from {project name}

{project name}에 'WebGrease 1.6.0'추가하기 {project name}에 'WebGrease 1.6.0'추가 성공 'WebGrease 1.5.2'제거. 'WebGrease 1.5.2'를 성공적으로 제거했습니다.

이로 인해 web.config가 다음과 같이 업데이트되었습니다.

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

이로 인해 csproj 파일에서 행이 제거되었습니다.

<WebGreaseLibPath>..\packages\WebGrease.1.5.2\lib</WebGreaseLibPath>

csproj 파일에서이 노드의 업데이트

<Reference Include="WebGrease, Version=1.5.2.14234, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\WebGrease.1.5.2\lib\WebGrease.dll</HintPath>
  <SpecificVersion>False</SpecificVersion>
  <Private>True</Private>
</Reference>

이에

<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
  <SpecificVersion>False</SpecificVersion>
  <Private>True</Private>
</Reference>

스테이지 웹 서버에서만 로컬 컴퓨터에 문제가 없었 음을 기억하십시오. 패키지를 업데이트하지 않고 문제를 해결하기 위해 최선을 다하고 싶었지만 이것이 내가 가진 유일한 해결책이었습니다.


많은 것을 시도했지만 때로는 Web.Optimization 어셈블리 문제가 발생하는 경우가 있습니다. 이것은 Microsoft.AspNet.Web.Optimization 1.1.3에서 저에게 효과적이었습니다.

Update-Package WebGrease -Version 1.6

명품이지만 골디 ...

Visual Studio 2013에서 MVC 5 프로젝트를 진행하고 있었는데 같은 문제가 발생했습니다. 우리는 버전 관리를 위해 Visual SVN을 사용하고 있었고,이 문제가있는 팀원은 저뿐이었습니다.

나를 위해 일한 유일한 것은 다음과 같습니다.

  1. Microsoft.AspNet.Web.Optimization 제거
  2. Nuget 명령 프롬프트에서 다음을 실행합니다. install-package Microsoft.AspNet.Web.Optimization -Version 1.0.0

Web.Optimization의 이전 버전을 설치합니다. 이 프로젝트는 처음에 버전 1.1.0을 참조했습니다. 문제는 WebGrease가 아니라 기존의 WebGrease 버전을 참조하는 System.Web.Optimization.dll에 있습니다.

프로젝트를 실행했을 때 효과가 있었지만 나머지 팀과 동일한 패키지 버전을 사용하고 싶었습니다. 그래서 업데이트를 시도했지만 ... 오류가 반환되었습니다 ...

그 후 프로젝트를 (다시) 삭제하고 SVN에서 다시 가져 왔습니다. 놀랍게도 작동하기 시작했습니다. 문제는 프로젝트를 완전히 삭제하고 이전에 SVN에서 여러 번 가져간 것입니다. NuGet에서 손상된 파일을 받고 있지만 아무 소용이 없다고 생각했기 때문에 동료로부터 dll을 가져 왔습니다.

언젠가 Visual Studio 2016 및 MVC 8을 통해 누군가에게 도움이되기를 바랍니다. :)


당신이 webgrease이 있는지 확인 리디렉션 할 때 당신은 필요가 없습니다 appliesTo의 온 속성 assemblyBinding의 요소를. 나를 위해 나는 그것을 완전히 제거했습니다.

여기에 이미지 설명 입력


패키지 관리자 콘솔을 사용하여 제거 할 수 없었기 때문에 수동으로 이동 packages.config하여 이전 버전을 주석 처리했습니다.


내가 사용 "Install-Package Microsoft.AspNet.Web.Optimization"starup의 대한 (현재 버전은 1.1.3이다) 웹 프로젝트 기본적으로 NuGet 콘솔에서 선택되지 않았습니다.

그러나 NuGetweb.config가 업데이트 될 것으로 예상되지만 새 app.config 파일을 만들었습니다 .

나에게는 할 일 WebGrease dependentAssembly의 이동 에서 요소 app.configweb.config의 ' <runtime><assemblyBinding>...</assemblyBinding></runtime>.


The other answers did not resolve this for me. We are adding a newer MVC 5 API project and it wasn't playing nice with the older MVC 2 API's. After running package updates I was getting the mentioned error. The resolution for me was to remove the WebGrease references added by NuGet in the web.config's of the offending projects.

To Resolve: Open the web.config of the project(s) throwing the exception and delete or comment out the dependency added for WebGrease.


Alreasy resolved this error. Situation was simpler than i thought. When you install from nuget new version of System.Web.Optimization it has reference to

// References: WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35

At same time i have WebGrease version 1.5.2.14234. Running project, we have this error: Could not load file or assembly 'WebGrease, Version=1.5.1.25624

Soo, i try to check this version on nuget and was surprized, that it wasn't...but when i create new project with VS - i got it. To hack this error i try to install it in GAC..but gac says me, that this lib is not subscribed. Downgrading to System.Web.Optimization Version=1.1.0.0 , where reference is:

// References: WebGrease, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

and 1.3.0.0 is strongly subscribed - helped me. It works. After upgrading webgrease, i have it Version=1.6.5135.21930 and it worked perfectly.

At conclusion, i have an opinion, than this error (Could not load file or assembly 'WebGrease, Version=1.5.1.25624) was because of that System.Web.Optimization lib is referenced to unsubscribed webgrease dll version.


I had this issue during a deployment.

I copied WebGrease.dll to production, but I forgot to update the Web.Config file as well.

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

Here is what I did to get around it,

  1. I saved a copy of the Web.config file of my current (corrupted project) to "Corrupted-Web.Config". and close the project solution.
  2. Created a new application with the same type of my courrpted project. called it ProjTemp.
  3. Save and Run the "PorjTemp", then Save a copy of the Web.Config to "OrigTemp_Web.config"
  4. Close the Web.config files.
  5. "ProjTemp"에서 도구-> "NuGet 패키지 관리자"-> "솔루션 용 NuGet 패키지 관리"---> 설치된 모든 관련 패키지를 업데이트하려면 선택하십시오. 6 이제 새로 업데이트 된 Web.config 파일을 엽니 다. 업데이트 된 ""시작 위치 "에서 정보 가져 오기를 복사합니다.

<runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
             --- Copy this section to replace in the corrupted file.---
       </assemblyBinding>
</runtime>

  1. 프로젝트를 저장하십시오. 다시 빌드하고 실행합니다. 이것이 도움이되기를 바랍니다! ....

예를 들어 VS2015와 같은 수정 된 것이 있습니다.


<runtime>
           <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                 <dependentAssembly>
                        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
                        <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
                 </dependentAssembly>
                <dependentAssembly>
                        <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
                        <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
              </dependentAssembly>
              <dependentAssembly>
                        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
                        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /
              </dependentAssembly>
              <dependentAssembly>
                        <assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" />
                        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /
                </dependentAssembly>
                <dependentAssembly>
                        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31bf3856ad364e35" />
                        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
                </dependentAssembly>
                <dependentAssembly>
                        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31bf3856ad364e35" />
                        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
                 </dependentAssembly>
                 <dependentAssembly>
                        <assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" />
                         <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
                  </dependentAssembly>
                  <dependentAssembly>
                         <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
                        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
                   </dependentAssembly>
          </assemblyBinding>
  </runtime>

그것이 내가 그것을 고치기 위해 한 일입니다, Github Sami의 솔루션 , Oweis 4 Computer


Web.config 파일을 웹 서버에 배포하지 않은 경우에도이 문제가 발생할 수 있습니다.

참고 URL : https://stackoverflow.com/questions/19851912/could-not-load-file-or-assembly-webgrease-version-1-5-1-25624-culture-neutral

반응형