System.Data.OracleClient 上的 WCF 模拟级别错误

发布于 2024-10-05 02:18:02 字数 533 浏览 5 评论 0原文

我目前有一个在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青朷 2024-10-12 02:18:02

尝试将客户端配置为允许模拟模拟级别。例如:

<system.serviceModel>
    <client>
      <endpoint address="http://xxxxx/Services/xxService.svc"
                binding="wsHttpBinding"
                contract="IServiceContract"
                behaviorConfiguration = "ImpersonationBehavior" />
    </client>
      <behaviors>
          <endpointBehaviors>
               <behavior name="ImpersonationBehavior">
                   <clientCredentials>
                       <windows allowedImpersonationLevel = "Impersonation" />
                   </clientCredentials>
               </behavior>
          <endpointBehaviors>
       </behaviors>
</system.serviceModel>

有关模拟和委派的详细信息,请参阅本文

Try configuring the client to allow an impersonation level of impersonation. For example:

<system.serviceModel>
    <client>
      <endpoint address="http://xxxxx/Services/xxService.svc"
                binding="wsHttpBinding"
                contract="IServiceContract"
                behaviorConfiguration = "ImpersonationBehavior" />
    </client>
      <behaviors>
          <endpointBehaviors>
               <behavior name="ImpersonationBehavior">
                   <clientCredentials>
                       <windows allowedImpersonationLevel = "Impersonation" />
                   </clientCredentials>
               </behavior>
          <endpointBehaviors>
       </behaviors>
</system.serviceModel>

See this article for more on impersonation and delegation.

云朵有点甜 2024-10-12 02:18:02

该错误消息表明问题在于模拟用户无权访问文件系统中的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文