Development Tip

파일 또는 어셈블리 System.Net.Http, 버전 = 4.0.0.0을 ASP.NET (MVC 4) 웹 API OData 프리 릴리즈와 함께로드 할 수 없습니다.

yourdevel 2020. 9. 25. 23:44
반응형

파일 또는 어셈블리 System.Net.Http, 버전 = 4.0.0.0을 ASP.NET (MVC 4) 웹 API OData 프리 릴리즈와 함께로드 할 수 없습니다.


문제

Microsoft ASP.NET Web API OData 패키지 5.0.0-rc1 시험판을 설치 한 후 다음 예외가 발생합니다.

파일 또는 어셈블리 'System.Web.Http, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'또는 해당 종속성 중 하나를로드 할 수 없습니다. 찾은 어셈블리의 매니페스트 정의가 어셈블리 참조와 일치하지 않습니다. (HRESULT 예외 : 0x80131040)

내 MVC 4 프로젝트는 아주 새롭고 정말 작습니다. .NET Framework 4.5를 대상으로합니다.

Delta 클래스를 사용하여 PATCH구현 하려면이 너겟 패키지필요합니다 (패키지 4.0.0.0 버전을 사용하면 Delta 클래스가 작동하지 않습니다).

어떻게 고칠 수 있습니까?

내 버전의 System.Web.Http

에서 GAC 나는 버전이 5.0.0.0 System.Web.Http의를

gacutil -l System.Web.Http 전역 어셈블리 캐시에는 System.Web.Http, Version = 5.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35, processorArchitecture = MSIL 어셈블리가 포함되어 있습니다.

에서 비주얼 스튜디오 , 내가 어셈블리를 탐색 할 때, System.Web.Http의 주어진 버전입니다 4.0.0.0 (왜?)

에서 내 프로젝트 , System.Web.Http에 대한 참조

  • 버전 5.0.0.0 있음
  • 패키지의 \ lib \ net45 \ 폴더를 가리 킵니다.
  • CopyLocal = true 있음

내가 시도한 것

Web.config에서 리디렉션 v 4.0.0.0을 5.0.0.0으로 바인딩하려고했습니다.

<dependentAssembly>
    <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="4.0.0.0-4.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>

하지만 또 다른 예외가 있습니다.

'System.Web.Http.GlobalConfiguration..cctor ()'메서드에서 'System.Web.Http.GlobalConfiguration.CS $ <> 9__CachedAnonymousMethodDelegate2'필드에 액세스하지 못했습니다.

v 4.0.0.0은 핵심 Web Api 엔진에서 실제로 사용해야한다고 생각합니다.

연결된 질문

코드 분석 오류 MVC4 Web API에서 'System.Net.Http, 버전 = 2.0.0.0'파일 또는 어셈블리를로드 할 수 없습니다. MVC4 Web API에서 'System.Net.Http, 버전 = 2.0.0.0'파일 또는 어셈블리를로드 할 수 없습니다.


Visual Studio 2013에는이를 처리하는 새로운 기능이 있습니다. 앱을 빌드 할 때 참조되는 어셈블리의 다른 버전에 대한 경고가 표시되어야합니다. 경고를 두 번 클릭하여 web.config에 어셈블리 바인딩 리디렉션을 추가합니다.

자세한 내용은 http://msdn.microsoft.com/en-us/library/2fc472t2.aspx 를 참조하십시오.

jeff.eynon은 아래에서 VS가 파일을 자동으로 편집하도록하려면 web.config를 체크 아웃해야합니다 (TFS 소스 제어를 사용하는 경우). 팁 고마워!


Nuget을 사용하여 WebApi 패키지를 시험판 버전으로 업그레이드하여 작동하도록 만들었습니다.

PM> Microsoft.AspNet.WebApi -Pre

최신 버전의 WebApi를 사용하여 프로젝트를 강제 실행하려면 루트 Web.config를 일부 수정해야합니다.

1) 웹 페이지 버전 2.0.0.0에서 3.0.0.0으로

<appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
</appSettings>

2) System.Web.Http 및 System.Net.Http.Formatting에 대해 5.0.0.0으로 바인딩 리디렉션

<dependentAssembly>
    <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
    <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>

그게 다인 것 같아요

PS : WebAPI OData 5.0 Beta 에서 영감을받은 솔루션 -GlobalConfiguration에 액세스하면 보안 오류가 발생합니다.


나는 같은 문제를 만났고 다음 libs에 대해 CopyLocal을 true로 설정하여 해결했습니다.

System.Web.Http.dll
System.Web.Http.WebHost.dll
System.Net.Http.Formatting.dll

MVC4 및 NET 4를 사용한다는 것을 추가해야합니다.


프로젝트 템플릿에서 Hot Towel Project를 업데이트하려고 할 때와 2013 년 10 월 23 일 현재 VS 2012에서 빈 프로젝트를 만들고 Nuget을 통해 HotTowel을 설치할 때이 문제가 발생했습니다.

문제를 해결하기 위해 Nuget을 통해 Web Api 웹 호스트 및 Web API 패키지를 현재 NuGet의 현재 버전 인 5.0으로 업데이트했습니다 (2013 년 10 월 23 일).

그런 다음 바인딩 지시를 추가했습니다.

<dependentAssembly>
  <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
  <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>

또는 NuGet 패키지 관리자 콘솔에서이 작업을 수행 할 수 있습니다.

 Install-Package Microsoft.AspNet.WebApi -Version 5.0.0

그런 다음 System.Web.Http.WebHost 5.0에 대한 참조를 추가 할 수 있습니다.


참조에서 System.Web.Http 및 System.Net.Http.Formatting을 제거하고 bin 폴더 (nuget에 의해 복사 된 위치)로 이동하여 참조를 다시 추가합니다. 이제 파일 버전은 5.0.0.0입니다.


이 오류는 여러 프로젝트에서 여러 번 발생했습니다.

What I finally figured out is that when I would build, there was already a copy of the system.web.mvc binary assembly in my bin folder.

To fix this, right-click on the assembly in the list of references and select "properties". Check to see if this is the latest version by looking at the "Version" property. If it is, switch "Copy Local" to true.

This will make sure that the version referenced in your project is the version that will end up in your binaries folder.

If you still get the error, try running nuGet to get the latest version, then try the aforementioned again.

Good luck - this error is a pain!


I faced the same error. When I installed Unity Framework for Dependency Injection the new references of the Http and HttpFormatter has been added in my configuration. So here are the steps I followed.

I ran following command on nuGet Package Manager Console: PM> Install-Package Microsoft.ASPNet.WebAPI -pre

And added physical reference to the dll with version 5.0


i solve by way nuget. the first you install nuget. the second you use.
illustration follow:

third : Check to see if this is the latest version by looking at the "Version" property.

The finaly : you check project have latest version again.


I have faced same type of issue and followed the below steps to resolved the issue

Go to Tools --> Library Package Manager --> Package Manager Console and run the below command

Install-Package Microsoft.ASPNet.WebAPI -pre


After modifying the References in the Web.config file as mentioned above, we resolved the references.

I was facing similar issue.

For us we have reference Microsoft.Data.Edm.dll and OData.dll and other assemblies from Program Files:

C:\Program Files (x86)\Microsoft WCF Data Services\5.0
                          \bin\.NETFramework\Microsoft.Data.Edm.dll

and

C:\Program Files (x86)\Microsoft WCF Data Services\5.0
                        \bin\.NETFramework\Microsoft.Data.OData.dll

and version was 5.6.4.

Once I change the reference of both assemblies to C:\....Project\packages\Microsoft.Data.Edm.5.6.0 , the issue was resolved


Went into nuget package manager and updated my packages. Now it works. The main one I updated was the Microsoft.AspNet.WebApi.Core. May need to do this with both projects to sync up the proper references.


If this issue occurs, kindly check web.config in below section

Below section gives the version of particular dll used

after checking this section in web.config, open solution explorer and select reference from the project tree as shown . Solution Explorer->Reference

참조를 확장 한 후 오류를 일으킨 dll을 찾으십시오. dll 참조를 마우스 오른쪽 버튼으로 클릭하고 위 이미지와 같은 버전을 확인하십시오.

구성 dll 버전과 참조 된 dll이 모두 다른 경우이 예외가 발생합니다. 둘 다 도움이 될 동일한 버전인지 확인하십시오.

참고 URL : https://stackoverflow.com/questions/18982682/could-not-load-file-or-assembly-system-net-http-version-4-0-0-0-with-asp-net-m

반응형