在Windows 7 x64上进行WCF调试

时间:2010-05-28 18:38:45

标签: visual-studio-2008 wcf .net-3.5

我使用Visual Studio 2008创建了一个非常简单的WCF沙箱项目,包括:

  • 控制台客户端应用程序
  • WCF服务库,在WcfSvcHost.exe中运行

我无法在Windows 7 x64系统上调试WCF服务。我得到一个弹出窗口说:

  

无法自动调试   'ServiceLibrary'。远程程序   无法调试。这通常   表示尚未进行调试   在服务器上启用。

该服务是Visual Studio 2008开箱即用的模板“IService1”。客户端直接调用GetData()操作,因此没有什么特别的。

我尝试了this question中的建议,这些建议没有引导我找到解决方案,但WCF跟踪日志包含一个特殊的例外:

<E2ETraceEvent>
<System>
<EventID>131075</EventID>
<Type>3</Type>
<SubType Name="Warning">0</SubType>
<Level>4</Level>
<TimeCreated SystemTime="2010-05-28T17:43:31.0190250Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{2f5e007a-d4d0-4046-9ab5-f6384b862a4f}" />
<Execution ProcessName="WcfSvcHost" ProcessID="6692" ThreadID="5" />
<Channel />
<Computer>SUBSPACE</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord Severity="Warning">
<Description>Throwing an exception.</Description>
<AppDomain>D:\PathTo\Service\bin\Debug\ServiceLibrary.dll.config</AppDomain>
<Exception>
<ExceptionType>System.ComponentModel.Win32Exception, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The specified domain either does not exist or could not be contacted</Message>
<StackTrace>
at System.ServiceModel.UpnEndpointIdentity.GetUpnFromDownlevelName(String downlevelName)
at System.ServiceModel.UpnEndpointIdentity.GetUpnFromWindowsIdentity(WindowsIdentity windowsIdentity)
at System.ServiceModel.UpnEndpointIdentity.EnsureIdentityClaim()
at System.ServiceModel.EndpointIdentity.get_IdentityClaim()
at System.ServiceModel.Security.SecurityUtils.GetSpnFromIdentity(EndpointIdentity identity, EndpointAddress target)
...
</StackTrace>
<ExceptionString>System.ComponentModel.Win32Exception: The specified domain either does not exist or could not be contacted</ExceptionString>
<NativeErrorCode>54B</NativeErrorCode>
</Exception>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>

(缩短了堆栈跟踪并删除了一些无趣的东西,full text here

它似乎在抱怨域名,但我的计算机不在任何域内。我在上面的XML中没有看到任何域名,但它确实有我的计算机名称(SUBSPACE)。任何人都知道是什么原因造成的?

客户端和服务都在其端点定义中有这个,尽管我已经尝试将其取出或将其更改为我的计算机名称:

<identity>
    <dns value="localhost" />
</identity>

当我使用 Debug - Start New Instance 单独启动它们时,服务和客户端是可调试的,但是我希望事情按照它们应该的那样工作......

1 个答案:

答案 0 :(得分:1)

消息

<ExceptionString>System.ComponentModel.Win32Exception: 
The specified domain either does not exist or could not be contacted</ExceptionString>

可能表示当您的计算机尝试解析“ \用户名”时出现问题,并且由于某种原因无法正确解析。

当您在工作组模式下运行时,它应该解析为您的本地计算机。从命令提示符尝试运行一个简单的:

ping %USERDOMAIN%

看看是否有效。它应该尝试ping您的本地IP。