我的问题首先是将.Net 2.0应用程序迁移到.Net 4.0。我不得不这样做的原因是,默认情况下,Windows8不启用早期的.Net版本,而且我的应用程序不能要求用户启用它。
该应用程序是一个NPAPI插件,它通过.Net使用UnmanagedExports组件。我把它设计成一个低完整性的应用程序,因此它必须驻留在用户的LocalLow目录中。
在我的应用程序中,我使用动态程序集加载机制在运行时加载多个程序集。我使用以下方法加载程序集,
MyInterface Instance;
Assembly assembly = Assembly.LoadFrom(AssemblyFile);
Type type = assembly.GetType(Identifier); // Identifier is implementing the MyInterface
Instance = Activator.CreateInstance(type) as MyInterface;
// Do something with the Instance在将项目修改为.Net 4.0之后,我注意到当二进制文件放在LocalLow目录中时,插件就会崩溃(它在其他地方工作)。我的下一步是用最少的代码创建一个极简的插件来解决这个问题。我注意到,除以下异常外,动态程序集加载失败,
System.IO.FileLoadException: Could not load file or assembly '<assemblyPath>' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515 (COR_E_NOTSUPPORTED)) --->
System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=131738 for more information.我尝试了以下方法来创建单独的域并加载程序集,但没有成功,
添加配置'loadFromRemoteSources‘也不起作用。.Net组件似乎没有加载.dll.config文件。(可能是因为UnmanagedExporting)
我的问题是,
发布于 2013-10-29 21:36:11
虽然它没有具体解决您的LocalLow问题,但是如果您能够从目录中“读取一个文件”,您可能可以使用这里详细介绍的“工作”:How can I get LabView to stop locking my .NET DLL?
https://stackoverflow.com/questions/19656738
复制相似问题