创建的 WPF 应用程序无法启动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40649949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Created WPF application doesn't start
提问by Only3lue
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.
我使用 Visual Studio 2015 创建了一个 C# WPF 应用程序。在我的电脑上一切正常。但没有其他人可以启动该应用程序。即使只有 .exe、Debug 文件夹中的 .exe 或当我发布软件并安装它时。
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.
该软件需要在桌面上有一个特殊的文件夹才能工作;我试过了,它建立了路径,Environment.GetFolderPath(Environment.SpecialFolder.Desktop)所以这不会导致问题。
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 MessageBoxis 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.
但没有MessageBox显示。甚至在任务管理器中也找不到线程。好像还没有开始。所有PC上的操作系统都是Win 10。
Does anyone know what the issue here is?
有谁知道这里的问题是什么?
EDIT:
编辑:
I found the following error message in the Windows Event Viewer.
我在 Windows 事件查看器中发现了以下错误消息。
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?
我制作了一个自定义 PDF 查看器,但由于某些原因似乎无法加载它,还是我错了?
回答by toadflakz
You should check the Windows Event Viewer logs for any .NET Runtime related logged issues.
您应该检查 Windows 事件查看器日志中是否有任何与 .NET 运行时相关的记录问题。
Otherwise, you should add the event handlers for the following events in your App.xaml.cs.
否则,您应该在您的App.xaml.cs.
AppDomain.CurrentDomain.UnhandledException
Application.Current.DispatcherUnhandledException
TaskScheduler.UnobservedTaskException
You can do the same thing you are doing now - showing a MessageBoxexcept rather use ex.ToString()instead of ex.InnerException.ToString()as often ex.InnerExceptionis null.
你可以做你现在正在做的同样的事情 - 显示一个MessageBoxexcept 而是使用ex.ToString()而不是ex.InnerException.ToString()经常ex.InnerException是null。

