views:

26

answers:

1

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: http://stackoverflow.com/questions/2420280/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.

+1  A: 

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.

STW
>_<You're right! Thanks for helping out a newbie. Turns out one of my schemas wasn't set to build as Content, so XmlReader was going nuts.
bearcdp