5

I know that it is possible, registering to the AppDomain.AssemblyResolve event, to handle the attempt to load an assembly when the automatic CLR search has failed.

In my current project, It would be helpful to handle all the assembly loading through such a mechanism; is there a way to do it?

An (ugly) workaround would be to move the executable in a separate directory and let everything be handled by the AssemblyResolve delegate; I hope there's a cleaner solution out there.

Regards, Andrea

Andrea
  • 884
  • 1
  • 10
  • 23
  • This can be done through the debugger and profiler interfaces. Whether that's suitable is completely unguessable from your question. The *why* is important. – Hans Passant Jun 11 '11 at 19:05
  • I am loading assemblies with Assembly.Load(byte[]). This works fine, but it happens that the same assembly I just loaded is referenced by another assemly and loaded twice into the AppDomain. I think that my best option to avoid that is to gain more control over the loading dynamics. – Andrea Jun 11 '11 at 19:15
  • 2
    Well, that's not possible unless the one you load with Assembly.Load(byte[]) is also available on disk. Move it to a subdirectory so the CLR cannot find it. Use fuslogvw.exe to troubleshoot assembly resolution problems. – Hans Passant Jun 11 '11 at 19:37

0 Answers0