How to debug .NET remoting calls?

Chris picture Chris · Nov 6, 2008 · Viewed 7.7k times · Source

I have an app with the following basic architecture:

A windows service (Service) that registers a .NET type (RemoteObject) for remote access (.NET Remoting). RemoteObject creates non-ThreadPool threads that use the ThreadPool to do IO processing. The size of the ThreadPool must be restricted to a limit for a particular reason. A GUI app uses .NET Remoting to access RemoteObject.

I've noticed that if the size of the ThreadPool is too low, the GUI app will hang when making a call to RemoteObject.

My question is, how can I figure out why this is hanging, and why would the RemoteObject thread be affected by the ThreadPool?

This is driving me crazy; thank you for your help!

Answer

user1228 picture user1228 · Nov 6, 2008

I'm not sure if this will help (I can't tell if this is your problem or not), but if you want to debug your service as its running, you can slap this in your code:

#if DEBUG
            if (!System.Diagnostics.Debugger.IsAttached)
                Debugger.Launch();
#endif

and you'll get a dialog asking you to select a debugger. Its an easy way to attach to a running instance of a service. If nothing else, this will let you break into your service when the UI is hanging (by pressing the pause button on your debug toolbar) and check out your threads and callstack.