开发者

WCF - weird error

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


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.


(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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜