How to determine whether a DLL is a managed assembly or native (prevent loading a native dll)?

后端 未结 7 2116
失恋的感觉
失恋的感觉 2020-12-08 09:56

Original title: How can I prevent loading a native dll from a .NET app?

Background:

My C# application includes a plugin framework and gene

7条回答
  •  暖寄归人
    2020-12-08 10:45

    Using BadImageFormatException exception is a bad way to go, for ex. if your application targets .NET 3.5, it will not recognize let's say assemblies compiled against .NET Core, though the assembly is managed.

    So I think parsing PE header is much better.

提交回复
热议问题