Frage

Ich laufe in ein wirklich seltsames Problem mit WCF. Ich habe 2 Projekte in einer Lösung, jeder von ihnen beginnt einige selbst gehosteten WCF-Dienste auf.

Projekt 1:

myService = new ServiceHost(typeof(MyService1));

Welche läuft gut. Allerdings, wenn ich versuche, mein zweites Projekt auszuführen, die enthält:

meService = new ServiceHost(typeof(MyOtherService));

Ich erhalte die Ausnahme:

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

Fusion Log:

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

Die wirklich seltsam ist, dass zu der Zeit im Debugger, dass ich diese Ausnahme, ich in ‚Schnellüberwachung‘ in Visual Studio gehen und geben Sie ein:

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

habe ich versucht, SysInternals File System Watcher beim Debuggen ausgeführt wird, aber es zeigt keinen ‚FileNotFound‘ Fehler anders als devenv.exe versuchen, PDB-Dateien aufzuspüren, um den Stack-Trace zu erzeugen.

Wer irgendwelche andere Ideen, was zu sehen?


Update # 1

überprüfte ich das Fusionsprotokoll für den Prozess aus, und es scheint, geschieht etwas Seltsames. Es gibt 2 Protokolleinträge für System.ServiceModel, Rücken an Rücken:

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

Dann wird ein zweiter Eintrag:

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

So scheint es, dass es versucht, System.ServiceModel zweimal zu laden, und einmal aus dem lokalen App dir anstelle des GAC? Ich bin verwirrt ...

War es hilfreich?

Lösung

Gefunden Mein Problem:

Für beiden Projekte (läßt sie MyProj1 und MyProj2 nennen) Ich habe diese Zeile in der .dll.config-Datei:

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

Proj1 läuft gut, Proj2 schlägt mit der Ausnahme oben. nur aus irgendeinem Grunde in Proj2, sieht es nur in meinem privaten Ordner \ sind, wenn sie versucht „System.ServiceModel“ zu lösen.

Wenn ich die obige Zeile ändern, um die vollständige Montage Namen haben:

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

Alles funktioniert wieder. Wie seltsam ... Ich habe keine Ahnung, warum die exakt gleichen Konfiguration Nachschlagewerken für ein Projekt und nicht eine andere, aber hey ... zumindest kann ich wieder an die Arbeit:)

Andere Tipps

Ein paar Fragen:

  • Sie Ihre beiden Projekte zumindest Ziel .NET Framework 3.0 oder höher?
  • Sie können uns zeigen, die Schnittstellen, die die beiden Dienste implementieren, und die groben Überblick über die Service-Implementierungsklassen selbst?

würde ich versuchen, zu löschen und erneut hinzufügen die Referenz im zweiten Projekt auf die System.ServiceModel Montag. Vielleicht hat ein anderer Entwickler es mit einer lokalen Datei anstelle der GAC-Version hinzugefügt, die auf Ihrer lokalen Umgebung verursacht Probleme?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top