WCF는 ServiceHost를 작성할 때 "System.ServiceModel"에 대한 filenotFound 예외를 던졌습니다.

StackOverflow https://stackoverflow.com/questions/934980

문제

나는 WCF와 함께 정말 이상한 문제를 겪고 있습니다. 솔루션에 2 개의 프로젝트가 있습니다. 각 프로젝트는 자체 주최 WCF 서비스를 시작합니다.

Project 1:

myService = new ServiceHost(typeof(MyService1));

잘 실행됩니다. 그러나 두 번째 프로젝트를 실행하려고 할 때 다음을 포함합니다.

meService = new ServiceHost(typeof(MyOtherService));

나는 예외를 얻는다 :

FileNotFoundException
Could not load file or assembly 'System.ServiceModel' or one of its dependencies.
The system cannot find the file specified.":"System.ServiceModel

퓨전 로그 :

=== Pre-bind state information ===
LOG: User = removed\removed
LOG: DisplayName = System.ServiceModel
 (Partial)
LOG: Appbase = file:///C:/Work/MySln/MyProj/bin/Dev
LOG: Initial PrivatePath = NULL
Calling assembly : System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Work\MySln\MyProj\bin\Dev\MyProj.dll.temp.config
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\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:/Work/MySln/MyProj/bin/Dev/System.ServiceModel.DLL.
LOG: Attempting download of new URL file:///C:/Work/MySln/MyProj/bin/Dev/System.ServiceModel/System.ServiceModel.DLL.
LOG: Attempting download of new URL file:///C:/Work/MySln/MyProj/bin/Dev/System.ServiceModel.EXE.
LOG: Attempting download of new URL file:///C:/Work/MySln/MyProj/bin/Dev/System.ServiceModel/System.ServiceModel.EXE.

정말 이상한 부분은 디버거 에서이 예외를 얻을 때 Visual Studio에서 'QuickWatch'로 가서 다음을 입력 할 수 있다는 것입니다.

new MyOtherService()  // returns new instance properly
new ServiceHost()     // returns new instance properly
new ServiceHost(typeof(MyOtherService))  // throws exception, same as above.

디버깅하는 동안 Sysinternals 파일 시스템 감시자를 실행하려고 시도했지만 devenv.exe 이외의 'FilenotFound'오류가 표시되지 않으며 .pdb 파일을 추적하여 스택 추적을 생성하려고합니다.

누구든지 무엇을 볼지에 대한 다른 아이디어가 있습니까?


업데이트 #1

프로세스에 대한 Fusion 로그를 확인했는데 이상한 일이 발생하는 것 같습니다. System.ServiceModel에는 2 개의 로그 항목이 있습니다.

*** Assembly Binder Log Entry  (6/1/2009 @ 10:26:48 AM) ***

The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from:  c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  C:\Program Files\TestDriven.NET 2.0\ProcessInvocation.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = removed\removed
LOG: DisplayName = System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 (Fully-specified)
LOG: Appbase = file:///C:/Work/MySln/PFWebIntgTests/bin/Dev
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = C:\Documents and Settings\removed\Local Settings\Temp\TestDrivenShadowCopy\633794488082894732
LOG: AppName = domain-nunit.addin.dll
Calling assembly : PFWebIntgTests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Work\MySln\PFWebIntgTests\bin\Dev\PFWebIntgTests.dll.temp.config
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll.
LOG: Assembly is loaded in default load context.

그런 다음 두 번째 항목 :

*** Assembly Binder Log Entry  (6/1/2009 @ 10:26:52 AM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  C:\Program Files\TestDriven.NET 2.0\ProcessInvocation.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = removed\removed
LOG: DisplayName = System.ServiceModel
 (Partial)
LOG: Appbase = file:///C:/Work/MySln/PFWebIntgTests/bin/Dev
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = C:\Documents and Settings\removed\Local Settings\Temp\TestDrivenShadowCopy\633794488082894732
LOG: AppName = domain-nunit.addin.dll
Calling assembly : System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Work\MySln\PFWebIntgTests\bin\Dev\PFWebIntgTests.dll.temp.config
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\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:/Work/MySln/PFWebIntgTests/bin/Dev/System.ServiceModel.DLL.
LOG: Attempting download of new URL file:///C:/Work/MySln/PFWebIntgTests/bin/Dev/System.ServiceModel/System.ServiceModel.DLL.
LOG: Attempting download of new URL file:///C:/Work/MySln/PFWebIntgTests/bin/Dev/System.ServiceModel.EXE.
LOG: Attempting download of new URL file:///C:/Work/MySln/PFWebIntgTests/bin/Dev/System.ServiceModel/System.ServiceModel.EXE.
LOG: All probing URLs attempted and failed.

그렇다면 System.servicemodel을 두 번, 그리고 GAC 대신 로컬 앱에서 한 번에서로드하려고하는 것 같습니다. 난 혼란스러워 ...

도움이 되었습니까?

해결책

내 문제를 찾았습니다.

두 프로젝트 모두 (myProj1 및 myProj2라고 부르겠습니다) .dll.config 파일 에이 줄이 있습니다.

<serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="System.ServiceModel.ServiceAuthorizationManager, System.ServiceModel" />

Proj1은 잘 실행되며 위의 예외로 Proj2가 실패합니다. Proj2에서만 어떤 이유로 든 "System.ServiceModel"을 해결하려고 할 때만 개인 bin 폴더에서만 보입니다.

위의 줄을 변경하면 전체 어셈블리 이름이 있습니다.

<serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="System.ServiceModel.ServiceAuthorizationManager, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

모든 것이 다시 작동합니다. 얼마나 이상한 ... 왜 정확히 동일한 구성 참조가 한 프로젝트에 효과가 있고 다른 프로젝트가 아닌지 모르겠지만 ... 적어도 지금은 다시 일할 수 있습니다 :)

다른 팁

몇 가지 질문 :

  • 두 프로젝트 모두 적어도 .NET 프레임 워크 3.0 이상을 대상으로합니까?
  • 두 서비스가 구현 한 인터페이스와 서비스 구현 클래스 자체의 대략적인 개요를 보여줄 수 있습니까?

두 번째 프로젝트에서 System.ServiceModel Assembly에 대한 참조를 삭제하고 다시 언급하려고합니다. 아마도 다른 개발자는 GAC 버전 대신 로컬 파일을 사용하여 지역 환경에서 문제를 일으켰을 것입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top