加载插件 DLL 文件时,“动态程序集中不支持被调用的成员". [英] Loading plug-in DLL files, "The invoked member is not supported in a dynamic assembly."

查看:33
本文介绍了加载插件 DLL 文件时,“动态程序集中不支持被调用的成员".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的初始设置文件中未包含自定义 DLL.它们在运行时加载.此过程在使用 .NET 2.0 时运行良好,但由于我们使用 .NET 4.0,我们收到动态程序集中不支持调用的成员"错误消息.

We have custom DLL's that are not included in our initial setup file. They are loaded at runtime. This process worked fine while using .NET 2.0, but we are getting the "The invoked member is not supported in a dynamic assembly" error message now that we are using .NET 4.0.

try
{
    assem = Assembly.LoadFrom(fi.FullName); //fi is FileSystemInfo
}
catch (FileLoadException) {}
catch (BadImageFormatException) {}
catch (System.Security.SecurityException) {}
catch (ArgumentException) {}
catch (PathTooLongException) {}

推荐答案

发生此错误是因为无法在动态程序集上调用 Assembly.Load.您必须先过滤掉动态程序集,然后才能使用它们.

This error is occurring because Assembly.Load cannot be called upon dynamic assemblies. You must filter out the dynamic assemblies before using them.

var assembly = AppDomain.CurrentDomain.GetAssemblies().Where(p => !p.IsDynamic);

这篇关于加载插件 DLL 文件时,“动态程序集中不支持被调用的成员".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆