Tre*_*orm 19 c# .net-4.0 .net-assembly .net-2.0 dynamic-assemblies
我们有自定义DLL,它们不包含在我们的初始设置文件中.它们在运行时加载.这个过程在使用.NET 2.0时运行良好,但是我们现在正在使用.NET 4.0获得"动态程序集中不支持调用的成员"错误消息.
try
{
assem = Assembly.LoadFrom(fi.FullName); //fi is FileSystemInfo
}
catch (FileLoadException) {}
catch (BadImageFormatException) {}
catch (System.Security.SecurityException) {}
catch (ArgumentException) {}
catch (PathTooLongException) {}
Run Code Online (Sandbox Code Playgroud)
use*_*608 16
对我来说,这个问题并没有嵌入Aspose dll的许可证:http://www.aspose.com/community/forums/thread/423874/initializing-the-license-file.aspx
当未检测到许可证时,他们的代码会注入动态程序集,导致其DLL失败,以及一堆与动态程序集不兼容的其他代码.
不确定这是否是确保与第三方dll注册使用的通用许可/激活方法,因此如果是,我会在这里发布谷歌.
Gus*_*dor 15
发生此错误是因为Assembly.Load无法在动态程序集上调用.您必须在使用动态装配之前将其过滤掉.
var assemblies AppDomain.CurrentDomain.GetAssemblies().Where(p => !p.IsDynamic);
app.config 文件中的这一点允许来自远程源的“插件”dll。
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
http://msdn.microsoft.com/en-us/library/dd409252.aspx