C# app runs with debugging, but not without

33,678

Solution 1

I fixed it, the .NET 2.0 Framework was corrupt and when I reinstalled it, everything magically started working again.

Solution 2

I've had similar issues where timing conflicts were causing the failure, and my debugging (breakpoints and stepping through the code) forced the code to run in the correct order.

Solution 3

Try take off optimizations from the Release build (in the project settings) and see if that helps.

Solution 4

I cannot tell you what exactly the problem is, but here's what you could do to get a clue what's really happening. I assume you're using VS2008 or 2005.

  1. Switch to release mode
  2. Go to Debug\Exceptions, and mark all "Thrown" exceptions, like illustrated here: http://vvcap.net/db/JbWS_tzy2IpBoI7R7amm.htp
  3. Run executable in debugger, ignore the warnings from VS that there's no debug info

It does seem that there's a win32 exception thrown some time during execution, but this way or another, you will get one or more messages from debugger explaining what kind of exception happened and where. In most cases those messages make it pretty clear what exactly went wrong

EDIT: One thing I forgot to mention is that unmanaged debugging must also be turned on, such like here (when you start program directly from IDE) or here (when you attach to running process)

Solution 5

Here is a support article with that error. Does that apply?

Perhaps the debugger is eating an excaption the VE3D API is throwing. In VS, do a ctrl+alt+e and change it to break whenever any exception is thrown. This can be tedius b/c it will break on all your try catch blocks, but it might give you some information.

Here is some info. about that PlugInLoader. It seems to imply it must be called from the FirstFrameRendered eventhandler. Perhaps one of your forms is doing that and one not?

Share:
33,678
Programatt
Author by

Programatt

I am a programmer by day, and a tinkerer by night.

Updated on January 05, 2020

Comments

  • Programatt
    Programatt over 4 years

    I'm running a (mostly) single threaded program (there's a main thread that does everything, the others only read stuff). I can get the application to run fine in VS2008 after a minor change (I changed the text of a form, and tab order of another form), but I can no longer get it to work outside of the debugger. Does anyone know what would cause this?

    Clarification: Release mode, launched with debugger (F5) works. Debug mode, lanuched with debugger (F5) works. Debug executable, or release executable launched outside of VS or with Ctrl+F5 fail.

    It uses Microsoft's Virtual Earth 3D, and it seems to crash just when the 'ring of hope' (loading ring) is about to complete.

    Event log says: ".NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (000006427F44AA6E) (80131506)"

    Culprit: this line:

            this.loader = PlugInLoader.CreateLoader(this.globeControl.Host);
    

    Causes it to fail. However, the form that was working uses the exact same line without an issue. This line is nesseccary for the program to function. I have no idea what it's doing.

    Another Lead the error seems to be inside the .NET framework. Application worked on another machine, attempting reinstall. Update: didn't make a difference, although when I repaired VS it kept telling me Visual Studio was crashing even though I wasn't running it.


    Error When I launch the program after a couple minutes I get: Application has generated an exception that could not be handled.

    Proccess ID=0x9CC (2508), Thread ID =0xF0C(3852).

    Click OK to terminate the application.
    Click CANCEL to debug the application.


    The disassembly is bizarre:

    0000000077EF2A90  int         3    
    0000000077EF2A91  int         3    
    0000000077EF2A92  int         3    
    0000000077EF2A93  int         3    
    0000000077EF2A94  int         3    
    0000000077EF2A95  int         3    
    0000000077EF2A96  xchg        ax,ax 
    0000000077EF2A9A  xchg        ax,ax 
    0000000077EF2A9E  xchg        ax,ax 
    0000000077EF2AA0  int         3        <-- Crashes here
    0000000077EF2AA1  ret    
    

    It repeats that same code block several times (minus on ax exchanging with itself)


    Besides my computer, it has worked on every machine I've tested it on, except for a VM on my machine which won't install the .NET framework because setup downloads 0 bytes out of 0 bytes for the framework)...lovely windows.

    • Programatt
      Programatt about 15 years
      None, it just crashes. Windows says that the application needs to close.
    • JP Alioto
      JP Alioto about 15 years
      Can you be more specific what you mean by "outside of the debugger"? Do you mean F5 versus Ctrl+F5 in Visual Studio? If you go to the bin/debug directory and double click the exe it fails?
    • Programatt
      Programatt about 15 years
      Outside the debugger means that it's not running with debugging, launching with Ctrl+F5 or directly from the executable both cause the application to crash.
    • Programatt
      Programatt about 15 years
      Event log has: .NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (000006427F44AA6E) (80131506)
    • JP Alioto
      JP Alioto about 15 years
      Does the application use any networking? Like you've allowed VS through a firewall but not the application directly.
    • Programatt
      Programatt about 15 years
      It connects to Microsoft's servers to pull some xml files, but it's done with their API and nothing has changed since my last update to the program, and it was working before.
    • JP Alioto
      JP Alioto about 15 years
      Yes, you changed the build. Make sure the application itself is allowed through the firewall.
    • Programatt
      Programatt about 15 years
      Nothing has changed in their api, which does the connecting. The firewall is not the issue here (I wish it was, it'd be simple to fix)
    • JP Alioto
      JP Alioto about 15 years
      I think George is right, have to isolate it.
    • Programatt
      Programatt about 15 years
      I think something is going wrong with the VE3D's API...it crashes when VE3D almost finishes loading although I have a form that still works...
    • JP Alioto
      JP Alioto about 15 years
      Use ctrl+alt+e and have it break on all thrown exceptions.
    • Programatt
      Programatt about 15 years
      no change. Doesn't throw an exception in debugger.
    • JP Alioto
      JP Alioto about 15 years
      Sorry for throwing darts here, but it's the inside/outside VS clue that makes me think there is a solution here and it's not just an API bug. How about permissions? Are you admin all the way through?
    • Programatt
      Programatt about 15 years
      I am. I don't actually think it happened because I changed something, because it worked once before after I changed it. I changed it, compiled it. Ran it (without debugger) and went to lunch. When I came back it wouldn't run again so I restart the computer and now it won't work at all.
    • Programatt
      Programatt about 15 years
      An API update had been released yesterday and I updated today, would it have just now registered the dll changes? Could that be it?
    • JP Alioto
      JP Alioto about 15 years
      Very possibly. It's a pain, but maybe you should build a toy app. that only makes the API calls and see if you still have a working API.
    • Programatt
      Programatt about 15 years
      but when I make another app look just like it, it fails...
    • JP Alioto
      JP Alioto about 15 years
      Before you reinstall -- are any of your DLLs deployed to the GAC? That would take priority over local assemblies and not be a problem when you move machines.
    • Anton Tykhyy
      Anton Tykhyy about 15 years
      NB: the jitter works differently when launching from VS, i.e. it ignores tail calls (not that this is an issue here, but this illustrates the difference)
    • Anton Tykhyy
      Anton Tykhyy about 15 years
      I think it was global assembly cache. Open c:\windows\assembly with Windows Explorer.
    • Programatt
      Programatt about 15 years
      They are in it should I remove them?
    • Abhishek
      Abhishek about 15 years
      The references in your project, when you added them, did you use the .NET tab for any of them? I could be wrong but I'm pretty sure those are the contents of your GAC
    • Programatt
      Programatt about 15 years
      No I did not, I added them from browsing to the C:\Program Folder (x86)\Virtual Earth 3D
  • Programatt
    Programatt about 15 years
    It's an app that uses Virtual Earth 3D to create animations, and it was working until I changed a few minor things.
  • Abhishek
    Abhishek about 15 years
    That's an interesting idea but can it really be the issue if his application writes on a single thread only?
  • Programatt
    Programatt about 15 years
    no breakpoints in the debugger :(
  • Programatt
    Programatt about 15 years
    someone already asked me to do that, it makes no difference. Nothing is thrown. Nothing. It just crashes outside of a debugger.
  • C. Ross
    C. Ross about 15 years
    You're right, it normally is caused by multi-threading, but sometimes object is doing multi-threading in the background.
  • Programatt
    Programatt about 15 years
    if you call it from the FirstFrameRendered event, it's too late. It's one of the few things that has to be called before that. However, loading plugin's happens after the first frame has been rendered.
  • Jared Updike
    Jared Updike almost 15 years
    Can't figure out how to reinstall. The installer says it's already installed. The Control Panel (Add or Remove Programs) has a Change button that shows a dialog and a progress meter but it doesn't say whether it reinstalled anything or even whether it succeeded or failed. Whatever I tried had no effect on my program's inability to run.
  • Programatt
    Programatt almost 15 years
    You need a third party tool, microsoft won't let you remove it. You're looking for dotnetfx or .NET Fix. Google it, it shouldn't be too hard to find. According to microsoft this kind of stuff doesn't happen, therefor you cannot uninstall it.
  • Programatt
    Programatt almost 15 years
    Why was this voted down. It is what solved the issue...
  • Greg Gum
    Greg Gum over 6 years
    This resolved the issue for me.
  • Rory McCrossan
    Rory McCrossan over 4 years
    Thank you. This worked for me, but I really don't like it as a long-term solution. Does anyone know exactly what unchecking this changes, and what a better approach would be?
  • Germán Martínez
    Germán Martínez over 4 years
    Here's an interesting blog post about what optimizations do: blogs.msdn.microsoft.com/ericlippert/2009/06/11/… but honestly if this is causing an issue something deeper is the problem - just look at the other answers. Even a corrupt installation of .net...