标签: dynamic-dll-import

C# - 动态加载 DLL - System.Reflection.ReflectionTypeLoadException:无法加载一种或多种请求的类型

在 C# 中,当尝试获取类型时,使用下面的代码从文件夹加载 DLL,获取下面的堆栈跟踪。

var assembly = Assembly.LoadFile(assemblyInfo.FullName); // assembly loads perfectly using the absolute path.
var types = assembly.GetTypes(); // this line throws the below stacktrace.
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.Assembly.GetTypes()
Run Code Online (Sandbox Code Playgroud)

我还检查了现有的解决方案:错误消息“无法加载一种或多种请求的类型”。检索 LoaderExceptions 属性以获取更多信息。,在 C# 中运行时加载 DLL(不起作用)

c# dll dllimport dll-injection dynamic-dll-import

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

dll ×1

dll-injection ×1

dllimport ×1

dynamic-dll-import ×1