如何在F#interactive中加载本机DLL?

时间:2017-09-01 20:24:04

标签: f# interop f#-interactive

尝试使用Microsoft.TeamFoundationServer.ExtendedClient nuget包时,出现以下错误:

System.DllNotFoundException: Unable to load DLL 'Microsoft.WITDataStore32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

这是因为程序包中包含的DLL之一是本机DLL,并且无法使用在F#interactive(#r "dllname.dll")中加载DLL的常规方法引用。

如何加载或帮助F#interactive查找本机DLL?

1 个答案:

答案 0 :(得分:4)

所有必要的是确保FSI进程在包含本机DLL的目录中查找DLL。您不需要直接引用它。

实现此目的的一种方法是将其添加到系统路径:

Environment.SetEnvironmentVariable("Path", Environment.GetEnvironmentVariable("Path") + ";" + __SOURCE_DIRECTORY__ + @"\..\packages\Microsoft.TeamFoundationServer.ExtendedClient.15.112.1\lib\native\x86\")

其他一些选项在以下位置解释:

http://christoph.ruegg.name/blog/loading-native-dlls-in-fsharp-interactive.html

相关问题