4 Replies - 7795 Views - Last Post: 23 February 2011 - 11:07 AM Rate Topic: -----

#1 dilzniksan   User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 35
  • Joined: 02-September 09

Debugging my first .NET App

Posted 22 February 2011 - 01:32 PM

I have a fairly simple application I wrote that seemed to execute correctly on my dev box, but when I try to run the app on a separate machine, it fails with the following events in the log:

 (.NET Runtime error)
Application: WolApp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Stack:
   at WolApp.PowerModel..ctor()
   at WolApp.PowerController..ctor()
   at WolApp.Program.Main()



Seconds later this error follows:
Faulting application name: WolApp.exe, version: 1.0.0.0, time stamp: 0x4d641b72
Faulting module name: KERNELBASE.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdbdf
Exception code: 0xe0434352
Fault offset: 0x0000b727
Faulting process id: 0x12b8
Faulting application start time: 0x01cbd2ce81d7da5b
Faulting application path: X:\WolApp.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: bfc4aacb-3ec1-11e0-8907-0024e82e58f8


Now in the first error, the error seems to originate from the WolApp.PowerModel constructor which is defined as follows:

public PowerModel() {
            try
            {
                entry = new DirectoryEntry();
            }
            catch (System.IO.FileNotFoundException e)
            {
                string sSource;
                string sLog;
                string sEvent;

                sSource = "WolApp";
                sLog = "Application";
                sEvent = e.message;
                EventLog.CreateEventSource(sSource,sLog);
                EventLog.WriteEntry(sSource, sEvent);
             }
        }



The try / catch block neither catches the exception, nor does it write to the log?


For completeness: both machines are Win 7 Pro x64 with .NET 4 and the MySQL Connector installed.

Is This A Good Question/Topic? 0
  • +

Replies To: Debugging my first .NET App

#2 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5104
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Debugging my first .NET App

Posted 22 February 2011 - 01:37 PM

The exception is likely happening inside the catch. It's probably not able to find the log file. Make sure the file and directory exists.
Was This Post Helpful? 0
  • +
  • -

#3 dilzniksan   User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 35
  • Joined: 02-September 09

Re: Debugging my first .NET App

Posted 23 February 2011 - 09:58 AM

The exception was being thrown before I implemented the try catch block.
Was This Post Helpful? 0
  • +
  • -

#4 CreaturGames   User is offline

  • D.I.C Regular

Reputation: 30
  • View blog
  • Posts: 290
  • Joined: 29-December 09

Re: Debugging my first .NET App

Posted 23 February 2011 - 10:07 AM

View Postdilzniksan, on 23 February 2011 - 09:58 AM, said:

The exception was being thrown before I implemented the try catch block.

Have you tried restarting the project and re-imputing the code?
Just to make sure, you are using Visual C# right?

It maybe that the code:
EventLog.CreateEventSource(sSource,sLog);
EventLog.WriteEntry(sSource, sEvent);


Couldn't write the event log. Usually, this means that there was something blocking the application from writing the log to the directory.
Was This Post Helpful? 0
  • +
  • -

#5 dilzniksan   User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 35
  • Joined: 02-September 09

Re: Debugging my first .NET App

Posted 23 February 2011 - 11:07 AM

The try catch block is not causing the error. I implemented it to catch the exception. What is strange about this is that the exception is only thrown when the application is run on machines outside of my dev box.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1