IT

2012 년에서 2013 년으로 업데이트 한 후 파일 또는 어셈블리 'System.Web.Http 4.0.0을로드 할 수 없습니다.

lottoking 2020. 5. 19. 08:18
반응형

2012 년에서 2013 년으로 업데이트 한 후 파일 또는 어셈블리 'System.Web.Http 4.0.0을로드 할 수 없습니다.


에 따라 업그레이드를 수행했습니다. http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and- 웹 API-2

오류가 발생합니다. 다른 사람 이이 오류가 발생합니까?

'/'응용 프로그램에 서버 오류가 있습니다.

파일 또는 어셈블리 'System.Web.Http, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'또는 해당 종속성 중 하나를로드 할 수 없습니다. 찾은 어셈블리의 매니페스트 정의가 어셈블리 참조와 일치하지 않습니다. (HRESULT 예외 : 0x80131040)
설명 : 현재 웹 요청을 실행하는 동안 처리되지 않은 예외가 발생했습니다. 오류 및 코드에서 발생한 위치에 대한 자세한 정보는 스택 추적을 검토하십시오.

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

소스 오류 :

48 행 : 49 행 : 50 행 :} 51 행 : 52 행 : protected void Application_BeginRequest (객체 발신자, EventArgs e)

소스 파일 : d : \ SM \ 7.4Test \ WebAPIServerV2 \ ThirdPartyWebAPI \ Global.asax.cs 줄 : 50

어셈블리로드 추적 : 다음 정보는 'System.Web.Http, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'어셈블리를로드 할 수없는 이유를 확인하는 데 도움이 될 수 있습니다.

=== 사전 바인딩 상태 정보 === 로그 : DisplayName = System.Web.Http, 버전 = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 (완전히 지정됨) LOG : Appbase = file : /// D : /SM/7.4Test/WebAPIServerV2/ThirdPartyWebAPI/ LOG : 초기 PrivatePath = D : \ SM \ 7.4Test \ WebAPIServerV2 \ ThirdPartyWebAPI \ bin 호출 어셈블리 : ThirdPartyWebAPI, 버전 = 1.0.0.0, Culture = neutral, PublicKeyToken = null. === LOG :이 바인드는 기본로드 컨텍스트에서 시작합니다. 로그 : 응용 프로그램 구성 파일 사용 : D : \ SM \ 7.4Test \ WebAPIServerV2 \ ThirdPartyWebAPI \ web.config 로그 : 호스트 구성 파일 사용 : C : \ Users \ michalc \ Documents \ IISExpress \ config \ aspnet.config 로그 : 컴퓨터 구성 사용 C : \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ config \ machine.config의 파일입니다. LOG : 정책 후 참조 : System.Web.Http, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 LOG : 새 URL 파일 다운로드 시도 중 : ///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files / root / 9184b2ea / c6d4b139 / System.Web.Http.DLL. LOG : 새 URL 파일 다운로드 시도 : ///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files / root / 9184b2ea / c6d4b139 / System.Web.Http / System.Web.Http .DLL. LOG : 새 URL 파일 다운로드 시도 : ///D:/SM/7.4Test/WebAPIServerV2/ThirdPartyWebAPI/bin/System.Web.Http.DLL. WRN : 어셈블리 이름을 비교하면 불일치가 발생했습니다. 주 버전 ERR : 어셈블리 설정을 완료하지 못했습니다 (hr = 0x80131040). 프로빙이 종료되었습니다. NET / Framework / v4.0.30319 / Temporary ASP.NET 파일 /root/9184b2ea/c6d4b139/System.Web.Http/System.Web.Http.DLL. LOG : 새 URL 파일 다운로드 시도 : ///D:/SM/7.4Test/WebAPIServerV2/ThirdPartyWebAPI/bin/System.Web.Http.DLL. WRN : 어셈블리 이름을 비교하면 불일치가 발생했습니다. 주 버전 ERR : 어셈블리 설정을 완료하지 못했습니다 (hr = 0x80131040). 프로빙이 종료되었습니다. NET / Framework / v4.0.30319 / Temporary ASP.NET 파일 /root/9184b2ea/c6d4b139/System.Web.Http/System.Web.Http.DLL. LOG : 새 URL 파일 다운로드 시도 : ///D:/SM/7.4Test/WebAPIServerV2/ThirdPartyWebAPI/bin/System.Web.Http.DLL. WRN : 어셈블리 이름을 비교하면 불일치가 발생했습니다. 주 버전 ERR : 어셈블리 설정을 완료하지 못했습니다 (hr = 0x80131040). 프로빙이 종료되었습니다.

스택 추적 :

[FileLoadException : 파일 또는 어셈블리 'System.Web.Http, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'또는 해당 종속성 중 하나를로드 할 수 없습니다. 찾은 어셈블리의 매니페스트 정의가 어셈블리 참조와 일치하지 않습니다. (HRESULT 예외 : 0x80131040)] d : \ SM \ 7.4Test \ WebAPIServerV2 \ ThirdPartyWebAPI \ Global.asax.cs : 50의 ThirdPartyWebAPI.WebApiApplication.Application_Start ()

[HttpException (0x80004005) : 파일 또는 어셈블리 'System.Web.Http, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'또는 해당 종속성 중 하나를로드 할 수 없습니다. 찾은 어셈블리의 매니페스트 정의가 어셈블리 참조와 일치하지 않습니다. (HRESULT 예외 : 0x80131040)]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode (HttpContext context, HttpApplication app) +9935033
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS (IntPtr appContext, HttpContext context, MethodInfo [] 처리기) +118
System.Web.HttpApplication .InitSpecial (HttpApplicationState 상태, MethodInfo [] 핸들러, IntPtr appContext, HttpContext 컨텍스트) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance (IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication (IntPtr appContext) +296

[HttpException (0x80004005) : 파일 또는 어셈블리 'System.Web.Http, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'또는 해당 종속성 중 하나를로드 할 수 없습니다. 찾은 어셈블리의 매니페스트 정의가 어셈블리 참조와 일치하지 않습니다. (HRESULT 예외 : 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit (HttpContext context) +9913572 System.Web.HttpRuntime.EnsureFirstRequestInit (HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate (IIS7WorkerRequest wr, HttpContext 컨텍스트) +254


버전 정보 : Microsoft .NET Framework 버전 : 4.0.30319; ASP.NET 버전 : 4.0.30319.18408


깨진 종속성을 수정 하는 NuGet 패키지다시 설치 하여이 문제를 해결했습니다 . 패키지 관리자에서 다음을 실행하십시오.

Update-Package Microsoft.AspNet.WebApi -reinstall

파일 또는 어셈블리 'System.Web.Http'를로드 할 수 없습니다 오류를 해결하려면 NuGet을 사용하여 Web API 2.1 WebHost를 설치하십시오.

참조의 솔루션 탐색기에서 마우스 오른쪽 단추를 클릭하고 너겟 패키지 관리를 선택하십시오. (nuget을 설치하지 않은 경우)

여기에 이미지 설명을 입력하십시오

왼쪽의 NuGet 패키지 관리 창에서 온라인을 클릭 한 다음 오른쪽 상단에서 웹 호스트를 검색하고 Microsoft ASP.NET Web API 2.1 웹 호스트를 설치하십시오. (설치가 완료되면 설치 버튼이 녹색 확인으로 바뀝니다)

그 후 프로젝트가 다시로드되고 다시 빌드되면 오류가 해결되고 프로젝트가 디버그되고 실행됩니다. 오류가 사라지고 '자원을 찾을 수 없습니다. URL을 추가하십시오 (예 : localhost : 52088 /에서 localhost : 52088api / products)

당신의 질문은 좋았고 저를 도왔습니다.

이 답변이 도움이 되길 바랍니다!


어셈블리 리디렉션을 추가해야합니다.

<configuration>

   ....

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

   ...

</configuration>

웹 호스팅 등과 같은 몇 가지 어셈블리에 대해이 작업을 수행해야합니다.


또는 NuGet Package Manager Console에서이를 수행 할 수 있습니다.

 Install-Package Microsoft.AspNet.WebApi -Version 5.0.0

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


Web Api 2.2 도움말을 설치하면이 오류가 시작되었습니다. 나는 이것을 web.config에 추가하고 내 문제를 해결했다.

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

나는 단순히 Copy Local = true누락 된 어셈블리 를 설정 했고 효과가있었습니다. 물론 누락 된 참조 (오류 메시지에 표시됨)를 마우스 오른쪽 버튼으로 클릭하고 속성을 선택하면됩니다. 아래:

여기에 이미지 설명을 입력하십시오

그러면 문제를 일으키는 어셈블리가 두 개 이상있을 수 있으므로 하나의 문제를 해결해야합니다. 내가 한 것은 모든 어셈블리를 선택하고 마우스 오른쪽 단추를 클릭하는 것입니다. 선택된 속성들; 그리고 모두 복사 로컬 = true로 설정하십시오. 그런 다음 다시 게시하십시오.


이 문제를 해결하는 올바른 해결책은 다음 단계를 따르는 것입니다.

. 이전 버전이 15.5.4 인 경우 Visual Studio를 업데이트합니다 (선택 사항)

  1. web.config에서 모든 바인딩 리디렉션을 제거하십시오.

  2. 이것을 csproj 파일에 추가하십시오 :

 <PropertyGroup>
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

  1. 짓다.

  2. bin 폴더에는 (WebAppName).dll.config파일 이 있어야 합니다.

  3. 리디렉션이 있어야합니다. 이것을 web.config에 복사하십시오.

  4. csproj 파일에서 위의 내용을 다시 제거하십시오.

  5. 작동해야합니다

Detailed Blog


나에게는 로컬 컴퓨터가 아닌 프로덕션 환경에서만이 오류가 발생했습니다. 해결 된 것은 / bin 폴더의 내용을 삭제 한 다음 다시 재생성하는 것입니다.


명백하지만 가능한 유용한 힌트 .... webconfig 어셈블리 바인딩에 지정한 새 버전이 프로젝트 참조에서 참조하는 버전과 동일한 지 확인하십시오. (즉,이 글을 쓰는 동안 ... System.Web.Http에서 최근에 NUGet을 수행 한 경우 5.1.0.0이됩니다.


 Installing NuGet package ASP.NET.MVC solved the issue for me. 
 To install package.
 - Right click on project 
 - Select "Manage NuGet Packages"
 - Select Online->Nuget.org from left menu
 - select "Microsoft ASP.NET MVC"
 - Click Install

 If you have already installed package earlier, please update the package by selecting Updates from left menu and then selecting "Microsoft ASP.NET" and click Update.

여기에 이미지 설명을 입력하십시오

여기에 이미지 설명을 입력하십시오


이것은 누군가를 도울 수 있습니다.

MVC4 앱을 사용하기로 결정했습니다.

프로젝트를 실행하고 일했다

그런 다음
Microsoft ASP.NET WEB API 2.2 (4 개 패키지) 와 같은 몇 가지 패키지를 설치했습니다.
Microsoft ASP.NET WEB API 2.2 도움말 페이지
Microsoft ASP.NET WEB API 2.2 OWIN

질문에서 언급 한 것과 동일한 오류로 프로젝트를 실행하십시오.

해결책:

에서 의 Web.config

 <dependentAssembly>
      <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.2.3.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.2.3.0" />
 </dependentAssembly>


Problem Solved


but then, some hotfix error found, To resolve it, go to VIEW folder of your MVC4 project, find second web.config file and changed version from 2.0.0.0 to 3.0.0.0 as shown below.


<configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>


In my case, I was actually missing my web.config altogether, which had the appropriate binding redirects. Restoring the web.config resolved the error.


I found the solution ! Delete folder named package in project directory and then rebuild to run it.


<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>

YES!!!

Install-Package Microsoft.AspNet.WebApi -Version 5.0.0

It works fine in my case....thnkz


Me did not nothing, just copied development Bin folder DLLs to online deployed Bin folder and it worked fine for me.


I could solve similar problem with System.Net.HTTP by adding assembly reference in app.config of main application.

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.1" newVersion="4.0.0.0" />
      </dependentAssembly></runtime>

As others have said just reinstall the MVC package to your web project using nuget, but be sure to add the MVC package to any projects depending on the web project, such as unit tests. If you build each included project individually, you will see witch ones require the update.


I had same problem and reinstalling package doesn't work.

My application runs in LocalIIS(not IIS EXPRESS). I enable Assembly Load Trace and find out it want load System.Web.Http load from below temp catche. so remove all catch folders in it.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files[my application]


I solved this problem by reverting the changes that nuget had made to my web.config after running nuget. Revert the changes to a previous working version.

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
  </dependentAssembly>

What solved the problem for me was re-installing the Microsoft ASP.NET Web API 2.2 Help Page and Microsoft ASP.NET Web API 2.2 OWIN packages. I re-installed both at the same time, but I think it was the former that fixed the issue.

I tried the first few of the solutions offered here but that didn't help, then I compared my dependencies with the ones in a project that worked (from a course on Pluralsight) and the two dependencies above were a lower version (5.0.0) so I updated them to 5.2.3 and it started working.


I had this from a WCF service. For me (as the issue was displaying in local dev), I simply had to delete the contents of the bin folder under the solution. The the rebuild work fine once again.


ASP.NET Version:4.0.30319.18408 belongs to .Net4.5 and System.Web.Http Version=4.0.0.0 is compatible for .NET4.0. So the versions that you have are not compatible. You should update you System.Web.Http to version 5.0.0.0, which is compatible with .Net4.5


I had a similar issue. Everything was working before. It's was originally made using Web Forms and later on added Web API for some things.

  • Tried uninstalling, installing and reinstalling Microsoft.AspNet.WebApi package.
  • Tried removing packages folder from solution and letting NuGet restore in VS.
  • Tried removing individual assembly references (under References) and reinstalling packages.
  • Tried adding binding redirects to 5.2.3.0 version in web.config mentioned in several answers. Nothing worked for me.

What worked was, in Visual Studio, change publish profile settings from Release to Debug. Strange, but that's what worked. So sharing here.


I got this issue when deploying to Azure using the Publish feature. Remember to clear files at destination.

Publish Settings -> File Publish Options drop down -> Check Remove additional files at destination

This solved my issue, in case people have to hunt around for this like I did. Everything was the same version in my project/solution, just not at the destination I was deploying to.


If you use several projects on a solution, and call method in one project to another project, make sure that all projects (called project and caller project) use the unique 'System.Net.Http' version.


Change the Specfic version flag from true to false for the dll in the reference


I had the same problem with System.Web.Http.WebHost, Version=5.2.6.0 being referenced but the latest NuGet package was 5.2.7.0. I edited the web.config files, re-installed the NuGet package, then edited the visual studio project files for all of my projects to make sure no references to 5.2.6.0 persisted. Even after all this, the problem persisted.

Then I looked in the bin folder for the project that was throwing the exception, where I found a DLL for one of my other projects that is not a dependency and should never have been there. I deleted the offending DLL (which had been compiled using the 5.2.6.0 version of System.Web.Http.WebHost), rebuilt the troublesome project, and now it is working.

참고 URL : https://stackoverflow.com/questions/19491860/could-not-load-file-or-assembly-system-web-http-4-0-0-after-update-from-2012-to

반응형