I was going over the MbUnit issue list and came across Issue 97. This had a really interesting scenario. Basically, Firefox was the default web browser but didn’t have a profile associated with it (it hadn’t been executed yet) and when you try and launch it via Process.Start it will load firefox correctly however also throw a Win32Exception.
If you did something like this:
The exception would be:
System.ComponentModel.Win32Exception was unhandled
Message=”The system cannot find the file specified”
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at ConsoleApplication1.Program.Main(String args) in ……Program.cs:line 13
at System.AppDomain._nExecuteAssembly(Assembly assembly, String args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String args)
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
Very strange, if anyone knows the extract reason why it decides to thrown an exception please leave a comment. Definitely something to be aware might happen. Wonder how many applications would crash because of this…
When testing your applications, if you want to reproduce this without having to load a clean VM, go into your %AppData% and move the Mozilla directory to another location. Next time you load Firefox, the dialog will be displayed and the exception will be thrown.