Programing

악명 높은 어셈블리 바인딩 오류

crosscheck 2020. 11. 30. 07:52
반응형

악명 높은 어셈블리 바인딩 오류


문제를 해결하려는 희망을 잃었 기 때문에 정말 도움이 필요합니다.

Office Communications Server 64 비트 라이브러리를 사용하고 있습니다. 프로젝트에서 사용하는 3 개의 dll, Microsoft.Rtc.Collaboration.dll, Microsoft.Rtc.Internal.Media.dll 및 SIPEPS.dll이 있습니다. Microsoft.Rtc.Collaboration에 대해 잘 모르겠지만 Internal.Media와 SIPEPS는 모두 x64입니다. GAC 어셈블리 목록에서 Rtc. Collaboration은 Processor Arhitecture 아래에 MSIL을 표시하고 나머지는 AMD64를 표시합니다.

내 프로젝트는 이러한 참조로 오류없이 컴파일되지만 런타임에 오류가 발생합니다.

파일 또는 어셈블리 'Microsoft.Rtc.Internal.Media'또는 해당 종속성 중 하나를로드 할 수 없습니다. 잘못된 형식으로 프로그램을로드하려고했습니다.

CPU가 모든 CPU로 설정된 프로젝트를 컴파일하려고 시도했지만 아무것도 변경되지 않았습니다. x64 및 x86 설정에서이 오류가 발생합니다.

도움을 주시면 감사하겠습니다.

업데이트 : 아래는 어셈블리 바인딩 로그입니다.

=== Pre-bind state information ===
LOG: User = CONTOSO\elodie
LOG: DisplayName = Microsoft.Rtc.Internal.Media
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.Rtc.Internal.Media | Domain ID: 9
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/elodie/Documents/Visual Studio 2010/Projects/TFS/proto/Main/Source/WebBot.Web/
LOG: Initial PrivatePath = C:\Users\elodie\Documents\Visual Studio 2010\Projects\TFS\proto\Main\Source\WebBot.Web\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\elodie\Documents\Visual Studio 2010\Projects\TFS\proto\Main\Source\WebBot.Web\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/e3d82f59/764fa8c3/Microsoft.Rtc.Internal.Media.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/e3d82f59/764fa8c3/Microsoft.Rtc.Internal.Media/Microsoft.Rtc.Internal.Media.DLL.
LOG: Attempting download of new URL file:///C:/Users/elodie/Documents/Visual Studio 2010/Projects/TFS/proto/Main/Source/WebBot.Web/bin/Microsoft.Rtc.Internal.Media.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

ASP.NET IIS에서이 문제가 발생했고 모든 것을 시도한 후 앱 풀에 대해 32 비트를 활성화하고 응용 프로그램 풀을 다시 시작했습니다. 그런 다음 작동했습니다.

IIS7 관리자에서 : 응용 프로그램 풀-> DefaultAppPool-> 고급 설정-> "32 비트 응용 프로그램 사용"을 true로 설정합니다.

또한 올바른 .Net 버전이 선택되었는지 확인하십시오.

또한 ISAPI 64 비트를 "ISAPI 및 CGI 제한"에서 허용하도록 설정했지만 도움이되었는지 확실하지 않습니다.


제 경우에는 IISExpress를 사용하여 x64 용으로 컴파일 된 웹 프로젝트를 실행했기 때문에이 문제가 발생했습니다. Visual Studio에서 다음 설정을 확인하여 문제를 해결했습니다.

도구 | 옵션 | 프로젝트 및 솔루션 | 웹 프로젝트 | 64 비트 버전의 IIS Express 사용

이것이 동일한 시나리오와 문제를 가진 다른 사람에게 도움이되기를 바랍니다.


세 dll 모두의 64 비트 버전을 32 비트 버전으로 교체하고 임시 ASP.NET 파일 폴더를 정리 한 다음 다시 컴파일했습니다. 이제 문제없이 작동합니다. 도와 주셔서 감사합니다.


해당 어셈블리에 대한 솔루션 탐색기에서 로컬 복사를 설정하고 바인딩 로그에 지정된 폴더에 드롭되는지 확인합니다.

또한 V2 CLR을 사용하여 구축되었을 수도 있습니다. 그렇다면이를 웹 / 앱 구성에 추가하여 혼합 모드 바인딩을 활성화해야합니다.

<configuration>
   <startup  useLegacyV2RuntimeActivationPolicy="true">
       <supportedRuntime version="v4.0"/>
  </startup>
</configuration> 

이 문제를 해결하기 위해 다음 명령을 실행하고 결과를 확인하여 모든 프로젝트가 동일한 버전을 사용하는지 확인했습니다.

update-package Newtonsoft.Json -reinstall

그리고 마지막으로 web.config에서 다음을 제거했습니다.

  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
  </dependentAssembly>

I know this is an old question, but still seems to be a popular result when searching for a solution regarding a partial binding error in Visual studio. I had experienced a very similar issue to the original poster, but with the EntityFramework.dll and Visual studio 2015 (.ASP Web Forms project), however, the solution I found relates to a broad problem. Since I didn't find any answers similar to my solution, I thought it might be helpful to contribute what I found, and I hope it does help someone.

In my web.config I am impersonating a domain user that is a service account. This service account did not have access to my Temporary files folder, therefore when debugging, it could not copy the dlls out there, and therefore could not load them.

What finally tipped we off was going and physically looking in the temporary folder mentioned in the error message. In the original question above, you'll notice the lines "Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files..." When I looked in that folder, my DLLs were not there.

The solution for me was this: Since I was using 64bit environment, and impersonating a domain account, I added the domain service account user to my local C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files folder with write (and modify - for good measure) access.

Bottom line - make sure your Temp files folder grants write access to the user your app is running as.


This is an old question, but was still the top result when I had this same issue today. I had switched my project compilation in Visual Studio to target x64 instead of 'All CPUs' (it's on a 64-bit machine). As per the other answers, there would be two ways to fix it - either change everything to 32-bit or everything to 64-bit. In this case, I needed 64-bit.

KabanaSoft's answer worked perfectly for me. Still correct as of Visual Studio 15.6.6.


I was getting the error when trying to run the web application from Visual Studio, but in my case the answer was simple. When I read the exception carefully I could see that the assembly in question was no longer used by the application but a copy was still in the bin folder. After the offending assembly was removed, the error vanished.


In my case I had gone through my site and replaced the name of the site with a new name. I inadvertently replaced the 'PreviousWebSiteName' with the 'NewWebSiteName' in Web.config where the assembly name was being specified.

    <pages enableSessionState="false" enableViewStateMac="true" enableEventValidation="true" controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID">
  <controls>
    <add assembly="NewWebSiteName" namespace="App_Code.Controls" tagPrefix="blog" />
  </controls>
</pages>

The site was still building an assembly with the old name - I only intended to change the site name where it was appearing on the pages of the site; I didn't need to change anything internally. Restoring the Web.config entry as it was before my naming change (resulting in an entry that matched the name of the built assembly) resolved the error for me.


In my case I had some crap in my web.config, specifically a half-commented out httpHandler that once I cleaned that up, my binding issue disappeared.

참고URL : https://stackoverflow.com/questions/3745612/infamous-assembly-binding-error

반응형