How to try and catch assembly not found

前端 未结 2 466
梦谈多话
梦谈多话 2021-01-02 06:00

OK, say I have an application like this:

using System;
using AliensExist; // some DLL which can\'t be found...

What I want is that if the

2条回答
  •  清酒与你
    2021-01-02 06:24

    You can't really do that in a try/catch, but what you can do is handle the AssemblyResolve event on the AppDomain.

    See http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx for further details.

    However, you will at least need to get your code compiling. If you are trying to "reference" an assembly which may or may not exist, you will need to dynamically load it and work from there.

提交回复
热议问题