从WCF服务应用程序调用的C ++ DLL在IIS 8中部署时无法正常工作?

时间:2016-09-14 12:12:44

标签: c# c++ wcf iis dll

我使用DLLImport调用C ++ DLL。代码位于从WCF服务应用程序调用的类库项目中。

 [DllImport(dllPath, SetLastError=true)]
 public static extern IntPtr CDSEngineConstructor();


 [DllImport(dllPath, SetLastError=true)]
 [return: MarshalAs(UnmanagedType.I1)]
 public static extern bool InitialiseDSEngine(StringBuilder pSB, IntPtr pDSEngine, StringBuilder pName, [MarshalAs(UnmanagedType.LPArray)] string[] ppListToLoad, UInt32 usiNumber);

我在成功调用dll的构造函数时获得了IntPtr。

IntPtr pEngine = CDSEngineConstructor();

我使用上面的值作为参数来调用dll中的另一个initialize方法。

if (!InitialiseDSEngine(sb, pEngine, sbReportingName, lstTyping.ToArray(), 10))
        throw new Exception("Failded to initilaise the search engine. please check the logs")

编辑:日志文件未创建!

当我在VS2008开发服务器中运行WCF时,上面的方法运行正常。但是在IIS 8中部署之后,上面的方法返回false,这意味着它无法初始化,我无法继续进行。

DLL是在x86中使用Release模式构建的。我的类库项目也使用相同的Active配置构建。

我还尝试在服务器中安装C ++可再发行组件2008。 IIS设置为运行32位应用程序。

我无法找到此行为的解决方案和原因。在未加载dll本身的情况下查询相同的返回结果。但在这种情况下,我能够正确加载dll。

如果我遗漏了任何信息,请告诉我。

0 个答案:

没有答案