0

I currently have a .NET application which references "SomePackage.dll" and "SomeUtilities.dll". SomePackage.dll is contained in a separate folder, and one of the assemblies it depends on is also named "SomeUtilities.dll".

In other words, I added a reference in my project to \somePath\SomePackage.dll, and there exists a file \somePath\SomeUtilities.dll that SomePackage.dll depends on. Since I already have a reference in my project to a assembly called SomeUtilties.dll, I could not add a reference to \somePath\SomeUtilties.dll.

As a result, when I try to run my application and initialize a module in from SomePackage.dll, I receive an error:

Could not load file or assembly 'SomeUtilities.dll..." or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.' 

To work around this, I used gacutil in the VS developer command prompt to add \somePath\SomeUtilities.dll to the GAC. Now both assemblies are resolved fine, but I was wondering if there was a better way to resolve this name collision that doesn't involve adding to the GAC. I'm worried about potential issues that may arise with installing into the GAC, and have heard that .NET has the ability to look through certain subfolders to resolve assemblies, but am not sure where to find more on this concept.

steeb3776
  • 31
  • 5
  • 1
    You can ask .NET to look for DLLs in other folders. This is known as a "probing path." See [this question](https://stackoverflow.com/questions/21931312/probing-privatepath-and-subdirectories) – John Wu Oct 19 '22 at 23:19
  • Hello, is there any update in this issue? – Lei Zhang-MSFT Oct 25 '22 at 08:47

2 Answers2

0

You can use bind redirect.

Open the .config file to find the location of < assemblyBinding> enter image description here

Remove the < assemblyBinding> reference.

Type in Package Manager Console: Add-BindingRedirect.

Lei Zhang-MSFT
  • 280
  • 1
  • 5
-1

Windows/.NET has a tool called FUSLOGVW.exe that will help find issues with assemblies. This tool is useful but sifting through the logs is cumbersome. There is an open source tool that is a wrapper around FUSLOGVW.exe and makes it much easier to sift through the data and find the root of the problem. I would use this

https://github.com/awaescher/Fusion

Xss
  • 211
  • 1
  • 12