6

I am debugging a WPF application that crashes with a unhandled System.IO.FileLoadException when started.

I used the Assembly Binding Log Viewer to verify that there are no assembly loading errors and all the code in the OnStartup override is wrapped in a try catch.

Having ruled out Assembly binding as the cause of the Exception, what are other possible causes I should be looking into?

Below are the relevant event log entries:


The first error with source "ApplicationError"

Faulting application name: CompanyProductManager.exe, version: 4.2.0.0, time stamp: 0x514a20ba
Faulting module name: KERNELBASE.dll, version: 6.1.7601.18015, time stamp: 0x50b8479b
Exception code: 0xe0434352
Fault offset: 0x0000000000009e5d
Faulting process id: 0xf18
Faulting application start time: 0x01ce3c6ce70ee3f8
Faulting application path: C:\Users\My_User\AppData\Local\Apps\2.0\VJ12169A.3AG\6445EVK6.26Y\wmsd..tion_9fb3931a66281a0b_0004.0000_68586becb8f48f17\CompanyProductManager.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: 2588c97b-a860-11e2-be7c-3cd92b4a0af4

The second error with source ".NET Runtime"

Application: CompanyProductManager.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileLoadException
Stack:
   at CompanySI.CompanyProduct.CompanyProductManager.App.OnStartup(System.Windows.StartupEventArgs)
   at System.Windows.Application.<.ctor>b__1(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Application.RunInternal(System.Windows.Window)
   at System.Windows.Application.Run()
   at CompanySI.CompanyProduct.CompanyProductManager.App.Main()
dmck
  • 7,801
  • 7
  • 43
  • 79
  • I had a similar error like your first "ApplicationError". silent tone´s answer below helped me to fix my problem. So I had to enable verification skipping because my assemblies were only signed with public key and get delay signed later. – donttellya Apr 10 '14 at 14:44
  • Looks similar to this.. http://stackoverflow.com/questions/7450634/system-io-fileloadexception-when-running-c-sharp-program-on-a-different-computer – Mick Aug 14 '14 at 00:07
  • and this... http://community.sharpdevelop.net/forums/t/21717.aspx ..got a corrupt hard disk or ssd? – Mick Aug 14 '14 at 00:09
  • or this .... http://blogs.msdn.com/b/shawnfa/archive/2009/06/08/more-implicit-uses-of-cas-policy-loadfromremotesources.aspx – Mick Aug 14 '14 at 00:10
  • Are you running the application from a folder that needs to be unblocked? http://stackoverflow.com/questions/11464051/unblocking-all-the-assembly-files-in-a-folder Are you running the application from a network folder? – Mick Aug 14 '14 at 00:20
  • Try adding a catch for that specific exception...so you can capture the "FileName".......so you have a better idea. " catch(System.IO.FileNotFoundException fnfex) { string x = fnfex.FileName; /*Log it somewhere */ } – granadaCoder Jun 15 '15 at 16:01

2 Answers2

2

Loading a delay signed assembly on a machine where verification skipping has not been enabled can cause a similar error.

silent tone
  • 539
  • 7
  • 12
0

Just a guess, but I've seen a corrupt user.config file do something like this before with another application. That was a while back and I don't remember exactly what the exception was that was thrown. Check if you have one in the AppData directory (or elsewhere) and remove it.

Steve
  • 6,334
  • 4
  • 39
  • 67