views:

54

answers:

2

When I deploy my app on other machines, this error comes up:

alt text

Now if I uninstall my app and re-install it, the error message does not come up. Has anyone else encountered this? I cant make sense of the stack trace either.

+2  A: 

Problems of this kind usually are of the following kind:

  • not all components are installed: Make sure that all third-party components and other pre-requisites are included in your setup and get correctly setup. This includes COM objects, runtime libraries etc.

  • differences in configuration: Make sure you include all relevant configuration in your setup.

  • 32-bit vs. 64-bit issues: If your code has dependencies to native 32-bit libraries/COM components you need to compile it with the platform target set to x86

  • features not supported on the platform (usually not the case for pure .NET applications and more a problem with older operation systems)

  • problems with elevation (also a bit more unlikely in your case as you seem to be on XP)

My feeling tells me that you probably use certain third-party controls for displaying reports in your application. Are you sure that these controls are installed on the target machine?

0xA3
+2  A: 

The diagnostic indicates that the native CreateWindowEx() API function failed. There are very few reasons for it to fail, the most common one is a gross mistake in the window procedure for the window. That certainly is not the case for the Form class, I've only ever seen Windows Forms programs fail with this error because the process exceeded its handle quota.

To explain that is going to require some hand waving. First off, by default a Windows process is only allowed to create 10,000 handles, GDI objects and user32 objects. It is of course very unlikely that your program consumed that many right at start up. Seeing this happen when it is started by the installer is however a lead. Msi.exe gets special dispensation, it is allowed to create many more handles. I've seen it do this, the VS2008 service pack 1 installer I ran on an old unpatched version of XP got up to 500,000 handles about 2 hours after I started it before it decided a reboot was necessary to complete the install.

Your installer would use CreateProcess() to start the program. It has an argument named bInheritHandles that determines whether or not the child process inherits the handles of the parent process. A possible scenario is thus that the installer consumes many handles, and that it has the bInheritHandles argument set to TRUE. Your WF program would then start with its handle quota already exceeded, creating another handle will fail. The SetVisibleCore() method is indeed the one that creates the main form's Handle property.

This is all conjecture of course, you should be able to see this for yourself with Taskmgr.exe, Process tab while the process is displaying the exception dialog. Use View + Select Columns and tick Handles, GDI Object and USER objects. An ultimate fix is going to require finding out why the installer is consuming so many handles. Or using a different way to start the program.

Hans Passant
Hmmmm. I might have to look in on this some more, because the error message only happens on certain machines. Thanks for the advice.
broke