Compile a version agnostic DLL in .NET

前端 未结 5 663
無奈伤痛
無奈伤痛 2020-12-05 01:14

Scenario

I have two wrappers around Microsoft Office, one for 2003 and one for 2007. Since having two versions of Microsoft Office running side by side is \"not of

5条回答
  •  一向
    一向 (楼主)
    2020-12-05 01:58

    Nice sleuthwork! I just threw together an implementation based on the concept presented above, and it works wonderfully:

    static Assembly domain_AssemblyResolve(object sender, ResolveEventArgs args)
    {
         string partialName = args.Name.Substring(0, args.Name.IndexOf(','));
         return Assembly.Load(new AssemblyName(partialName));
    }
    

    Of course there is room for enhancement, but this does the trick for me!

提交回复
热议问题