Click here to Skip to main content
15,889,900 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a .NET Framework WPF app that I've installed on a VM.
(Installer built with WiX.)
If I try to launch it, it fails without ever showing any UI.

From the Event Viewer I can see that the problem is a FileNotFoundException:
Application: MyApp.exe Framework Version: v4.0.30319 
Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException at MyApp.App.OnStartup(System.Windows.StartupEventArgs) ...

It runs OK on my development system, but with the full VS development environment, and third party libraries installed, I'm not surprised.
A second app that's installed together with it, works fine.

How can I find out which file is missing?

What I have tried:

I tried wrapping the entire body of the MyApp.App.OnStartup() in a try-catch, and writing a file with the exception info in the catch.
It never wrote the file.
I tried using System.Diagnostics.Trace.WriteLine at the beginning of the OnStartup(), and running DbgView as admin while launching the app.
I didn't get any messages.
I even tried to write a file at the entry to the OnStartup().
Nothing written.
Posted
Updated 19-Aug-21 21:56pm

One place to look is Windows Event Log. If the linked assembly cannot be found during startup, you should find the assembly name in the log.
 
Share this answer
 
Comments
Matt T Heffron 20-Aug-21 13:03pm    
The message that I included was from the Windows Event Viewer. It didn't include the NAME of the file that it couldn't find.
It's possible that the exception is being thrown when your App file is loaded, which means your OnStartup method won't be called. Try giving your application a custom entry point in a separate class, and wrapping that in an exception handler which logs the full exception details.
 
Share this answer
 
Comments
Matt T Heffron 20-Aug-21 13:12pm    
The stack trace in the Event Viewer information shows that the exception is being thrown from under the OnStartup():
Application: MyApp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
at MyApp.App.OnStartup(System.Windows.StartupEventArgs)
at System.Windows.Application.<.ctor>b__1_0(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
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 MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, 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 System.Windows.Threading.ExceptionWrapper.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 System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at MyApp.App.Main()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900