Pregunta

Me estoy quedando en un muy extraño problema con WCF. Tengo 2 proyectos en una solución, cada uno de ellos se pone en marcha algunos servicios WCF con alojamiento propio.

Proyecto 1:

myService = new ServiceHost(typeof(MyService1));

Lo que funciona muy bien. Sin embargo, cuando trato de ejecutar mi segundo proyecto, que contiene:

meService = new ServiceHost(typeof(MyOtherService));

Me da la excepción:

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

Fusión de registro:

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

La parte realmente extraño es que en el depurador, en el momento que llegue esta excepción, yo puedo entrar en 'Inspección rápida' en Visual Studio y escriba:

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

He intentado correr SysInternals File System Watcher durante la depuración, pero muestra errores no 'FileNotFound' distintos de devenv.exe tratando de localizar archivos .pdb para generar el seguimiento de la pila.

Alguien tiene alguna otra idea de lo que a la vista?


Actualización # 1

Fui a ver el registro de fusión para el proceso, y parece algo extraño sucede. Hay 2 entradas de registro para System.ServiceModel, espalda con espalda:

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

A continuación, una segunda entrada:

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

Así que parece que intenta cargar System.ServiceModel dos veces, y una vez de la dir aplicación local en lugar del GAC? Estoy confundido ...

¿Fue útil?

Solución

Encontrados mi problema:

Para ambos proyectos (permite llamar MyProj1 y MyProj2) tengo esta línea en el archivo .dll.config:

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

Proj1 funciona muy bien, Proj2 falla con la excepción anteriormente. Por alguna razón en Proj2 única, que sólo se ve en mi carpeta privada \ bin cuando se trata de resolver "System.ServiceModel".

Si cambio de la línea de arriba para tener el nombre de ensamblado completo:

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

Todo funciona de nuevo. Qué extraño ... no tengo ni idea de por qué exactamente las mismas obras de referencia de configuración de un proyecto y no otro, pero bueno ... al menos que pueda volver a trabajar ahora:)

Otros consejos

Un par de preguntas:

  • ambos de sus proyectos se dirigen a al menos NET Framework 3.0 o superior?
  • nos puede mostrar las interfaces que implementan los dos servicios, y el esbozo de las clases de implementación de servicios de sí mismos?

que iba a tratar de eliminar y volver a agregar la referencia en el segundo proyecto a la asamblea System.ServiceModel. Tal vez otro dev ha añadido que el uso de un archivo local en lugar de la versión GAC que causó problemas en su entorno local?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top