ライブラリ ネイティブ x86 C/C++ *.dll を、コンピューター (IIS7.5) でローカルにホストされているサービス WCF C# 4.0 に接続する必要があります。httpリクエスト(メソッド[WebGet])でサービスメソッドを呼び出しています。エラーが発生します:
http://s1.ipicture.ru/uploads/20120509/H8TVURsE.jpg
DllNotFoundException はユーザー コードによって処理されませんでした
DLL Li.dll を読み込めません: アクセスが拒否されました (HRESULT からの除外: 0x80070005 (E_ACCESSDENIED))
何が問題なのか教えてください。
コンソール アプリケーション C# でテストされたライブラリ Li.dll の効率 - 正常に動作しています。
Windows 7 x86 .NET 4.0 VS 2010 IIS7.5
構造ソリューション サービス WCF:
http://s1.ipicture.ru/uploads/20120430/vBXivN71.jpg
ソースコード
ネイティブ C/C++ x86 Li.dll:
Li.h
extern "C" {
__declspec(dllexport) int __cdecl SimulateGameDLL (int a, int b);
}
Li.cpp
#include "Li.h"
extern int __cdecl SimulateGameDLL (int num_games, int rand_in) {
return 121;
}
C#
WcfServiceLibrary1.IService1
[ServiceContract] public interface IService1{
[OperationContract][WebGet] string GetData();
}
WcfServiceLibrary1.Service1
public class Service1 : IService1{
public string GetData(){
ClassLibrary1.Class1 cl = new ClassLibrary1.Class1();
var rt = cl.M();
return string.Format("Value = : {0}", rt);
}
}
ClassLibrary1.Class1
public class Class1{
[DllImport("Li.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int SimulateGameDLL(int a, int b);
public int M() {
var r = SimulateGameDLL(10, 20);
return r;
}
}
強いテキスト