MiloszKrajewski/LibZ

AssemblyResolver ResolveEventArgs assembly name differing from injected assembly name.

Opened this issue · 1 comments

I am using inject-dll to inject a managed dll into a managed main dll.

The TaskBase.InjectDll method uses sourceAssembly.FullName to calculate the hash and Guid for the assembly. Later, when the AsmZResolver.AssemblyResolver event handler is run, the assembly name is taken from ResolveEventArgs.Name. The problem is that these two strings differ, and thus the Guid doesn't match.

The injected name looks like this: "MyAssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null".
The ResolveEventArgs.Name: "MyAssemblyName, Version=1.0.0.0, Culture=neutral".

What could be the cause of "PublicKeyToken=null" missing from ResolveEventArgs.Name?

Quick answer is: I don't know. If you can send me your app, or even better, replicate same problem with small demo app I could investigate.

Please note that "inject-dll" comes with a disclaimer: "Please note that this approach works for trivial applications only. If your application (or 3rd party libraries) use reflection, application domains, native DLLs you might need more "personalised" approach. Please refer to Scenarios."

Most of the problems people have is with this approach (which I actually added last-minute). See https://github.com/MiloszKrajewski/LibZ/blob/master/doc/scenarios.md adn use containers (scenario 4 seems like something you want).