Ich bin auf ein wirklich seltsames Problem mit WCF. Ich habe 2 Projekte in einer Lösung, jede von ihnen startet einige selbst gehostete WCF-Dienste.WCF löst FileNotFound-Ausnahme für "System.ServiceModel" beim Erstellen von ServiceHost
Projekt 1:
myService = new ServiceHost(typeof(MyService1));
Welche fein läuft. Allerdings, wenn ich versuche, mein zweites Projekt auszuführen, die enthält:
meService = new ServiceHost(typeof(MyOtherService));
Ich bekomme 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 in der Debugger, zu der Zeit, dass ich diese Ausnahme bekomme, kann ich in 'QuickWatch' 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.
Ich habe versucht, SysInternals File System Watcher während des Debuggen, aber es zeigt keine 'FileNotFound' Fehler anders als devenv.exe versucht,. Pdb-Dateien zu verfolgen, um den Stack-Trace zu generieren.
Hat jemand andere Ideen, was zu sehen?
Update # 1
checkte ich für den Prozess des Fusionsprotokoll 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 von der lokale App dir anstelle des GAC? Ich bin verwirrt ...
Beide zielen auf .net 3.5. Seltsamerweise kann ich im "kaputten" Projekt "MyOtherService" durch irgendeine Service-Schnittstelle ersetzen, und sie alle werfen den gleichen Fehler, was zu der Annahme führt, dass etwas im Projekt selbst falsch ist. Siehe meine oben hinzugefügte Forschung für die Fusionsprotokolle. – CodingWithSpike
Könnte es sein, dass Sie versehentlich eine Kopie von System.ServiceModel.dll in Ihrem Apps bin-Verzeichnis irgendwo bekommen haben ?? Ich hatte das manchmal zufällig, dass ich 2.0 32-Bit-Kopien von System.Data im bin-Verzeichnis meiner Website bekam und nicht mehr auf meinem 64-Bit-Rechner bauen konnte. –
Eigentlich ist das Gegenteil der Fall. Wenn ich System.ServiceModel.dll vom GAC in meinen \ bin Pfad kopiere, läuft es jetzt gut. Aus irgendeinem Grund versucht .NET, es von \ bin zu lösen. Siehe Fusionsprotokoll oben (Richtlinie wird derzeit nicht auf Referenz angewendet). – CodingWithSpike