WCF – 奇怪的错误

我在IIS上使用wsHttpBinding托管了我的dll.我有这个奇怪的错误发生在中间.

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

我也读了这个http://msdn.microsoft.com/en-us/library/ee517280.aspx.但我不确定它与此有关.如果您有关于此的更多信息,请指导我.谢谢.

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

最佳答案 看起来你正试图在IIS6中运行.NET 4.0 Framework,这很棘手
according to this post.我自己没试过.您获得的异常实际上是因为您的进程尝试加载System.ServiceModel版本4.0 DLL失败.虽然该帖子适用于ASP.NET,但它适用于WCF,因为ASP.NET是IIS6中的服务主机进程.这是另一个
question along the same lines,有一些很好的答案.

点赞