Azure: Could not load file or assembly 'Microsoft.ServiceBus

心不动则不痛 提交于 2019-12-04 03:32:48

问题


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

  1. Make sure your reference to the assembly specifies COPY LOCAL
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!