ClickOnce,我的应用程序崩溃 Visual C# Express
我正在完成一个 C# 应用程序的工作,并希望制作一个 ClickOnce 安装程序。
现在,我只想确保安装程序可以正常运行,并且我能够在没有 Visual Studio 的情况下运行 exe。
因此,我将项目设置为需要 Windows Installer 和 .NET 3.5 SP1,并告诉它从供应商处下载(稍后我将包含这些组件,但不用于此测试)。它只是一个不需要更新的基本实用程序,因此我禁用更新并告诉它使用 CD/DVD 安装方法,因为我只想在本地运行它。当我运行生成的 setup.exe 时,我收到安装提示,并且 MyApp 出现在“添加/删除程序”中。但是,一旦安装程序完成,它就会崩溃并显示以下消息:
[MyApp] 遇到问题并且 需要关闭。我们很抱歉 带来不便。
当您尝试运行 .exe 时,会弹出相同的消息。安装期间不会创建“开始菜单”文件夹。我尝试完全取消创建安装文件,因此它只生成 .application 文件,但我仍然遇到相同的错误。
我错过了一些明显的东西吗?我的应用程序在发布配置中编译并运行得很好。 ClickOnce 是否不应该与常规 WinForms 应用程序一起使用?
这个问题: ClickOnce 发布后 WPF 应用程序崩溃 听起来与我的问题类似,但我使用的是 Windows 窗体,因此没有收到 XAML 异常。它只是拒绝运行。
I'm finishing up a C# app for work, and looking to make a ClickOnce installer.
Right now, I just want to make sure the installer works and that I am able to run the exe without Visual Studio.
So I set up my project to require Windows Installer and .NET 3.5 SP1, and tell it to download from a vendor (I'll be including the components later, but not for this test). It's just a basic utility that won't need updates, so I disable updates and tell it to use a CD/DVD install method since I just want to run it locally. When I run the resultant setup.exe, I get the installation prompt, and MyApp appears in Add/Remove Programs. But, as soon as the installer finishes it crashes with this message:
[MyApp] has encountered a problem and
needs to close. We are sorry for the
inconvenience.
The same message pops up when you try to run the .exe. No Start Menu folders are created during installation. I tried doing away with creating the setup file altogether so it just generated the .application file, but I still got the same error.
Am I missing something obvious? My app compiles in Release configuration and runs just fine. Is ClickOnce just not supposed to work with regular WinForms applications?
This question:
WPF application crash after ClickOnce publish
Sounds similar to my issue, but I'm using Windows Forms, and thus not getting an XAML exception. It just refuses to run.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个好的起点是为 AppDomain 添加处理程序。 UnhandledException 事件。这是当代码内部发生异常且未由 try/catch 块处理(或重新抛出且不再处理)时引发的事件。 .NET 在这种情况下的行为是关闭应用程序——从它的角度来看,存在失控错误。
在此事件处理程序中,您至少应该以确保在应用程序关闭之前写入错误的方式记录错误。这可能是一个非常初级的消息框,用于显示错误内容、写入文本文件或(最好)写入公共日志记录位置。
A good place to start is to add a handler for the AppDomain.UnhandledException event. This is the event which is raised when an exception occurs inside your code and is not handled by a
try/catch
block (or is re-thrown and never handled again). .NET's behavior in this condition is to close the application--from it's perspective there is a runaway error.In this event handler, you should--at a minimum--log the error in a manner that ensures it will be written before the application closes. This could be a very rudementary MessageBox to show the error contents, writing to a text-file, or (preferably) writting to a common logging location.