私は自分のをホストしましRest WCF
たIIS 7
。私はすべてをテストしましたが、をインポートする以外は問題なく動作しdll
ます。私のインスタンスクラスコードは次のとおりです。
[OperationContract, WebInvoke(Method = "GET", UriTemplate = "/getname?name={name}&age={age}", ResponseFormat = WebMessageFormat.Json)]
bool getname(string name, string age);
[OperationContract, WebInvoke(Method = "GET", UriTemplate = "/getcallfromdll?name={name}&age={age}", ResponseFormat = WebMessageFormat.Json)]
bool getcallfromdll(string name, string age);
上記のメソッドの定義は次のとおりです。
public string getname(string name, int len)
{
return "It's working";
}
public string getcallfromdll(string name, int len)
{
return UnsafeNativeMethods.getvalue(name, len); //Unsafe.. is a internal structure
}
internal static class UnsafeNativeMethods
{
const string _dllLocation = "school.dll";
[DllImport(_dllLocation, CallingConvention = CallingConvention.Cdecl)]
public static extern bool getvalue(string name, String len);
}
実行しようとするとlocalhost:8085/service.svc/getname?name=kajn&len=21
:が返されます"It's working"
。これは正しいですが、呼び出そうとするとlocalhost:8085/service.svc/getcallfromdll?name=kajn&len=21
:が返されます。The server encountered an error processing the request. See server logs for more details.
私はそれを検索しました、そしてどういうわけか私はサービスのために起こっているすべてがを見つけるためにベールではないことを知りましたDLL
。これを解決するために、dllを次の場所に配置しようとしましたが、役に立ちませんでした:(:
- system32 / inetsrv
- SysWOW64 / inetsrv
- binフォルダに
- また、プロジェクトが存在するのと同じフォルダーを配置します。
しかし、私には何も機能しません。解決策を提案してください。
注:自己ホスト型のWCFアプリケーションからdllメソッドを呼び出し、完全に機能していたため、dllに問題はありません。その時、私は自分のdllをbin/debug
フォルダに入れました。