问题
I have a app fabric service that I want to test. (http://xxx.cloudapp.net:8081/service.svc).
I created a console app and added a service reference to the service and got the following error:
Could not load file or assembly 'Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I added a reference to Microsoft.ServiceBus from C:\Program Files (x86)\Windows Azure platform AppFabric SDK\V1.0\Assemblies\NET4.0
I set all assemblies in my project to Copy Local = True, as suggested here: http://msdn.microsoft.com/en-us/library/ee706702.aspx
Additional Due diligence: I opened Microsoft.ServiceBus in red-gate's reflector and confirmed that it is the correct version. Just for kicks, I also added references to each assembly referenced in reflector and set all references to copy local = true.
Any other ideas?
…Peter
回答1:
When you reference Microsoft.ServiceBus.dll, reference it from the install location, e.g.,
C:\Program Files (x86)\Windows Azure platform AppFabric
SDK\V1.0\Assemblies\NET4.0\Microsoft.ServiceBus.dll
... not from the GAC, and set Copy Local to true.
You need to do this in whatever you are deploying into Azure; the Microsoft.ServiceBus.dll needs to packaged with your project because it is not available by default in Azure.
If you fire up Fiddler, you see a 500 error when calling the service. This proves that the exception isn't in your calling application.
回答2:
Make sure you change the Target Framework (Project properties/Application tab) from '.NET Framework 4 Client Profile' to '.NET Framework 4'. I found a similar post and that was what helped me. I believe it has to with the fact that Microsoft.ServiceBus is not supported by the client profile of .NET 4.
回答3:
ServiceBus dll is not installed on Azure boxes
- Make sure your reference to the assembly specifies COPY LOCAL
- Also make sure you don’t have references to the service bus dll in upper projects which do NOT copy local (this might be your problem if you have verified 1 above)
You can check the CSX tree for your azure build folder to see if the assembly is being copied into the final package. That’s a lot quicker than uploading to azure or starting the dev fabric.
That should solve your problem
来源:https://stackoverflow.com/questions/3859333/azure-could-not-load-file-or-assembly-microsoft-servicebus