Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 C# 项目,其中包含从解决方案中的另一个项目引用 win32 dll 的存储过程。目前,dllimport 使用绝对路径来引用它。如果我改用相对路径,那么一旦将 clr 存储的 procs 程序集加载到 sql server 中,该路径相对于哪里?
好问题,因为 DLL 在物理上不可用。我的猜测是它将查看主机所在的位置(例如 SQL 服务器二进制文件)。但是我会尝试在带有测试实例的机器上使用 Process Monitor 或类似工具进行查找;SQL Server 将尝试查找该文件,这应该在进程监视器日志中可见。
也就是说,如果需要,您还可以使用系统 LoadLibrary 和 GetProcAddress 调用并将委托绑定到您使用 Marshal 类返回的地址,因为这允许您对计算的 DLL 路径执行适当的后期绑定。