开发者

System.Reflection.Assembly.LoadFile failed (Advices?)

I work on inhouse tool for retrieving some information about my own managed dlls. For loading dlls I use System.Reflection.Assembly.LoadFile. With some of dlls I got exception:

"ClassName": "System.NullReferenceException"; "Message": "Object reference not set to 开发者_运维百科an instance of an object.";

But these dlls work well and they are loadable within applications. All dependences are in the same directory. Any advices?

Thank you very much!!!

P.S. Such exception happening with method System.Reflection.Assembly.LoadFrom;


LoadFile load the assembly for execution in the current AppDomain. (Some) static constructors can be executed and custom class Attributes are evaluated. In those cases, some of your code might be executed; thus the NullReferenceException may come from your code. The exception StackTrace will probably reveal the source.

Edit: If you want to obtain infos about an Assembly without executing its static constructors or evaluate attributes, you may look at Assembly.ReflectionOnlyLoad* methods.


Mmmm ... I'm not sure if this makes sense but maybe are they unmanaged DLLs or you lack the required file rights?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜