c# - 在 C# 中从网络驱动器加载程序集 (dll)

标签 c# dll

我正在尝试从我的 C# exe 中的网络文件夹加载一个 dll。

System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFile(xPath + "\"+ t[0] + ".dll");

我收到以下错误 -

  RefusedSet=""
       Url=file://<network drive>/folder/raterType.dll
       StackTrace:
            at raterType.raterType.raterTypeCode(String a)
       InnerException: 

我必须做哪些程序集设置,才能完全信任我的 exe 中的 dll,以便它可以不受任何限制地加载它?

最佳答案

这是由于 CAS policy。您需要给予完全信任权限。

如果在那之后它仍然不起作用,请尝试先将文件加载到内存中(字节数组,使用 System.IO.File.ReadAllBytes()),然后使用 Assembly.Load() 重载从内存文件数据中加载程序集.

关于c# - 在 C# 中从网络驱动器加载程序集 (dll),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14044019/

相关文章:

c# - 引入 Visual Studio 2015 的问题

windows - dependency walker 如何知道模块中的哪些函数被使用了?

c++ - 在 Visual Studio 2017 中创建的简单 DLL 不会在 XP 中加载

visual-studio-2008 - 线程 'Win32 Thread'已退出,代码为-1073740777(0xc0000417)

C++ DLL - 打破循环依赖

javascript - GET 请求调用返回错误结果

c# - 如何使用没有主键的 SqlAdapter.Update 更新表

c# - 使用客户端功能创建复合控件

c# - .net标准类库-不支持分布式事务错误

Python Ctypes - 加载 dll 抛出 OSError : [WinError 193] %1 is not a valid Win32 application