I try to deploy a Click Once Installer but run into a very strange issue:
The installer runs fine but as soon as the application is supposed to start it crashes with the following message
[MyApp] has encountered a problem and needs to close. We are sorry for
the inconvenience.
and no useful information about the cause. As soon as I install Visual Studio Professional 2012 on the same machine, the application starts fine but sometimes behaves very strange (e.g. I have to click to red close button twice to close the application). Funny enough, the problem not always appears, I suspect it has something to do with the order in which I install the .Net Framework/Visual Studio/the Click Once installer.
I am pretty much lost here .....
Btw: The framework targetVersion and supportedRuntime of the Click-Once installer are 4.0 and 4.0.30319 respectively.
Add an UnhandledException handler to your app. This will allow you to see the exception that is causing the crash.
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
static void MyHandler(object sender, UnhandledExceptionEventArgs e)
{
Exception ex = (Exception)e.ExceptionObject;
MessageBox.Show("Unhandled domain exception:\n\n" + ex.Message);
}
Note that the use of MessageBox is only for debugging. A logging system should be used for your release version.
Related
I'm running an WPF application on a different computer than I am developing it on. Currently I am only using the files from Debug instead of Release. I notice that when I run an application made in Windows Forms, a JIT debugging window shows up when an unhandled exception occurs. This is not the case for my WPF application though. I've check my visual studio settings and I have JIT enabled. Installing visual studio on the computer where the application needs to run is not really possible. Is there a way I can get the JIT debugging window to show up? I am having a real pain in trying to figure out what is going on when the application crashes and doesn't give me any information about it.
So I've not been able to replicate the windows form unhandled exception window but I've got the next best thing using this article:
https://www.wpf-tutorial.com/wpf-application/handling-exceptions/
Adding the following code into app.xaml
DispatcherUnhandledException="Application_DispatcherUnhandledException"
And the following code into app.xaml.cs
public partial class App : Application
{
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show("An unhandled exception just occurred: " + e.Exception.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning);
e.Handled = true;
}
}
I get a MessageBox telling me what the error is. It also handles the exception and allows the application to continue running.
Using Visual C# 2010 Express, when I throw an exception it takes about minute and a half for the debugger to break on a user unhandled exception. During this time the application I'm debugging and visual studio are completely unresponsive and VCSExpress.exe processor usage jumps to 12-14%. The rest of the computer (mouse, other applications, etc.) remains responsive.
Visual studio isn't completely unusable but it is definitely slowing my application down when running from the debugger. I haven't been able to find the real source of the slowdown yet. This happens right at startup and isn't a problem that gets worse over time.
I have disabled my antivirus (eset nod32 v7) and do not have any extensions installed. My CPU is an Intel Core i7 740QM # 1.73GHz (quad-core hyperthreaded). OS is Windows 7 Professional. I've updated Visual C# 2010 Express to SP1 (Version 10.0.40219.1 SP1Rel). My hard disk shows no warning signs via S.M.A.R.T.
I have two extremely simple test scenarios written in WPF. In the first scneario I simply throw an exception when the button is clicked:
private void button1_Click(object sender, RoutedEventArgs e)
{
throw new InvalidOperationException();
}
I manually measured the time between when I click the button and when Visual Studio displays the thrown/user unhandled exception dialogue box (and thus becomes responsive again). I tested the timing for breaking on thrown versus user-unhandled exceptions when, with and without antivirus (AV), and with and without the Visual Studio Hosting Process (VS):
Debug, Unhandled, AV on -- 1:35.3, 1:38.0
Debug, Thrown, AV on -- 0:10.4, 0:11.5, 0:11.1
Debug, Thrown, AV off -- 0:10.7
Release, Thrown, AV off -- 0:9.1, 0:10.0
Release, Unhandled, AV off -- 1:34.5
Release, Thrown, AV off, No VS Hosting -- 0:8.9, 0:9.1
Release, Unhandled, AV off, No VS Hosting -- 1:19.6, 1:20.9
When breaking on unhandled exceptions, it takes 1:30 (1 minute, 30 seconds) to recover. Antivirus makes no difference. Taking away VS Hosting saves around 15 seconds. Release mode saves about 1 second. Switching to breaking on thrown exceptions has significant savings (10 seconds to recover), though this still is not acceptable.
My second test scenario is for timing a caught exception inside and outside of Visual Studio:
private void button2_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Stopwatch sw = new Stopwatch();
sw.Start();
try
{
throw new InvalidOperationException();
}
catch { }
sw.Stop();
label1.Content = string.Format("{0:0.000} seconds", sw.ElapsedMilliseconds / 1000.0);
}
For this scenario, I set VS to break only on unhandled exceptions so I could get timing data for simple caught exceptions. I ran this in VS and outside of VS as the stand-alone EXE:
Release, Unhandled, AV off, No VS Hosting -- 0:1.965, 0:1.812, 0:1.985
Debug, Unhandled, AV off, No VS Hosting -- 0:2.333, 0:2.136, 0:2.305
Release EXE, AV off -- 0:0.002, 0:0.000, 0:0.000
Debug EXE, AV off -- 0:0.002, 0:0.000, 0:0.000
Outside of VS there is no slowdown. Inside of VS this takes about 2 seconds, which still seems pretty excessive for a quad core hyperthreaded CPU and a tiny try/catch block.
I'm pursuing some of the leads in the linked questions (system environment settings, etc.) and monitoring the file system/disk activity to see if I can get any leads. Any additional help is much appreciated!
btw, I'd prefer not to re-install Visual Studio or my OS
Thanks!
Update
I've installed VS 2012 Express, and the numbers are:
Test 1:
Debug, Unhandled, AV off -- 0:01.6
Debug, Thrown, AV off -- 0:01.1
Test 2:
Debug, VS Hosting -- 0:1.202
Debug, No VS Hosting -- 0:1.191
Release, VS Hosting -- 0:1.220
The numbers in VS2012 are much better. Clearly one solution to my problem is upgrading to VS2012, which is what I'm planning on doing. But I'd still like a resolution to this problem if anyone has any ideas.
I just got some feedback of some users of our application, they have got issues on windows XP with our application. This application works fine on Windows 7, but not on Windows XP.
One other strange thing: If I build this on a Windows XP workstation(with VS2010), it works on my local workstations, and if I put this build on another XP workstation, it doesn't work anymore.
When running on XP, I just got an error telling me that XXXXX has encountered a problem and needs to close. We are sorry for the inconvenience.
I found in the EventViewer Application's log this stacktrace:
Application: MyApplication.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
at System.Windows.Forms.UnsafeNativeMethods+IOleObject.DoVerb(Int32, IntPtr, IOleClientSite, Int32, IntPtr, COMRECT)
at System.Windows.Forms.WebBrowserBase.DoVerb(Int32)
at System.Windows.Forms.WebBrowserBase.TransitionFromRunningToInPlaceActive()
at System.Windows.Forms.WebBrowserBase.TransitionUpTo(AXState)
at System.Windows.Forms.WebBrowserBase.OnParentChanged(System.EventArgs)
at System.Windows.Forms.Control.AssignParent(System.Windows.Forms.Control)
at System.Windows.Forms.Control+ControlCollection.Add(System.Windows.Forms.Control)
at My.NameSpace.Here.Controls.LearningCenterControl.InitializeComponent()
at My.NameSpace.Here.Controls.LearningCenterControl..ctor()
at My.NameSpace.Here.MainForm.InitializeComponent()
at My.NameSpace.Here.MainForm..ctor()
at My.NameSpace.Here.MainForm.get_Instance()
at My.NameSpace.Here.Program.Main(System.String[])
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
This happens on the InitializeComponent of the designer of one of my userControl:
this.m_learingResourceBrowser = new System.Windows.Forms.WebBrowser();
I guess there a Security issue with XP, but what?
I found this:
REM Mark project as DEP Noncompliant
call "$(DevEnvDir)..\..\VC\bin\vcvars32.bat"
call "$(DevEnvDir)..\..\VC\bin\editbin.exe" /NXCOMPAT:NO "$(TargetPath)"
I've put this Post-build event on the exe project, but I didn't saw any improvement
I've also tried to run directly the command with my exe:
editbin.exe /NXCOMPAT:NO YourProgram.exe
Any idea about what could cause this issue?
EDIT
I found this answer which states:
To test if its a DEP issue do this.
Right click on "My Computer" Select "Properties" and "Advanced" Under
"Startup and Recovery, click Settings Now click on "Edit" The notepad
has just begun. Simply replace the line: Code: noexecute optionn by
AlwaysOff Restart your PC to complete the transaction.
And I after this I don't have this error anymore. So my question is: currently I've done the previous operation only on the main exe. Should I do this operation on all dll? Because my project is composed of more than 230 projects, so it would be hard to test everything.
I've been developing a game and after each update I send my friend a setup.exe to use I made with Inno Setup. It's always worked fine up until now. He is able to instal the game but when he runs the .exe he gets "Game has stopped working". While it works fine for me after installing. The only thing I can think of that could of caused this was I added saving and loading using storage containers. I choose the location to save in with:
asyncResult = StorageDevice.BeginShowSelector(playerIndex, null, null);
storageDevice = StorageDevice.EndShowSelector(asyncResult);
asyncResult = storageDevice.BeginOpenContainer("Game1StorageContainer", null, null);
This places the file in: Desktop\Libraries\Documents\SavedGames\Game\Game1StorageContainer\Player1\
This is a vague question but maybe someone has an idea?
:: UPDATE ::
Ok, I've had my friend reinstall the XNA Runtime, same problem.
There are no files in his minidump folder, even with hidden folders shown.
However I have a windows error log here:
Application: My Game.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info:Microsoft.Xna.Framework.GamerServices.GamerServicesNotAvailableException
Stack:
at Microsoft.Xna.Framework.GamerServices.KernelMethods+ProxyProcess..ctor(Microsoft.Xna.Framework.GamerServices.UserPacketBuffer)
at Microsoft.Xna.Framework.GamerServices.KernelMethods.Initialize(Microsoft.Xna.Framework.GamerServices.UserPacketBuffer)
at Microsoft.Xna.Framework.GamerServices.GamerServicesDispatcher.Initialize(System.IServiceProvider)
at Microsoft.Xna.Framework.GamerServices.GamerServicesComponent.Initialize()
at Microsoft.Xna.Framework.Game.Initialize()
at My_Game.Game1.Initialize()
at Microsoft.Xna.Framework.Game.RunGame(Boolean)
at Microsoft.Xna.Framework.Game.Run()
at My_Game.Program.Main(System.String[])
So, It crashed at Game1.Initialize();, which contains:
protected override void Initialize()
{
this.graphics.PreferredBackBufferWidth = 800;
this.graphics.PreferredBackBufferHeight = 600;
this.graphics.IsFullScreen = false;
this.graphics.ApplyChanges();
base.Initialize();
}
So surely it is the base.Initialize();, which I'm guessing is because I've included some new libraries from the framework. So I have no idea what to do, the previous version of my game works fine for him.
Someone have any idea what I can do?
Thanks
Does he have the XNA Runtime installed?
Check the Windows Event Log, it should have a detailed entry for the crash
When an application crashes, a minidump is created. You should be able to load this into visual studio and see where it crashed.
As the title says, VS2008 keeps crashing on me whenever I debug a project when a certain form is open. I attached another VS2008 instance to it and found the following exception to be the culprit:
System.Runtime.InteropServices.COMException occurred
Message="Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"
Source="mscorlib"
ErrorCode=-2147418113
StackTrace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.NativeMethods.ThrowOnFailure(Int32 hr, Int32[] expectedHRFailure)
InnerException:
The problem I'm having is that I have no idea why this would happen. We use a few COM components (this is an old version of software I'm updating), but they don't cause any exceptions when the program is actually running, or when viewing design view normally. Only when I debug when the form is open. The program itself runs fine when debugging after VS's crash, but Visual Studio itself is hosed.
I know the simplest answer is to "make sure that form is closed!" but it takes forever to load and it's a much smoother workflow to keep it open (plus, I don't always remember to close it!)
So, has anyone run into this? Does anyone have any ideas why this might be happening?
You could try to 'refresh' you IDE istallation by command line:
devenv.exe /setup
/setup - Forces Visual Studio to merge resource metadata that describes menus, toolbars, and command groups, from all VSPackages available.
or run it with detailed logging to see what's happened:
devenv.exe /log
/log - Starts Visual Studio and logs all activity to the log file.
See MSDN: Devenv Command Line Switches for the rest of supported Visual Studio IDE switches