Weird issue with C# console app on a specific machine - c#

I have the simplest C# console app that only does a WriteLine and a ReadLine. For some reason, it doesn't run in standalone mode on the machine it was built. I tried the built executable on another box and it works fine.
Trying to run it on this machine makes it just hang there. It works fine inside VS, just not from the command line.
Trying to attach VS to the hanging process says something along the lines of "ConsoleApplication1 has triggered a breakpoint" but can't see what the problem is (it indicates the breakpoint is _LdrpDoDebuggerBreak#0() in ntdll.dll).
Any ideas on how to diagnose what's going on?
EDIT (answering comments below): Same behavior happens for both Release and Debug. Platform is set to Auto. Both machines tested on are 64-bit. The one it's working on is Windows 7, the one I'm building on (and where it hangs) is Windows 10.
EDIT2: Something else I noticed is that trying to run the app doesn't bring up a console window (so it hangs before that). Also, detaching after attaching to the hanging process also hangs VS.
EDIT3: Here's the full zipped project: (removed). It contains the debug .exe file as well for the curious. It's just a vanilla console application project with the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("ASD");
Console.ReadLine();
}
}
}

Are you sure that there's nothing in your code except a WriteLine() and a ReadLine()? I haven't tested it, but this sounds like exactly the behavior I would expect from calling Debugger.Break().
The MSDN page has a note:
Starting with .NET Framework 4, the runtime no longer exercises tight control of launching the debugger for the Break method, but instead reports an error to the Windows Error Reporting (WER) subsystem. WER provides many settings to customize the problem reporting experience, so a lot of factors will influence the way WER responds to an error such as operating system version, process, session, user, machine and domain. If you're having unexpected results when calling the Break method, check the WER settings on your machine. For more information on how to customize WER, see WER Settings. If you want to ensure the debugger is launched regardless of the WER settings, be sure to call the Launch method instead.
On the machine where it is working, it's either ignoring this line because you don't have development tools installed, or your settings are such that it just skips it. On the machine you're developing on, the settings would be different. Possibly fees are based on the Windows 7 and 10 defaults, but I don't know.

Finally figured it out. It's my lovely antivirus. Hoping this helps someone in the future, Avast doesn't bring up the usual prompt indicating it's scanning the app or quarantining it or anything. Disabling the shields (Avast Shields Control -> Disable for 10 mins) makes the app work properly. Argh!
Thank you all for the support!
Interestingly the other machine where it works is still running Avast, but I think it's one major version behind. This is for version 10.4.2233.

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.

Anyway to deal with weird errors while my .net program running?

I made a program, which works fine on my PC without any errors, it also works fine on some office PCs, but it crashes without any describable error on customer's PC and some others.
Crashes are completely random, sometime it may crash and sometimes not.
Crashes are not related with any actions, sometimes it may crash when they just look at the program and wait for crash.
Customers send me this beautiful screens and want me to solve this.
There you see common error reporting dialog, but not info about Exception.
My program uses Unity Web Player running in WebBrowser control. It's always run in background on the hidden tab which becomes visible when needed.
Any ideas how to handle such errors?
I think you should first ensure that the environment at your place and that of your customers are identical.
Maybe there're dll or other programs installed at your place (Unity web player as you mentioned for example) or anything in your Registry that may differ.
Else there's no point in getting error on one PC and not on another.
Make sure all dll are well deployed
Check your registry,
Ensure that all related programs are well installed

Mono & WInforms on OS X

I have just begun to explore the mono winforms environment and I cannot work out how to start a program from within monodevelop without a console session being started.
My simple program runs okay but when it exits a terminal session is always created & waiting for me to 'press any key'. I guess I could arrange things so that the terminal window closes automatically, but I would rather the app just ran 'natively', is this possible or does the way mono & .net function work preclude it?
As shown in the examples at Zetcode, in 'Main' the rest of the code is started with 'application.run(new aFunction());', I thought this might be the cause of the terminal session occurring but replacing it with:
myNewClass n = new myNewClass();
n.aFunction();
causes the program to not run at all (or maybe just exit without doing anything).
I am an experienced programmer but not familiar at all with C# or the mono/.net environment so 'stating the obvious' may be all that is required in an answer.
MonoDevelop will usually let you start a program with or without it running in an external console.
In MonoDevelop 2.8 on Linux you can control this by context clicking on a project in the solution tree and selecting Options; then Run on external console under the Run section. I'm not sure if you can disable this on OSX.

C# Program runs fine, until minimized

I've never seen this issue before, and I'm not even sure if I'm posting in the correct place.
My Co-worker wrote a C# program (windows), that includes a web control. In that web control are a bunch of iFrames. Now, when the web control is populated (max 15 records), everything is fine. 99% system idle process. But once you minimize the program, boom, 99% process goes to the c# program and stays there!
If the web control is not populated. There is no issue with minimizing and maximizing the program.
There are no functions that run when the program is minimized or maximized, so there's nothing to debug...
The program is crashing on two computers, but on the rest (about 8 computers) it runs fine.
The two computers that "crash", are not very similar... so it's proving hard to find what may be causing the issue. One computer is xp, the other is windows 7, one is ie7, the other is ie8.
If anyone could point me in the right direction, or if anyone had a similar situation and has a solution, I'm all ear's and eye's!
I would attach Visual Studio to the "99% CPU" process, break all, and see what's going on in there. That's first step.
Doesn't Windows write inactive (i.e. minimised) application state to disk, to free up resources for active (non-minimised) windows?
One of the hooks / events called when you minimise the application could be causing IO hangs. You should get a diagnostics tool like Sysinternals Procmon to see if IO (or any other process) is hanging based on the minimise event.
Good luck!
Chris.
So my co-worker didn't find the thorough answer as to why it was crashing, but it was crashing due to the .net Web control. He swapped out the control for a VB6 control and it now works.

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