Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Created WPF application doesn't start

Tags:

c#

wpf

I created a C# WPF application with Visual Studio 2015. On my computer everything works fine. But no one else can start the application. Even only with the .exe, the .exe in the Debug folder or when I publish the software and they install it.

I tried a few things:

The software needs a special folder on the desktop to work; I tried this out and it builds the path with Environment.GetFolderPath(Environment.SpecialFolder.Desktop) so this won't cause the problem.

Additionally I use a database in my program but I declared the database in the code and tried it on my own pc by cutting the network connection. It works, so the missing connection is not the problem. The program has a navigation window with three pages, so I made this

public MainWindow()
{           
    try
    {
        InitializeComponent();
    }
    catch (Exception ex) {
        MessageBox.Show(ex.InnerException.ToString());
    }
}

but no MessageBox is shown. Even the thread can´t be found in the task manager. It seems that it doesn't start. The OS on all the PCs is Win 10.

Does anyone know what the issue here is?

EDIT:

I found the following error message in the Windows Event Viewer.

System.IO.FileNotFoundException

bei MMS.CustomAcrobatCtrl.InitializeComponent()

bei MMS.CustomAcrobatCtrl..ctor()

bei MMS.WpfAcrobatCtrl..ctor()

I made a custom PDF viewer and it seems that it can´t be loaded for some reasons, or am i wrong?

like image 782
Only3lue Avatar asked Nov 17 '16 08:11

Only3lue


2 Answers

You should check the Windows Event Viewer logs for any .NET Runtime related logged issues.

Otherwise, you should add the event handlers for the following events in your App.xaml.cs.

AppDomain.CurrentDomain.UnhandledException
Application.Current.DispatcherUnhandledException
TaskScheduler.UnobservedTaskException

You can do the same thing you are doing now - showing a MessageBox except rather use ex.ToString() instead of ex.InnerException.ToString() as often ex.InnerException is null.

like image 169
toadflakz Avatar answered Oct 17 '22 04:10

toadflakz


I know this is an old issue, but a I faced the same problem. The following solution gave me more information to pinpoint my problem.

  1. Right click your application and choose properties
  2. In the application tab change the output type to Console application
  3. Build your application in debug mode
  4. Start your application again

Your application now starts with a console window (CMD.exe). If there is an exception, this will be showed in the console window. The exception shows line numbers and module names as well.

like image 42
DaanH Avatar answered Oct 17 '22 04:10

DaanH