I've got a Visual Studio 2008 solution with a WCF service, and a client.
我有一个带有WCF服务和客户端的Visual Studio 2008解决方案。
When I run my client, and call a method from my service I get a message saying "Unable to automatically debug 'Home.Service'. The remote procedure could not be debugged. This usually indicates that debugging has not been enabled on the server."
当我运行我的客户端,并从我的服务调用一个方法时,我收到一条消息“无法自动调试'Home.Service'。远程过程无法调试。这通常表示尚未在服务器上启用调试。 “
I've googled around, and have tried the following.
我用Google搜索过,并试过以下内容。
<system.web>
<compilation debug="true" />
</system.web>
has been added in app.config on both the client and the server.
已在客户端和服务器上的app.config中添加。
I have also made sure that the project is being compiled in Debug mode.
我还确保在调试模式下编译项目。
What else could be causing this message?
还有什么可能导致此消息?
Edit: Added more info based on feedback questions
编辑:根据反馈问题添加更多信息
- It is using wsHttpBinding
-
I have set
我已经设定
<serviceDebug includeExceptionDetailInFaults="true"/>
-
I am using
我在用
var service = new HomeReference.HomeServiceClient(); service.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
它使用wsHttpBinding
Unfortunately the error shows up the first time I call a method on my Service. I can dismiss the messagebox, and the application continues working. Any Exceptions thrown on the server at not propagated back to the client though (I assume it should?)
不幸的是,第一次在我的服务上调用方法时出现错误。我可以关闭消息框,应用程序继续工作。服务器上抛出的任何异常都没有传播回客户端(我认为它应该?)
11 个解决方案
#1
13
In my case the problem turned out to be a mismatch between security settings on client and server. I was using a custom binding like this:
在我的情况下,问题结果是客户端和服务器上的安全设置不匹配。我正在使用这样的自定义绑定:
<customBinding>
<binding name="AuthorisedBinaryHttpsBinding" receiveTimeout="00:03:00" sendTimeout="00:03:00">
<!-- this next element caused the problem: -->
<security authenticationMode="UserNameOverTransport">
</security>
<binaryMessageEncoding>
<readerQuotas maxDepth="100" maxStringContentLength="1000000"
maxArrayLength="655360000" />
</binaryMessageEncoding>
<httpsTransport />
</binding>
</customBinding>
When I removed the security element that I've highlighted above the problem with the "Unable to automatically debug" message went away.
当我删除上面突出显示的安全元素时,“无法自动调试”消息的问题就消失了。
To solve the problem I first turned on WCF tracing. This showed me that WCF was throwing a MessageSecurityException:
为了解决这个问题,我首先启用了WCF跟踪。这告诉我WCF正在抛出MessageSecurityException:
Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. This can occur if the service is configured for security and the client is not using security.
安全处理器无法在消息中找到安全标头。这可能是因为消息是不安全的故障,或者因为通信方之间存在绑定不匹配。如果为安全性配置服务并且客户端未使用安全性,则会发生这种情况。
That pointed me to look at the Binding settings on the client side. It turned out that I hadn't added the required security element to my custom binding there. Since I was doing this through code, I needed the following (note the 3rd line):
这指向我查看客户端的绑定设置。原来,我没有在我的自定义绑定中添加所需的安全元素。由于我是通过代码执行此操作,因此我需要以下内容(请注意第3行):
var binding = new CustomBinding(
binaryEncoding,
SecurityBindingElement.CreateUserNameOverTransportBindingElement(),
new HttpsTransportBindingElement { MaxReceivedMessageSize = MaxMessageSize, });
As to why Visual Studio was showing that error, I've no idea - looks to me to be a bug.
至于为什么Visual Studio显示错误,我不知道 - 看起来我是一个错误。
#2
39
I was fighting with this exact same error for over an hour and low and behold I restarted VS2008 and it magically fixed itself. Give it a try as it might save you some time.
我正在与这个完全相同的错误战斗超过一个小时,并且看到我重新启动VS2008并且它神奇地修复了自己。试一试,因为它可能会节省你一些时间。
#3
8
Automatically attaching to a service has the following limitations:
自动附加到服务具有以下限制:
-
The service must be part of the Visual Studio solution you are debugging.
该服务必须是您正在调试的Visual Studio解决方案的一部分。
-
The service must be hosted. It may be part of a Web Site Project (File System and HTTP), Web Application Project (File System and HTTP), or WCF Service Library project. WCF Service Library projects can be either Service Libraries or Workflow Service Libraries.
该服务必须托管。它可能是网站项目(文件系统和HTTP),Web应用程序项目(文件系统和HTTP)或WCF服务库项目的一部分。 WCF服务库项目可以是服务库或工作流服务库。
-
The service must be invoked from a WCF client.
必须从WCF客户端调用该服务。
-
Debugging must be enabled with the following code in the app.config or Web.config file:
必须使用app.config或Web.config文件中的以下代码启用调试:
<system.web> <compilation debug="true" /> </system.web>
See Limitations on WCF Debugging
请参阅WCF调试的限制
In addition, if both projects (client and service) are in the same solution but will run in different processes (for example if you are using your local IIS Server for development and are running your web application on a different application pool than the service it consumes), you may need to enable "Multiple startup projects" for the solution (on Solution Properties -> Startup Project) so that the debugger can attach to both.
此外,如果两个项目(客户端和服务)都在同一个解决方案中,但将在不同的进程中运行(例如,如果您使用本地IIS服务器进行开发,并且在不同的应用程序池上运行Web应用程序而不是服务它消耗),您可能需要为解决方案启用“多个启动项目”(在解决方案属性 - >启动项目上),以便调试器可以附加到两者。
To avoid the service browser window to show up every time you debug, you may set the "Start Action" (on service project properties) to "Don't open a page. Wait for request from external application."
为避免每次调试时都显示服务浏览器窗口,您可以将“开始操作”(在服务项目属性上)设置为“不要打开页面。等待来自外部应用程序的请求”。
This is from personal experience and may help others.
这来自个人经验,可能会帮助他人。
#4
6
The other reason you might see this error (and I believe is the case for me) is if you're running in 64bit Windows. Apparently Visual Studio doesn't have any x64 debugger support.
你可能会看到这个错误的另一个原因(我相信是我的情况)是你在64位Windows上运行。显然,Visual Studio没有任何x64调试器支持。
You can work around this by changing the Platform Target for the consuming application:
您可以通过更改使用应用程序的平台目标来解决此问题:
Project Properties -> Build -> Change "Platform Target" to "x86".
项目属性 - >构建 - >将“平台目标”更改为“x86”。
Unfortunately this won't work for me as I'm trying to run in the Windows Azure Development AppFabric which seems to require everything to run in 64bit mode!
不幸的是,这对我来说不起作用,因为我试图在Windows Azure开发AppFabric中运行,这似乎要求一切都以64位模式运行!
#5
1
I also got the same problem. I changed in both client & service config files like
我也遇到了同样的问题。我更改了客户端和服务配置文件,如
Compilation debug is set to true.
编译调试设置为true。
This worked for me.
这对我有用。
#6
0
Have you tried
你有没有尝试过
<serviceBehaviors>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
For debugging purposes?
出于调试目的?
Edit : nevermind, I think I misunderstood the question
编辑:没关系,我想我误解了这个问题
#7
0
I've had a similar problem and it turns out to have been due to Windows Authentication not being enabled on the IIS site/virtual directory.
我遇到了类似的问题,结果是由于IIS身份验证/虚拟目录上没有启用Windows身份验证。
Have you tried setting the authentication mode to Integrated instead of Anonymous? http://msdn.microsoft.com/en-us/library/x8a5axew(VS.80).aspx
您是否尝试将身份验证模式设置为“集成”而不是“匿名”? http://msdn.microsoft.com/en-us/library/x8a5axew(VS.80).aspx
#8
0
In your web service web.config ensure that compilation debug is set to true. That should fix your problem!
在Web服务web.config中,确保将编译调试设置为true。这应该可以解决你的问题!
#9
0
In my case the problem turned out to be something completely different. I had changed the name of an operation on the webservice and forgot to update the client. For some reason this resulted in the "Unable to automatically debug ..." error.
在我的情况下,问题变成了完全不同的东西。我更改了webservice上的操作名称,忘记更新客户端。由于某种原因,这导致“无法自动调试...”错误。
#10
0
It can also be that the same port number is used in IISExpress and IIS. If you are developing a WCF application in Visual Studio and IISExpress and then install the same application on your local IIS make sure not to use the same port number in IIS and IISExpress. Using the same port number will lead to this error message.
它也可以是IISExpress和IIS中使用相同的端口号。如果您在Visual Studio和IISExpress中开发WCF应用程序,然后在本地IIS上安装相同的应用程序,请确保不要在IIS和IISExpress中使用相同的端口号。使用相同的端口号将导致此错误消息。
#11
-1
Add this line of code after you create your service reference in your client.
在客户端中创建服务引用后添加此行代码。
MyWCFService.IService _proxy = new MyWCFService.IService();
_proxy.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
#1
13
In my case the problem turned out to be a mismatch between security settings on client and server. I was using a custom binding like this:
在我的情况下,问题结果是客户端和服务器上的安全设置不匹配。我正在使用这样的自定义绑定:
<customBinding>
<binding name="AuthorisedBinaryHttpsBinding" receiveTimeout="00:03:00" sendTimeout="00:03:00">
<!-- this next element caused the problem: -->
<security authenticationMode="UserNameOverTransport">
</security>
<binaryMessageEncoding>
<readerQuotas maxDepth="100" maxStringContentLength="1000000"
maxArrayLength="655360000" />
</binaryMessageEncoding>
<httpsTransport />
</binding>
</customBinding>
When I removed the security element that I've highlighted above the problem with the "Unable to automatically debug" message went away.
当我删除上面突出显示的安全元素时,“无法自动调试”消息的问题就消失了。
To solve the problem I first turned on WCF tracing. This showed me that WCF was throwing a MessageSecurityException:
为了解决这个问题,我首先启用了WCF跟踪。这告诉我WCF正在抛出MessageSecurityException:
Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. This can occur if the service is configured for security and the client is not using security.
安全处理器无法在消息中找到安全标头。这可能是因为消息是不安全的故障,或者因为通信方之间存在绑定不匹配。如果为安全性配置服务并且客户端未使用安全性,则会发生这种情况。
That pointed me to look at the Binding settings on the client side. It turned out that I hadn't added the required security element to my custom binding there. Since I was doing this through code, I needed the following (note the 3rd line):
这指向我查看客户端的绑定设置。原来,我没有在我的自定义绑定中添加所需的安全元素。由于我是通过代码执行此操作,因此我需要以下内容(请注意第3行):
var binding = new CustomBinding(
binaryEncoding,
SecurityBindingElement.CreateUserNameOverTransportBindingElement(),
new HttpsTransportBindingElement { MaxReceivedMessageSize = MaxMessageSize, });
As to why Visual Studio was showing that error, I've no idea - looks to me to be a bug.
至于为什么Visual Studio显示错误,我不知道 - 看起来我是一个错误。
#2
39
I was fighting with this exact same error for over an hour and low and behold I restarted VS2008 and it magically fixed itself. Give it a try as it might save you some time.
我正在与这个完全相同的错误战斗超过一个小时,并且看到我重新启动VS2008并且它神奇地修复了自己。试一试,因为它可能会节省你一些时间。
#3
8
Automatically attaching to a service has the following limitations:
自动附加到服务具有以下限制:
-
The service must be part of the Visual Studio solution you are debugging.
该服务必须是您正在调试的Visual Studio解决方案的一部分。
-
The service must be hosted. It may be part of a Web Site Project (File System and HTTP), Web Application Project (File System and HTTP), or WCF Service Library project. WCF Service Library projects can be either Service Libraries or Workflow Service Libraries.
该服务必须托管。它可能是网站项目(文件系统和HTTP),Web应用程序项目(文件系统和HTTP)或WCF服务库项目的一部分。 WCF服务库项目可以是服务库或工作流服务库。
-
The service must be invoked from a WCF client.
必须从WCF客户端调用该服务。
-
Debugging must be enabled with the following code in the app.config or Web.config file:
必须使用app.config或Web.config文件中的以下代码启用调试:
<system.web> <compilation debug="true" /> </system.web>
See Limitations on WCF Debugging
请参阅WCF调试的限制
In addition, if both projects (client and service) are in the same solution but will run in different processes (for example if you are using your local IIS Server for development and are running your web application on a different application pool than the service it consumes), you may need to enable "Multiple startup projects" for the solution (on Solution Properties -> Startup Project) so that the debugger can attach to both.
此外,如果两个项目(客户端和服务)都在同一个解决方案中,但将在不同的进程中运行(例如,如果您使用本地IIS服务器进行开发,并且在不同的应用程序池上运行Web应用程序而不是服务它消耗),您可能需要为解决方案启用“多个启动项目”(在解决方案属性 - >启动项目上),以便调试器可以附加到两者。
To avoid the service browser window to show up every time you debug, you may set the "Start Action" (on service project properties) to "Don't open a page. Wait for request from external application."
为避免每次调试时都显示服务浏览器窗口,您可以将“开始操作”(在服务项目属性上)设置为“不要打开页面。等待来自外部应用程序的请求”。
This is from personal experience and may help others.
这来自个人经验,可能会帮助他人。
#4
6
The other reason you might see this error (and I believe is the case for me) is if you're running in 64bit Windows. Apparently Visual Studio doesn't have any x64 debugger support.
你可能会看到这个错误的另一个原因(我相信是我的情况)是你在64位Windows上运行。显然,Visual Studio没有任何x64调试器支持。
You can work around this by changing the Platform Target for the consuming application:
您可以通过更改使用应用程序的平台目标来解决此问题:
Project Properties -> Build -> Change "Platform Target" to "x86".
项目属性 - >构建 - >将“平台目标”更改为“x86”。
Unfortunately this won't work for me as I'm trying to run in the Windows Azure Development AppFabric which seems to require everything to run in 64bit mode!
不幸的是,这对我来说不起作用,因为我试图在Windows Azure开发AppFabric中运行,这似乎要求一切都以64位模式运行!
#5
1
I also got the same problem. I changed in both client & service config files like
我也遇到了同样的问题。我更改了客户端和服务配置文件,如
Compilation debug is set to true.
编译调试设置为true。
This worked for me.
这对我有用。
#6
0
Have you tried
你有没有尝试过
<serviceBehaviors>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
For debugging purposes?
出于调试目的?
Edit : nevermind, I think I misunderstood the question
编辑:没关系,我想我误解了这个问题
#7
0
I've had a similar problem and it turns out to have been due to Windows Authentication not being enabled on the IIS site/virtual directory.
我遇到了类似的问题,结果是由于IIS身份验证/虚拟目录上没有启用Windows身份验证。
Have you tried setting the authentication mode to Integrated instead of Anonymous? http://msdn.microsoft.com/en-us/library/x8a5axew(VS.80).aspx
您是否尝试将身份验证模式设置为“集成”而不是“匿名”? http://msdn.microsoft.com/en-us/library/x8a5axew(VS.80).aspx
#8
0
In your web service web.config ensure that compilation debug is set to true. That should fix your problem!
在Web服务web.config中,确保将编译调试设置为true。这应该可以解决你的问题!
#9
0
In my case the problem turned out to be something completely different. I had changed the name of an operation on the webservice and forgot to update the client. For some reason this resulted in the "Unable to automatically debug ..." error.
在我的情况下,问题变成了完全不同的东西。我更改了webservice上的操作名称,忘记更新客户端。由于某种原因,这导致“无法自动调试...”错误。
#10
0
It can also be that the same port number is used in IISExpress and IIS. If you are developing a WCF application in Visual Studio and IISExpress and then install the same application on your local IIS make sure not to use the same port number in IIS and IISExpress. Using the same port number will lead to this error message.
它也可以是IISExpress和IIS中使用相同的端口号。如果您在Visual Studio和IISExpress中开发WCF应用程序,然后在本地IIS上安装相同的应用程序,请确保不要在IIS和IISExpress中使用相同的端口号。使用相同的端口号将导致此错误消息。
#11
-1
Add this line of code after you create your service reference in your client.
在客户端中创建服务引用后添加此行代码。
MyWCFService.IService _proxy = new MyWCFService.IService();
_proxy.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;