Bertvan
Bertvan

Reputation: 5033

Debug .NET assembly binding aka Find what dll is used and why

We're having some mystery version mismatches on our referenced dll's loaded at runtime.

Errors like:

Could not load file or assembly X or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Is there any way to debug the assembly binding.

In other words, how can I know the following details about loaded assemblies:

Upvotes: 3

Views: 3693

Answers (2)

Volodymyr Usarskyy
Volodymyr Usarskyy

Reputation: 1287

Totally agree with Chris, Assembly Binding Log Viewer should give you all information you need. In addition you could also use WinDbg + SOS.dll. Mostly it's used for debugging but can be quite useful in some other cases when you need to know as much information as possible. The only problem that could stop you is that it doesn't have nice UI like VS debugger :)

Good luck!

Upvotes: 2

Chris Schmich
Chris Schmich

Reputation: 29476

The Assembly Binding Log Viewer (aka Fusion Log Viewer, fuslogvw.exe) shows useful data for these sorts of issues such as:

  • What process is trying to load an assembly
  • The full name of the assembly (version, culture, public key token)
  • The assembly that's causing the load
  • Which paths were probed for the assembly

You can log all binds or just bind failures.

fuslogvw.exe should be accessible directly from any VS command prompt.

Upvotes: 6

Related Questions