views:

314

answers:

3

We have an application written in C# .NET that is currently used in production environments. Obviously the release build is used.

Unfortunately sometimes the application misbehaves under certain conditions and we can't figure out why. We are unable to reproduce the issue in house. Yes, more tracing would help, but often it is after the fact that you realize that more tracing should have been put in place.

What is the best way to debug that installation using the regular, line by line, Visual Studio Attach-to-Process type debugging. Would it be to install the express edition of VS on the customer machine and replace the dlls with the debug versions? Is it enough to just send the PDBs over and the specific source files? Is there a better way? The end goal is to have a development like environment to debug the issue.

+2  A: 

First, make sure that you have deployed PDBs with the app (release PDBs are sufficient). Then, if you install and run the Visual Studio remote debugger on the production machine, you will be able to debug it from your local machine. The PDB files of app on the deployed machine should match your local version as I don't think the remote debugger does any kind of synchronization.

Steve Guidi
Just to be clear: you don't need to install Visual Studio, only the remote debugger.Regards,Sebastiaan
Sebastiaan Megens
MSDN Info on setting up Remote Debugging: http://msdn.microsoft.com/en-us/library/xf8k2h6a.aspx
Millhouse
+2  A: 

Remote debugging is a good feature, but it can seldom be used in production environments because it requires 2-way trust between domains (your own and your customers) that is hard to achieve (administrators of both companies will strongly opposit the idea)

see Remote Debugging Across Domains

However sending PDB files with your application will help. You can ask your customers to use Clr Debugger (DbgCLR.exe) It has some limitations comparing with VS Debugger, but still it is a debugger that can do the work and it is a part of .NET SDK. If the problem is cannot be debugged with Clr Debugger, customers can try to install a trial version of VS in their production environment and give you a remote desktop connection (if admins will allow you to do this). I suppose that 90-day trial period will be enough to solve the problem

You can also try to build a test environment like your customer have - limit (or increase) number of CPUs, memory etc. to match physical conditions as far as you can. Ask your customer to create a virtual image of their Windows if you think that some additional 3rd party software or non-existing registry record can influence your program.

However, my experience is that in 50% such "non-reproducible" errors in .NET happens because of concurrent access by multiple users (deadlocks, race conditions, logical misbehavior in First Wins/Last Wins scenarios). In most cases these are errors that you will not be able to debug even if you install VS on customer machine (if you run this in non rush hours), because you need to run at least 2 customers on different machines simultaneously.

So, while you are looking for options to provide debugging to customers, keep working on improving tracing and monitoring features. Tracing and performance counters are often your only friends in production environments.

Bogdan_Ch
Mark
I suppose that DbgClr for 2.0 should be able to debug 3.0 and 3.5, because actually all these frameworks have been grown on the base of 2.0. (and when in install 3.5 SP1 it allso installs all required patches for 2.0, and I hope for debugger as well). I suppose that for .NET 4.0 we will have a new debugger.
Bogdan_Ch
A: 

use status messages and log files to at least identify the line of code causing the error.

Beth