views:

793

answers:

10

I'm running Visual Studio 2010 on a Windows 7 x64 machine, and occasionally VS is giving me the good old "The remote procedure could not be debugged.This usually indicates that debugging has not been enabled on the server" error that a lot of people ask about.

My problem, though, is that it seems to only do this randomly(it can be anywhere from a few minutes to a few hours), and after I've made plenty of successful calls to the service already. It doesn't prevent the service from working. It still returns values and doesn't throw any errors. The only difference is that annoying dialog pops up everytime I start to debug my application.

I should mention that I'm connecting the WCF service from a WPF application. If I launch the web site the service is part of, I don't get the dialog.

A few of the things I've tried that do not work:

  • Killing and restarting the server.
  • Compiling the web server in x86
  • Enabling tracing, but couldn't find any problems.

Is this just a bug in Visual Studio 2010, or is there something I'm missing?

UPDATE

I've noticed that this seems to occur if my WPF application crashes while the WCF service is being initialized. Afterwards, all attempts to call the WCF service will bring up the "Unable to debug" message until I restart VS2010.

A: 

So I have a few questions about your WCF Service that you are running. Have you configured WCF to run in ASP.NET compatibility mode? ASP.NET compatibility mode? It could be that you are attaching to the web server and not the process hosting WCF. Also can you get others to reproduce the behavior? If so I would Email one of the Visual Studio product managers to make sure a fix for this makes it into SP1.

runxc1 Bret Ferrier
I have tried it with ASP.Net compatibility on and off, and the error still crops up after awhile. Also, I have two computers I work on this project on and it happens on both.
rossisdead
With intermittent behaviour like this it sounds more like a bug. I am doing SharePoint 2007 work with VS2010 and some times I have issues with attaching to the WSS process if I copy DLLS directly into the GAC ao I usually have to do some other type of deployment process.
runxc1 Bret Ferrier
A: 

It's a long shot, but I resolved a similar issue by re-running regiis -i for ASP.NET:

x64
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
x86
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

Make sure to iisreset after that.

JeffN825
Hey Jeff, I meant to respond to this when I wrote my update a few days ago. I did try this, but it seemed to have no effect on the problem.
rossisdead
A: 

Not sure if this will work, but based on your update it appears to be that the process is not attached and you can therefore not debug.

Here is the theory:

  • When it starts normally the process is attached and all works OK.
  • When the WPF app crashes the WCF service is started but is not attached to anything
  • When you restart the WPF app, it sees that the WCF app is running, no need to start it therefore it does not get attached.

The solution would then be to try and attach the process containing the WCF app manually.

Shiraz Bhaiji
A: 

Visual Studio does not debug all web app. Only valid WebServices.

If its not the case, maybe a machine.config error. Take a look into.

Anyhow, if you atach manualy, it must work.

Note: I had some strange debugging problems as I was using VS2010 beta. After get the licenses, it works perfect.

Erico Schuch
+1  A: 

This might not necessarily be an option if you've already deployed the service, but if you add the website as a local project rather than as an IIS project, it'll use the built-in debug web server (Cassini), which VS seems to have less trouble attaching to.

Rei Miyasaka
A: 

You mention that:

The WCF service is running on an ASP.Net site. If I launch the ASP.Net site in order to debug the site through Visual Studio, I don't get any issues

Have you enabled the .NET Framework WCF activation features?

Assuming you're on Windows Server 2008:

  1. Open Server Manager
  2. Open Features Click "Add Feature"
  3. Expand .NET Framework 3.5.1 Features
  4. Expand WCF Features Select both HTTP and non-HTTP activation mechanisms

Without these activation features, IIS doesn't install a listener that knows how to activate the processes that host your WCF service.

When you manually access the web site, you're manually activating the processes and thus should see your WCF services become available. But you also mention that they "randomly" become unavailable - this is probably when the hosting process terminates due to lack of activity and doesn't start automatically when you next try to send a message to your services.

bitcrazed
A: 

Have a look at a utility contained in the C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE folder called vsdiag_regwcf.exe.

Here is some more information which may solve your issue Debugging WCF Services in Visual Studio 2008

HTH,

Steve

Steve
A: 

In your web service, if you are using static initializers, it may help to log whether these ran successfully or not. For example (using a log4net logger assigned to 'Log'):

static Foo() {
   try {
      // ... initialization code here
      Log.Info( ... ); // log success
   }
   catch(Exception ex) {
      Log.Fatal(ex.ToString()); // log failure reason
   }
}

More than once this was a life saver in my team.

John
A: 

If the WPF app is compiled in 32bit mode or running from a different (32 bit machine) have you set the application pool of the IIS site hosting the WCF service to "Enable 32-bit Applications" to true?

Not sure that this should be necessary but you've tried a lot of other things already so this might be worth a try if it's not set already.

Peter
A: 

Ok before you try 1,000 things, please note that you are using VS.NET 2010 and may have a valid exposed bug. You might be doing everything correctly and the issue is with the product. In fact I have an issue open myself with Microsoft Connect in regards to the IDE crashing randomly when Blend and .NET are both open whiel debugging. I sent them a .dmp dump of the issue and they are taking a look.

If you can reproduce the WCF exception message you may want to open an item with Microsoft Connect for Visual Studio. The link is below:

Visual Studio and .NET Framework Microsoft Connect: http://connect.microsoft.com/VisualStudio

atconway