System.Data.OracleClient 上的 WCF 模拟级别错误
我目前有一个在 IIS7 中运行的 WCF 服务,并且我已在每个公共 Web 方法上添加了模拟,其中包含以下内容:
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public void TestMethod(){}
每当我从测试客户端应用程序调用此方法时,都会收到以下错误:
无法加载文件或程序集“System.Data.OracleClient,Version=4.0.0.0,Culture=neutral,PublicKeyToken=waeraewrar”或其依赖项之一。未提供所需的模拟级别,或者提供的模拟级别无效。
我当前使用的是 Microsoft Enterprise Library 3.1 和 .Net 4.0。
示例代码:
WcfService client = new WcfService();
client.TestMethod();
I currently have a WCF service running in IIS7 and I have have added impersonation on each of the public web methods with the following:
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public void TestMethod(){}
When ever I call this method from my test client application I get the following error:
Could not load file or assembly 'System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=waeraewrar' or one of its dependencies. Either a required impersonation level was not provided, or the provided impersonation level is invalid.
I'm currently using Microsoft Enterprise Library 3.1, and .Net 4.0.
Sample code:
WcfService client = new WcfService();
client.TestMethod();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将客户端配置为允许模拟模拟级别。例如:
有关模拟和委派的详细信息,请参阅本文。
Try configuring the client to allow an impersonation level of impersonation. For example:
See this article for more on impersonation and delegation.
该错误消息表明问题在于模拟用户无权访问文件系统中的 System.Data.OracleClient 程序集 DLL,因此无法加载它。
您能否不导致
System.Data.OracleClient
程序集首先由需要模拟的服务方法之外的代码加载...即通过以 IIS 工作进程标识运行的代码。例如在您的服务实例构造函数中。一旦程序集被加载到服务的 AppDomain 中,在模拟下运行的服务方法就不需要再次这样做。
The error message suggests that the problem is that the impersonating user doesn't have access to the
System.Data.OracleClient
assembly DLL in the file system, and thus can't load it.Can you not cause the
System.Data.OracleClient
assembly to be first loaded by code outside the service methods requiring impersonation... i.e. by code running with the IIS worker process identity. For example in your service instance constructor.Once the assembly is loaded into the service's AppDomain, the service methods running under impersonation shouldn't need to do so again.