【问题标题】:WCF PInvoke produces "Access is denied"WCF PInvoke 产生“访问被拒绝”
【发布时间】:2012-08-14 22:08:14
【问题描述】:

我有一个使用 webHttpEndpoint 端点实现 REST 接口的 WCF。

调用栈是这样的: WCF 服务 >> C# 库 >> PInvoke >> C++ 库

从 Visual Studio 运行时,一切都按预期工作。部署到 IIS 时会发生以下错误:

System.DllNotFoundException: Unable to load DLL 'native.dll': Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) at ...

所有 .dll 文件都在 \bin 文件夹中。

完全相同的 C# 库/PInvoke 链在同一服务器上的 Web 窗体 ASP.NET 站点中工作。

这是 WCF 服务的 web.config:

 <system.web>
   <trust level="Full"/>
   <compilation debug="true" targetFramework="4.0" />
   <customErrors mode="Off"/>
 </system.web>

 <system.webServer>
   <modules runAllManagedModulesForAllRequests="true">
     <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   </modules>
 </system.webServer>

 <system.serviceModel>
   <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
   <standardEndpoints>
     <webHttpEndpoint>
       <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
     </webHttpEndpoint>
   </standardEndpoints>
</system.serviceModel>

WCF 环境中是否有什么特别之处,或者是否需要特定权限才能找到/访问本机 dll?

其他信息 从 /bin 中删除 native.dll 会产生:

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

所以它实际上是在寻找文件。

【问题讨论】:

    标签: c# wcf iis pinvoke


    【解决方案1】:

    原来这是文件的简单权限问题的结果。

    【讨论】:

    • 我不会将此归类为答案,因为它缺乏可以帮助他人的细节。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-19
    • 2019-08-30
    • 1970-01-01
    • 1970-01-01
    • 2020-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多