Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

c# - Could not load file or assembly 'Microsoft.Azure.Management.ServiceBus.Fluent'

I am working on Azure service bus from my console application. I have a separate project and I have installed the nuGet package "Microsoft.Azure.Management.ServiceBus.Fluent" package to get connection string using namespace. After installing the package and running the application, I get this exception:

System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Azure.Management.ServiceBus.Fluent, Version=1.0.0.66, Culture=neutral or one of its dependencies. The system cannot find the file specified.'

How do I resolve it? Please leave it in the comments if I can add any other details.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

First of all, I assume you have installed Microsoft.Azure.Management.ServiceBus.Fluent version 1.36.0.

If your project is net framework with packages.config nuget package format, you could try these:

To correct the path, you should clean nuget caches first(delete all files under C:Usersxxx.nugetpackages) and packages folder under the solution folder

then run the below command to correct the path:

update-package -reinstall

under Tools-->Nuget Package Manager-->Package Manager Console.

Also, you could just modify the csproj file and change the hintpath of the nuget package reference to the right nuget dll path.

<Reference Include="Microsoft.Azure.Management.ServiceBus.Fluent, Version=1.0.0.66, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..packagesMicrosoft.Azure.Management.ServiceBus.Fluent.1.36.0lib
et452Microsoft.Azure.Management.ServiceBus.Fluent.dll</HintPath>
</Reference>

Besides, add bindingRedirect might be a safe choice.

Add this under app.config file

 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Azure.Management.ServiceBus.Fluent" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.66" newVersion="1.0.0.66" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

=========================================================

If your project is net core project with PackageRefence nuget management format,

you should also clean nuget caches first and then delete bin and obj folder.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...