I am using the Azure.Storage.Queues
nuget package and it came with assemblyBinding; which I didn’t realise was a thing.
I was initially using this package to build a .netstandard2.0 class library, and using CopyLocalLockFileAssemblies
to publish all assemblies referenced by my project.
With this code:
Azure.Storage.Queues.QueueClient.SendMessageAsync("someMessage",default);
I kept getting this error
Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
Visual Studio shows that the Azure.Storage.Queues
package is using System.Buffer - 4.5.1
nuget package which contains the System.Buffer.dll, v4.0.3.0
assembly but when the code is executed, it tries to find the System.Buffer.dll, v4.0.2.0
; as shown in the error.
This was impossible to figure this out when I was working on the class library project, I only realised that there are bindings involved with this package when I imported this package to a console app at which point it updated the App.config
file.
Also the ref folder in the System.Buffer 4.5.1
nuget package contains the System.Buffer.dll, v4.0.2.0
version of the assembly and the lib folder in the package System.Buffer.dll, v4.0.3.0
.
Can someone please help me understand
- if there is anything in a Nuget package that can tell me if it needs any assemblyBinding.
- why does the
Azure.Storage.Queues.QueueClient.SendMessageAsync
method trying to use theSystem.Buffer.dll, v4.0.2.0
version of the lib?
Regarding your first question, programmatically you can use reflection to determine the referenced assemblies via System.Reflection.Assembly.GetReferencedAssemblies().
If you want to analyze it with graphical tools, I recommend JetBrains dotPeek which shows you content and references of assemblies very easy (as most people I know have JetBrains Resharper Ultimate already installed alongside their IDE).