programing

파일 또는 어셈블리 'System.Web.WebPages.Razor, 버전 = 2.0.0.0을로드 할 수 없습니다.

projobs 2021. 1. 17. 10:23
반응형

파일 또는 어셈블리 'System.Web.WebPages.Razor, 버전 = 2.0.0.0을로드 할 수 없습니다.


방금 MVC 3 프로젝트 (ASP.net 4)에서 패키지를 업그레이드했는데 이제 해당 프로젝트의 페이지에 액세스 할 때 다음 오류 메시지가 표시됩니다.

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

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

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

소스 오류 :

현재 웹 요청을 실행하는 동안 처리되지 않은 예외가 생성되었습니다. 아래의 예외 스택 추적을 사용하여 예외의 출처 및 위치에 대한 정보를 식별 할 수 있습니다.

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

=== 사전 바인딩 상태 정보 === 로그 : 사용자 = IIS APPPOOL \ ASP.NET v4.0 로그 : DisplayName = System.Web.WebPages.Razor, 버전 = 2.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 ( 완전히 지정됨) LOG : Appbase = file : /// C : /.../ LOG : Initial PrivatePath = C : ... \ bin Calling assembly : Microsoft.Web.Helpers, Version = 2.0.0.0, Culture = neutral , PublicKeyToken = 31bf3856ad364e35. === LOG :이 바인딩은 기본로드 컨텍스트에서 시작됩니다. 로그 : 응용 프로그램 구성 파일 사용 : C : ... \ web.config 로그 : 호스트 구성 파일 사용 : C : \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ aspnet.config 로그 : C에서 컴퓨터 구성 파일 사용 : \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ config \ machine.config. 로그 : 정책 후 참조 : System.Web.WebPages.Razor, 버전 = 2.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 로그 : 새 URL 파일 다운로드 시도 : ///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files /.../ cb62a7b2 / 327a0353 / System.Web.WebPages.Razor.DLL. 로그 : 새 URL 파일 다운로드 시도 중 : ///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files /.../ cb62a7b2 / 327a0353 / System.Web.WebPages.Razor / System .Web.WebPages.Razor.DLL 로그 : 새 URL 파일 다운로드 시도 : ///C:/LeGroupeHtmSVN/.../UpDir.Web/bin/System.Web.WebPages.Razor.DLL. WRN : 어셈블리 이름을 비교 한 결과 불일치가 발생했습니다. 주 버전 오류 : 어셈블리 설정을 완료하지 못했습니다 (hr = 0x80131040). 조사가 종료되었습니다. 30319 / Temporary ASP.NET 파일 /.../cb62a7b2/327a0353/System.Web.WebPages.Razor/System.Web.WebPages.Razor.DLL. 로그 : 새 URL 파일 다운로드 시도 : ///C:/LeGroupeHtmSVN/.../UpDir.Web/bin/System.Web.WebPages.Razor.DLL. WRN : 어셈블리 이름을 비교 한 결과 불일치가 발생했습니다. 주 버전 오류 : 어셈블리 설정을 완료하지 못했습니다 (hr = 0x80131040). 조사가 종료되었습니다. 30319 / Temporary ASP.NET 파일 /.../cb62a7b2/327a0353/System.Web.WebPages.Razor/System.Web.WebPages.Razor.DLL. 로그 : 새 URL 파일 다운로드 시도 : ///C:/LeGroupeHtmSVN/.../UpDir.Web/bin/System.Web.WebPages.Razor.DLL. WRN : 어셈블리 이름을 비교 한 결과 불일치가 발생했습니다. 주 버전 오류 : 어셈블리 설정을 완료하지 못했습니다 (hr = 0x80131040). 조사가 종료되었습니다.

스택 추적 :

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

[InvalidOperationException : Microsoft.Web.Helpers.PreApplicationStartCode 유형의 사전 응용 프로그램 시작 초기화 메서드 시작에서 다음 오류 메시지와 함께 예외가 발생했습니다. 파일 또는 어셈블리를로드 할 수 없습니다. 'System.Web.WebPages.Razor, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 '또는 해당 종속성 중 하나입니다. 찾은 어셈블리의 매니페스트 정의가 어셈블리 참조와 일치하지 않습니다. (HRESULT 예외 : 0x80131040)]
System.Web.Compilation.BuildManager.InvokePreStartInitMethods (ICollection`1 메서드) +11711966
System.Web.Compilation.BuildManager.CallPreStartInitMethods () +465
System.Web.Hosting.HostingEnvironment.Initialize (ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1167

[HttpException (0x80004005) : Microsoft.Web.Helpers.PreApplicationStartCode 유형의 사전 응용 프로그램 시작 초기화 메서드 시작에서 다음 오류 메시지와 함께 예외가 발생했습니다. 'System.Web.WebPages.Razor, 버전 = 2.0'파일 또는 어셈블리를로드 할 수 없습니다. .0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 '또는 해당 종속성 중 하나. 찾은 어셈블리의 매니페스트 정의가 어셈블리 참조와 일치하지 않습니다. (HRESULT 예외 : 0x80131040).]
System.Web.HttpRuntime.FirstRequestInit (HttpContext 컨텍스트) +11700896 System.Web.HttpRuntime.EnsureFirstRequestInit (HttpContext 컨텍스트) +141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate (IIS7WorkerRequest wr, HttpContext 컨텍스트) + 4869125

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

내 web.config 파일과 내 응용 프로그램에서 System.Web.WebPages.Razor v1.0.0.0을 참조하고 있습니다.

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

.Net 4와 함께 System.Web.WebPages.Razor v2.0.0.0을 사용할 수 있는지조차 모르겠습니다.

이제 System.Web.WebPages.Razor v2.0.0.0을 참조하는 것이 무엇인지 어떻게 알 수 있습니까?


System.Web.WebPages.Razor v2.0.0.0을 참조하는 것이 무엇인지 어떻게 알 수 있습니까?

예외 스택 추적을 읽으십시오.

Calling assembly : Microsoft.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

따라서에 Microsoft.Web.Helpers의존하는을 사용하는 것 같습니다 System.Web.WebPages.Razor, Version=2.0.0.0.


아주 간단합니다. Nuget 패키지 관리자 콘솔에서 :

업데이트 패키지 Microsoft.AspNet.Mvc-재설치


이 문제는 '사용하지 않는 참조 제거'를 수행했을 때 시작되었습니다. 웹 사이트는 여전히 내 로컬 컴퓨터에서 작동했지만 게시 후 서버에서 작동하지 않았습니다.

Remove unused references

다음을 수행하여이 문제를 해결했습니다.

  1. Visual Studio에서 '패키지 관리자 콘솔'을 엽니 다.
  2. 제거 패키지 Microsoft.AspNet.Mvc
  3. 설치 패키지 Microsoft.AspNet.Mvc

많은 고통, 인터넷 검색 및 머리카락 잡아 당기기 후 nuget을 사용하여 MVC 4를 제거하고 웹 구성에서 MVC, 면도기 및 인프라에 대한 모든 참조를 삭제하고 bin 폴더에서 dll을 삭제 한 다음 nuget을 사용하여 모든 것을 다시 설치했습니다. dll이 일치하지 않는 이유를 파악하는 데 시간이 덜 걸렸습니다.


ASP.NET MVC 4에서 네임 스페이스는 System.Web.WebPages.Razor가 아니라 System.Web.Razor입니다.

그것은 나를 위해 일했습니다 .web.config를 변경하십시오.


I was getting the same error after adding an unnecessary reference to System.Web.Mvc. I removed all the references I could find, but nothing seemed to work. I finally deleted the project's bin folder and the error went away after a rebuild.


I uninstalled ASP.NET MVC 4 using the Windows Control Panel, then reinstalled it by running AspNetMVC4Setup.exe (which I got from https://www.microsoft.com/en-us/download/details.aspx?id=30683), and that fixed the issue for me.

In other words, I didn't need to use Nuget or Visual Studio.


I also received this error and tried everything I could find online and it wouldn't go away. In the end, I just downgraded MVC from 5.2.3 to 4.0.40804. I don't like this solution because eventually I'll need to use MVC 5, but it works for now. Hope this helps others.


Short:
In you have this problem with a pure Web API project (and thus don't need razor), try to add it anyway, rebuild, then remove it.

Long story:
I had this problem with a brand-new pure Web API project, except that the stacktrace pointed "System.Web.Mvc" as Calling assembly (see Darin's answer). No reference to MVC, Razor or anything like that in my project though...
I decided to add the MVC packages (AspNet.Mvc, AspNet.WebPages and AspNet.Razor) to check if there was any subsequent problem.
The WebApi app then launched perfectly fine. Then I removed the exact same packages and everything was still OK.

Hope it helps someone.


In some cases, just install web page 2 to resolve this (resolved with my case - deploy to local web page using web api )

https://www.microsoft.com/en-us/download/details.aspx?id=34600


If earlier working project crashing suddenly with mentioned error you can try following solution.

  • Delete the bin folder of respective web/service project.
  • Build

This worked for me.


For similar assembly binding errors , following steps may help:

  1. Right click on your Solution and click Manage Nuget Packages for Solution ...
  2. go to Consolidate Tab (last tab) and check if any any differences between packages installed in different projects inside your solution. specially pay attention to your referenced projects which may have lower versions because they usually are less noticed)
  3. consolidate specially packages related to your assembly error and note that many packages are dependent on some other packages like *.code & *.api & ...
  4. after resolving all suspected consolidations , rebuild and rerun the app and see if the assembly bindings are resolved.

I first tried Mohammed Emad's answer - no joy. Then I tried

git clean -x -d -f

which brought me to a new "Roslyn" error which I was able to fix by manually editing my .csproj.

Interestingly, after I'd read down a bit further down the page on the Roslyn question, I found another suggestion with even more votes (Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r). Thinking I'd rather implement that than manually edit .csproj, I backed out my .csproj changes, only to find my solution was still working.

So after all that, I'm wondering if Mohammed's answer (on this page) would have done the trick, had I simply done the git clean first.


I was getting the same error when i upgrade MVC4 to MVC5 version, Firstly i Upgraded the calling assembly which was depends on

> System.Web.WebPages.Razor, Version=2.0.0.0

after that updated the web.config files under the Views folder, updated following packages from

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

to

<configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.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>

and also updated

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

to

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

these steps works for me

ReferenceURL : https://stackoverflow.com/questions/11000506/could-not-load-file-or-assembly-system-web-webpages-razor-version-2-0-0-0

반응형