Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.IO.FileNotFoundException. Where do I find what path is wrong?

I create small Windows Forms progs in VisualStudio2010, just for hobby. After releasing them I use the .exe file to run them on other PCs, without having to do any installation. Those PCs run Windows OS(7,vista,XP). The PC which I wrote the code had Win XP and the progs managed to work fine anytime.

Now I wrote another prog, on another PC, which runs Win 8.1 and I get the following error whenever I try to run the released .exe at other platforms, as mentioned above.

Problem signature:
  Problem Event Name:   CLR20r3
  Problem Signature 01: dmg_ors.exe
  Problem Signature 02: 1.0.0.0
  Problem Signature 03: 52f4bad1
  Problem Signature 04: DMG_ORS
  Problem Signature 05: 1.0.0.0
  Problem Signature 06: 52f4bad1
  Problem Signature 07: 3
  Problem Signature 08: c
  Problem Signature 09: System.IO.FileNotFoundException
  OS Version:   6.1.7601.2.1.0.256.48
  Locale ID:    1033
  Additional Information 1: 82e2
  Additional Information 2: 82e23b36efee975bd0e9417ff09fe7bb
  Additional Information 3: a1d6
  Additional Information 4: a1d6e932d2c942475edff9f8fe05b46c

Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
  C:\Windows\system32\en-US\erofflps.tx

How can I locate what file is missing? tyvm

like image 550
Stelios Avatar asked Feb 07 '14 11:02

Stelios


People also ask

Which exception will a program generate when a specified file name doesnt exist in the file system?

FileNotFoundException which is a common exception which occurs while we try to access a file. FileNotFoundExcetion is thrown by constructors RandomAccessFile, FileInputStream, and FileOutputStream.

Could not find file System io FileNotFoundException?

IO. FileNotFoundException appears when the path that you are using is wrong , it means that the file doesnt exist. Your problem cames on the variable string fullpath wich has a wrong path. First check on your computer(windows search : windows+s) that the file exists by copying there the full path.

How to handle FileNotFoundException in c#?

This happens as the reader. ReadToEnd() is trying to read the file which doesn't exist. To resolve this create the file using a File class method File. Create() within the catch block.


1 Answers

Problem solved.I had to modify my main,IOT to catch that exception and see what
was actually missing.

 static void Main()

{

 Application.EnableVisualStyles();
 Application.SetCompatibleTextRenderingDefault(false);
 Application.ThreadException += new  

ThreadExceptionEventHandler(Application_ThreadException);
      AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

  Application.Run(new Form1());

}

static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
  MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception");
  // here you can log the exception ...
}

static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
  MessageBox.Show((e.ExceptionObject as Exception).Message, "Unhandled UI Exception");


     // here you can log the exception 

}

Then I could see that the problem existed because Visual Basic Powerpack needed to be installed.I assume that machines without VS2010 installed,even if they have .NET 4.5, do not have that. The question is though, what was the difference this time and that package was needed IOT run the application.... The solution was found here actually, I need to say that. http://www.csharp-examples.net/catching-unhandled-exceptions/

like image 116
Stelios Avatar answered Oct 16 '22 23:10

Stelios