Using Debug View with a Windows Service - c#

I'm having trouble with real time debugging of a Windows service on a remote machine. This machine is behind a firewall only accessible through remote desktop. I include Debug.WriteLine statements through my code, in lieu of Console.WriteLine. Not too long ago I ran across an application from Microsoft named Debug View. It has been helpful in debugging Forms and WPF applications but it will not show the Debug.WriteLine statements for a running service. I would be extremely happy if I could see these debug statements. Is there a way to do this?
Note, the project is compiled in debug mode as I can see the debug statements in Debug View during the service installation.

Run Debug View as Administrator, select the Capture menu, then make sure that Capture Global Win32 is checked. That will capture Debug.WriteLine output from your service (and any other service as well). You may want to use a filter to prevent Debug View from displaying output you are not interested in. Consider prefixing your service debug messages with your service name so that you can filter for them.

Related

Cannot debug ASP.NET Application on Localhost anymore

I've got stumped by problem during development of my ASP.NET application.
I cannot debug it any more after attaching debugger to a process. Recently I was changing some windows features and checking IIS settings but as far as I remember I was able to debug my app till today.
Ok so what's going on.
I attached debugger and nothing happens no symbols are getting loaded (I am absolutely sure that Build -> Configuration and stuff looks correct in terms of debug etd). That symbols are getting generated and that app is working on dlls which I compile the only problem is that no matter what I do - symbols are not getting loaded.
I've got 2 traces which could lead me to the cause 1st:
The first one is strange application type when attempting to attach a debugger using visual studio. Normally all other apps are using Managed (v4.0......),x64 (I am right now talking about Window with all process running on computer Debug -> Attach -> type column)
but this app for some reason is using Script, Managed (v4.0......),x64
The other one is that when I've debugger attached to the application and open Debug -> Windows -> Modules the only one that is listed is:
**Script Code (Microsoft Active Server Pages) Script Code (Microsoft Active Server Pages) N/A N/A Symbols loaded. Script Code (Microsoft Active Server Pages) 1 [29896] w3wp.exe**
Which kinda looks like some precompilled stuff. (I do not recall enabling any kind of recompilation).
I've tried recreating app on IIS along with switch app pool yet it's still the same. What's even more after checking diff of web config I don't see any kind of change which could lead to such behavior.
I was working with this application for like 8 months and never had a problem like this.
Thanks in advance for your tips.
Kind Regards.
EDIT:
Images
Modules
I've had the exact same issue and could solve it by moving the site to a different application pool. The target application pool already had an application assigned which I could debug (showed up as Managed (v4.0......),x64 in process selector) and once I moved the problematic site over, I could also debug that site.
I didn't figure out what exactly causes the behavior in the first application pool but maybe this helps someone to quickly solve this problem until someone comes up with a better analysis.

Debug .Net Winforms Application on the client

How can I attach a debugger to my own .Net Winform application to set breakpoints, watch variables and inspect problems on client machine?
Long story:
I have to figure out the problems with respect to client on the phone (remotely) for my current job. But I can't even find the correct form.
We have nearly 50 projects and they usually have 20 or more forms and use some 3rd party APIs. Client request may have related to crashed application or results are calculated incorrectly. So I have to figure out problem on the phone.
My idea is create a base winform, make all forms to extend that form, attach a debugger, activate that debugger with a key stroke on the client machine. Then I need to see the code, set breakpoints, watch variables and use something like immediate window to execute codes. That way I don't need to change code because of inheritance.
How can I achieve this?
PS : We have fairly good update procedure. So updating the application on the client is easy.
PS2: I will update a Debug build for my purpose.
PS3: VS Remote Debug is not an option.
PS4: Eurokelog or anything like that is not an option.
PS5: We use screen sharing application so I can view client desktop or server.

Debugging EXCHANGE transport agent in VS2010 c#

I was given the source to a transport agent that parses incoming email that meet a certain criteria. I need to make some modifications but I need to track variables and my debugging attempts have been unsuccessful.
I build the dll, install it in exchange, set a break point then attach to the relevant process but nothing appears to be happening. I am not experienced in this method of debugging and I'm pretty sure that i'm missing a step, but all the documentation i'm able to find basically has the process listed as those few steps. Any assistance?
Figured it out
For anyone in the same situation, you need to do is this:
Compile your project in Debug mode.
Deploy it to exchange however you do that.
Since it is a DLL and running through exchange, exchange will be the host process so you'll have to attach a debugging to the exchange process for debugging.
You can do that but going to the Debug menu in VS and selecting "Attach to process", select the process that will be running the DLL.
When VS attaches to the process just set breakpoints in your code and you should be good to go.

SendKeys.SendWait doesn't works

My target is to send keyboard events to external application.
From my application, I'm launching a C# exe (console application) that bring the target application to the front and uses SendKeys.SendWait to send keyboards events. I ran into a rate case were the command don't have any affect.
When debugging it, it works but when running it not in debug it fails.
I think it as something to do with the fact that when debugging my application is the active application.
You'll need to do a little work, and it changes depending on the version of Windows. There's an MSDN page that has a good explanation and an example:
http://msdn.microsoft.com/en-us/library/ms171548.aspx

WinForms Application Hangs

I have an application (ABC) that I developed and it as a windows application (.exe). It is by itself quite a big application referring a lot of dll's.
However, now there is a requirement that demands that this application(ABC) be a part of an even larger application (XYZ). Hence, I had to change the project type of "ABC" from being a windows application to a class library, and by changing a few lines of code.
My problem is that, ever since I started using ABC as part of XYZ, the application started hanging if I dint perform any operation on it for 10 to 15 mins... I do not have any problems while running it as a separate application.
Any reasons why this might occur?
Any suggestions would be really appreciated...
Thanks,
Ram
Launch XYZ in the debugger. Wait for the app to hang, pause the debugger, and have a look at what each of the threads in your process are busy with.
It might also help to turn on "break on all exceptions"
You can also use remote debugging to debug the application whilst it is running on the user's machine. From your dev machine, you can attach to the process on the user's machine, and then do a debug break to see what the threads are doing.

Categories