I have a command line winforms executable that invokes a windows winforms application.
Occassionally Ops forget to include Windows exe with the exe command line when deploying the application, resulting in an error.
How I gracefully handle this and show a nice error, not:
Unhandled exception: System.IO.FileNotFoundException: it is possible not to load the file or ass in "MyappFoo", Version = 5.1.4303.0, Culture = neutral, PublicKeyToken = null or one of its dependencies. The system cannot find the specified file. File name: 'MyAppFoo, Version = 5.1.4303.0, Culture = Neutral, PublicKeyToken = null' in AppFoo.Program.Main (String [] args)
WRN: Assembly binding registration is off. To enable assembly error logging, set the registry value to [HKLM \ Software \ M icrosoft \ Fusion! EnableLog] (DWORD) to 1. Note. There is some performance limitation associated with assembly binding failure. To turn this feature off, delete the registry value [HKLM \ Software \ Microsoft \ Fus ion! EnableLog].
Edit:
To clarify a bit how to catch a FileNotFoundExcception when
static int Main(string[] args)
{
try
{
Console.WriteLine"MyPhooApp Command Line (c) PhooSoft 2008");
}
catch (System.IO.FileNotFoundException fe)
{
Console.WriteLine("Unable to find foo.exe");
return -1;
}
}
does not work.
source
share