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)
つまり、実際にファイルを見つけています。