WCF-奇怪的错误

发布于 2024-11-27 05:18:20 字数 1255 浏览 0 评论 0原文

我的 dll 通过 wsHttpBinding 托管在 IIS 上。我中间发生了这个奇怪的错误。

好吧,当我重置 IIS (iisreset) 时,一切都会恢复正常。

我还读过这篇http://msdn.microsoft.com/en-us/库/ee517280.aspx。但我不确定这是否与此有关。如果您有更多相关信息,请指导我。谢谢。

“/MSBuildCompilation”应用程序中出现服务器错误。

未提供所需的模拟级别,或者 假设模拟级别无效。 (HRESULT 的异常: 0x80070542) 说明:在执行期间发生未处理的异常。 执行当前的网络请求。请检查堆栈跟踪 有关该错误及其起源的更多信息 代码。

异常详细信息:System.Runtime.InteropServices.COMException:任一 未提供所需的模拟级别,或者提供的 模拟级别无效。 (HRESULT 异常:0x80070542)

来源错误:

执行过程中产生了未处理的异常 当前的网络请求。有关原产地和地点的信息 可以使用下面的异常堆栈跟踪来识别异常。

堆栈跟踪:

[COMException (0x80070542): 所需的模拟级别为 未提供,或者提供的模拟级别无效。 (HRESULT 异常:0x80070542)]

[FileLoadException:无法加载文件或程序集 'System.ServiceModel,版本=4.0.0.0,文化=中性, PublicKeyToken=b77a5c561934e089' 或其依赖项之一。要么是 未提供所需的模拟级别,或提供的 模拟级别无效。 (HRESULT 异常:0x80070542)] System.ServiceModel.Activation.HttpModule.ProcessRequest(对象 发送者,EventArgs e) +0
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤, 布尔&同步完成)+75

I have my dll hosted at IIS with wsHttpBinding. I have this weird error happened intermediate.

Well, everything will be restored back normal again when I reset the IIS (iisreset).

I also read this one http://msdn.microsoft.com/en-us/library/ee517280.aspx. But I am not sure it has to do with this. Please guide me if you more info on this. Thanks.

Server Error in '/MSBuildCompilation' Application.

Either a required impersonation level was not provided, or the
provided impersonation level is invalid. (Exception from HRESULT:
0x80070542) Description: An unhandled exception occurred during the
execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.

Exception Details: System.Runtime.InteropServices.COMException: Either
a required impersonation level was not provided, or the provided
impersonation level is invalid. (Exception from HRESULT: 0x80070542)

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[COMException (0x80070542): Either a required impersonation level was
not provided, or the provided impersonation level is invalid.
(Exception from HRESULT: 0x80070542)]

[FileLoadException: Could not load file or assembly
'System.ServiceModel, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' or one of its dependencies. Either a
required impersonation level was not provided, or the provided
impersonation level is invalid. (Exception from HRESULT: 0x80070542)]
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object
sender, EventArgs e) +0
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +75

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

诗化ㄋ丶相逢 2024-12-04 05:18:20

看起来您正在尝试在 IIS6 中运行 .NET 4.0 Framework,这很棘手 根据这篇文章。 我自己还没有尝试过。您收到的异常实际上正在发生,因为您的进程尝试加载 System.ServiceModel 版本 4.0 DLL 失败。虽然这篇文章是针对 ASP.NET 的,但它也适用于 WCF,因为 ASP.NET 是 IIS6 中的服务主机进程。这是另一个同样的问题有一些很好的答案。

Looks like you are trying to run the .NET 4.0 Framework in IIS6 which be tricky according to this post. Haven't tried that myself. The exception you are getting is actually happening because your process is unsuccessfully trying to load the System.ServiceModel version 4.0 DLL. Although that post is for ASP.NET, it's applicable to WCF because ASP.NET is the service host process in IIS6. Here is another question along the same lines with some good answers.

帅的被狗咬 2024-12-04 05:18:20

(原发帖者回答,但在错误的地方,被我感动了。)

大家好,我终于通过在我的客户端应用程序代码中添加这两行来解决我自己的问题:

    WindowsClientCredential wsCred = wsFactory.Credentials.Windows;
    wsCred.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;

这两行强制客户端在每次连接时进行模拟。

(Answered by original poster but in wrong place, moved by me.)

Hi all, I finally solved my own problem by adding this 2 lines at my Client Application code:

    WindowsClientCredential wsCred = wsFactory.Credentials.Windows;
    wsCred.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;

This 2 lines to force client to impersonate every time when it connects.

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