开发者

Load multiple versions of the same dll without putting it in the GAC

I would like to load two different versions of the same dll within the same process. At the same time I would like t开发者_如何学Pythono avoid placing any of them in the GAC.

Any ideas?

Thanks, Krikor


Yes, it seems like i have to manually load the assembly, one way or another.

One solution that i found was to subscribe to the AssemblyResolve event of the appDomain. This event is raised when an assembly is not found and allows you to manually provide it.

  1. Reregister an event handler like this

AppDomain.CurrentDomain.AssemblyResolve += MyResolveEventHandler;

static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) { return Assembly.LoadFrom(@"OldAsm\Asm.dll"); }

  1. Once the code that uses the specific code is reached the .NET Framework will try to load the assembly, it will crash and will call your handler (MyResolveEventHandler).

I would keep looking for a way to resolve the right reference without having to write any code and without having to put anything in the GAC. If anyone finds a way, please post it.

Thanks


Activator.CreateInstance. Check msdn for examples.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜