Hi I'm developing a windows phone app and I use
System.Diagnostics.Debug.WriteLine()
function to write some debug info and when I run the program in debug mode while my phone is connected to my computer and visual studio there is no problem. but when I run the program without debugger - while installed in each of release and debug mode - those lines of debug info cause the app to encounter an exception!
can anybody explain what's going in there?
You can try to check if debugger is attached, then execute codes specific for debugging purpose only if IsAttached value is true :
if(System.Diagnostics.Debugger.IsAttached)
{
System.Diagnostics.Debug.WriteLine();
}
Related
I have a Windows service that is started and after some time it shuts down with the following exit code:
-1073740791. STATUS_STACK_BUFFER_OVERRUN.
How can I debug? How do I know what is happening. Tried attaching with the debugger (with "Enable native code debugging" enabled) and selected all exceptions but it doesn't stop. The service just exits.
I have built a web app which suddenly stops while running. I could see the following in output window in my VS
The program '[29000] iisexpress.exe: Managed (v4.0.30319)' has exited with code -1073741819 (0xc0000005) 'Access Violation'
The program '[20648] iexplore.exe' has exited with code -1 (0xffffffff).
I have tried to debug to find the line where it fails. But it did not fail anywhere. The page was successfully loaded and it stops running after few seconds.
Check out the answers for this question.
You can try cleaning the solution/project and making sure you delete ASP.NET temporary files.
I noticed your error includes detail regarding IExplore.exe; makes me wonder if the debug process is unable to launch Internet Explorer due to something blocking that invocation. Try temporarily turning off Windows Firewall or any Anti-Virus program and make sure User Account Control (or LUA if on Windows Server) is disabled.
I am having issues with running a simple C# Console Application in Visual Studio 2013.
Details of my problem: I was running Console Applications successfully with the default "Press any key to continue" displaying cleanly at the end. Suddenly it started behaving differently with the following symptoms:
A new command window (cmd.exe) opening alongside my Console Application (this wasn't happening in the past)
My Console Application closing abruptly without the default clean "Press any key" message
cmd.exe hangs and I am unable to close it, even through the Task Manager -> End Process
My System Properties:
Visual Studio 2013 Ultimate
Windows 8, x64
This is my Console Application code just to show that it isn't a problem in my code:
class Program
{
static void Main(string[] args)
{
RegularTest();
}
private static void RegularTest()
{
Console.WriteLine("This is the Regular Test. It works!");
}
}
We had the exact same problem here during several weeks !
And we finally found a solution !
In our case, it was the anti-virus Avast which was corrupting the generated .exe !
The solution was to simply disable all agents while generating the release !
If you use another anti-virus, try to disable it.
I created a Windows service in C# (4.0) and am trying to install it using installutil tool in command line. However I get an exception. I managed to find out what part of my code is causing the exception - using some crappy logging but whatever - but now I want to understand why. So what I want to do is debugging the installation of my Windows Service.
I know how to debug the service itself, but here, I want to debug the content of my Installer.Install(IDictionary stateSaver) method in the service.
I tried to attach the debugger to the cmd.exe process but it obviously doesn't work. I was thinking also to attach the debugger to the installutil process but I have no clue how to do this.
I had a look to this post: How do you debug a windows service that is being installed? and several others but in this case, for some reason, this guy seem to have his service already in the services.msc which is not my case.
How can I achieve this?
You can put a Debugger.Break(); statement in the installer code, and it should launch the debugger for you.
If the above does not work, I have found this process works too. Basically, you compile in debug mode and install the service (I used installutil.exe through the command line). In code you pop-up a message box with the process ID. Startup a second instance of studio, attach it to that process and debug. The message box pauses it to allow setup. The process ID isn't important, its named InstallUtil.exe. I usually put a Debug.Break() in after the message box to guarantee it enters the code.
using System.Windows.Forms;
using System.Diagnostics;
...
#if DEBUG
int processId = Process.GetCurrentProcess().Id;
string message = string.Format("Please attach the debugger (elevated on Vista or Win 7) to process [{0}].", processId);
MessageBox.Show(message, "Debug");
#endif
....
How to debug the installation of a custom windows service
I am trying to get crash dump debugging working with 2010, but it keeps failing.
I get this error when I try to start debugging:
"Managed Minidump Debugging: The signature verification for the file 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscordbi.dll' failed with the error 0x800700c1.:
I'm using the simplest program I can think of just to get off the ground (below).
Here are the steps I am taking:
Build
Run with a double-click from Windows explorer
right-click on the process in TaskManager, and select "Create Dump File"
kill the process
open the dump file in Visual Studio (File | Open, set filter to crash dumps)
Select "Debug with Mixed"
much loading of symbols (I have MS Symbol server enabled)
Boom (I get an error dialog saying I need to specify my symbol path -- which I believe I have done -- MS symbol server is enabled, and my solution is loaded)
In the output window, I get the following error (note that there are also a bunch of successful symbol loads, including for my exe):
Managed Minidump Debugging: The signature verification for the file 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscordbi.dll' failed with the error 0x800700c1.
(All the while, the solution with the code for my exe is loaded in the Visual Studio instance).
Any idea what I am doing wrong? Is this the right procedure for crashdump debugging in VS 2010?
The test dummy program:
class Program
{
public static string AStaticProperty = "Hello World";
static void Main(string[] args)
{
DoLoop(10000);
}
static void DoLoop(int iterations)
{
for (int i = 0; i < iterations; i--)
System.Threading.Thread.Sleep(500);
}
}
Edit
I'm going to vote to close -- I don't know exactly what the deal is, but everything is working now.
Here's what I did:
I started debugging the running process in VS 2010
I used the "save dump file" option off of the debug menu in 2010
I stopped the process and loaded the dump file.
It worked, so I thought "hmm, maybe the problem was with the dump file that I created (had used both adplus and TaskManager).
But no, now those work too. (although they failed very reliably until I did the 3 steps above). Weird, but now I cannot repro, so I'm going to vote to close.
Maybe this question/answers "Symbol issue when debugging C# code" helps you out.
The common tool used to debug dumps is WinDbg which is available in Debugging Tools for Windows. For x64 dumps you need the x64 debugger, while for x86 you need x86 debugger.
Visual Studio is x86 only, so you should not expect it can debug all dumps.
I think that this was an unstable machine/need a reboot issue. I have been unable to repro the problem