如何让 IIS 加载 WCF 服务引用的本机 DLL?
我有一个 WCF 服务,其中包含一些 C# 代码,该代码引用了 C++/CLI dll,后者又引用了一些本机 DLL。我将所有必需的 DLL 包含在 IIS 应用程序的 bin 文件夹中,但是当 IIS 加载托管 DLL 时,它似乎将它们复制到深层目录,例如:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\testwcf\73473be6\e625098c\assembly\dl3\aada7c33\85a7332b_2f9acc01
它将每个托管 DLL 复制到其自己的目录并加载它。当它到达我的 C++/CLI DLL 时,它会将其复制到如上所述的目录,然后无法加载依赖项。如果我手动将所有本机 DLL 复制到此文件夹中,它将运行,但这不是一个很好的解决方案。
我的 web.config 是 VS 创建的常用配置,其端点是根据 MSDN 文章定义的。
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="WcfService.Service1">
<endpoint address=""
binding="wsHttpBinding"
contract="WcfService.IService1" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
我怎样才能让这些DLL自动被拾取呢?
I have a WCF service that contains some C# code, which references a C++/CLI dll, which references some native DLLs. I include all of the necessary DLLs in the bin folder for my IIS application, but when IIS loads the managed DLLs, it seems to be copying them to a deep directory like:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\testwcf\73473be6\e625098c\assembly\dl3\aada7c33\85a7332b_2f9acc01
It copies each managed DLL to its own directory and loads it. When it gets to my C++/CLI DLL, it copies it to a directory like above, and then it is unable to load the dependencies. If I manually copy all of the native DLLs into this folder, it will run, but that's not a great solution.
My web.config is the stock one created by VS, with an endpoint defined based on an MSDN article.
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="WcfService.Service1">
<endpoint address=""
binding="wsHttpBinding"
contract="WcfService.IService1" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
How can I get these DLLs to be picked up automatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自这篇文章,似乎本机 DLL 需要在某些目录或路径中可用:
提供的解决方案如下:
还有一些与#2 相关的更复杂的解决方案,其中涉及以编程方式更新 PATH。
From this post, it seems that the native DLLs need to be available in certain directories or on the path:
The solutions offered are as follows:
There are also some more complex solutions related to #2 which involve programmatically updating the PATH.