Ent Lib 2.0 Performance Counters causing Install issues

Topics: Enterprise Library Core
Jul 20, 2007 at 1:05 PM
I've been using EntLib 2.0 for some time for Logging and Data Access, but I decide I needed to add some Perf Counters so I added an 'Instrumentation' folder to my project.

I added an 'Installers.Add(new ReflectionInstaller<PerformanceCounterInstallerBuilder>)' to the ProjectInstaller.

Now if I run the VS Setup project that builds the Setup for my project I get an error and the install fails, but if I run InstallUtil on the EXE it works. The counters are registered. I had to run InstallUtil against the Logging assembly also.

Finally when I run my application I can see the logging perf values and display them in the Monitor, but my custom counters can't be displayed as it seems as if it's not associating them with the instance of my app.

Can anyone explain what's going on here?
Jul 20, 2007 at 2:20 PM
Hi Robert,

Can you describe your situation with more detail? I understand you're creating your own performance counters, and you're relying on entlib's reflection installer. You created an instrumentation folder and I assume you created a ProjectInstaller class as wll, but you don't mention wether you have classes with the attributes required by entlib's ReflectionInstaller and PerformanceCounterInstallerBuilder: HasInstallableResourcesAttribute, PerformanceCountersDefinitionAttribute and PerformanceCounterAttribute. Without such classes the installers will perform no actions, but it will not signal an error; when you run installutil on the EXE do you get an output describing the creation of the perf counters similar to the output when running installutil on the logging assemly? Btw, installutil must be run on each assembly defining instrumentation; running on the EXE alone will not install the referenced assemblies.

You also mention that you can't see the counters when you run the application; how are these custom counters managed at runtime? The same classes that should have the attributes required by the installer should create and update the performance counters, and should be instantiated by your application either directly or through the instrumentation features provided by entlib and used in the blocks.

Finally, you mention an error when running the setup created by VS but you don't describe the nature of the error so it's hard to understand the problem. Can you provide additional information? For MSI related issues it's best to run the MSI through msiexec with logging enabled and look for the error entries; running msiexec with no parameters will show the reference for the switches.

Jul 20, 2007 at 4:41 PM
AH!! I think the problem is that the object I want to instrumentate hasn't been created through the ObjectBuilder mechanism. I've only been using the logging and data assemblies and my main objects are created from basic C# classes rather than built from a factory. What I noticed was the 'binder class' wasn't getting called and following that trail I noticed that it's called during the Object build. That would explain a few things.
Jul 20, 2007 at 11:12 PM
OK, I now have an object created with ObjectBuilder and I can see the counters being updated, but if I add the Installers.Add(...) line to the ProjectInstaller the Setup still failswith an "Error during the Commit Phase".

Any ideas what that's about? I assume it's got something to do with either ther ProjectInstaller class or the base ProjectInstaller class. I've tried to debug this but I can't find a place to set a breakpoint.

Jul 21, 2007 at 2:16 PM
Hi Robert,

You need to provide information about the actual error; the generic "Error during the Commit Phase" is not enough to determine the cause of the failure. Installutil usually does a decent job with the output of diagnostic information.
Btw, how do you get to update the counters if the install fails?

You don't need to use ObjectBuilder to create the object in order to get instrumentation; ObjectBuilder will just wire up the instrumentation listener to your object based on metadata, but you can wire it up yourself if necessary.

Jul 21, 2007 at 3:34 PM
'InstallUtil' works just fine, it's the VS Setup Project that fails with the 'commit' error. I've tried attaching to the process and setting breakpoints, but nothing breaks!! I suspect that as everything is packaged inside the MSI, VS can't hook the code(?)

As I said; it's the Installers.Add(...) that causes the problem.

How do you 'wire up' the instrumentation without ObjectBuilder?
Jul 21, 2007 at 7:39 PM

Regardless of the source of the source of the error, a generic "Error during the Commit Phase" message does not contain enough information to understand the problem. If executing the MSI is causing the error then run msiexec with logging enabled as described previously and look for a description of the specific problem (depending on the logging settings, you may need to scan through a lot of diagnostics information).

I understand that the single "Installers.Add(...)" change is causing the MSI to go from working to failing. This line is of course necessary for the perf counters to be created by installutil, and it would be strange that the MSI is failing without executing the code. In order for this to run the MSI must have a custom action running installutil. How did you configure such an action? This action needs to run with elevated privileges, so it needs to be properly configured when creating the MSI; an improperly configured action could explain the failure. You can try creating a repro MSI with just an application and a project installer, without real instrumentation classes, and see if it fails.

Regarding wiring up instrumentation, you can follow the full pattern used for enterprise library (objects build with object builder and a pair of provider/listener objects for dealing with instrumentation) or just have your application invoke the instrumentation APIs. You would likely use the former if you want the configuration based, decoupled approach. You can browse the code in class InstrumentationAttachmentStrategy for details on how wiring up happens in EntLib; you might be able to reuse some of the building blocks, like the binders, in your code.

Jul 22, 2007 at 6:10 PM
Thanks for the help.

I did run msiexec and looked at the log, but it didn't really tell me why it had failed.

Action 18:39:10: RollbackCleanup. Removing backup files
MSI (s) (D4:F4) 18:39:10:046: Creating MSIHANDLE (12) of type 790536 for thread 756
MSI (s) (D4:60) 18:39:10:046: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI1418.tmp, Entrypoint: ManagedInstall
MSI (s) (D4!48) 18:39:10:062: Creating MSIHANDLE (13) of type 790531 for thread 3912
DEBUG: Error 2835: The control ErrorIcon was not found on dialog ErrorDialog
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2835. The arguments are: ErrorIcon, ErrorDialog,
Error 1001. Error 1001. An exception occurred during the Commit phase of the installation. This exception will be ignored and installation will continue. However, the application might not function correctly after installation is complete. --> The savedState dictionary contains inconsistent data and might have been corrupted.
MSI (s) (D4!48) 18:39:14:546:
MSI (s) (D4:60) 18:39:14:546: Leaked MSIHANDLE (13) of type 790531 for thread 3912
MSI (s) (D4:60) 18:39:14:546: Closing MSIHANDLE (13) of type 790531 for thread 3912
MSI (s) (D4:60) 18:39:14:546: Note: 1: 2769 2: 4B81558F45F544AA8747_05C7EECECA16.commit 3: 1
DEBUG: Error 2769: Custom Action 4B81558F45F544AA8747_05C7EECECA16.commit did not close 1 MSIHANDLEs.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2769. The arguments are: 4B81558F45F544AA8747_05C7EECECA16.commit, 1,
MSI (s) (D4:60) 18:39:14:546: Closing MSIHANDLE (12) of type 790536 for thread 756
MSI (s) (D4:F4) 18:39:14:546: Executing op: Header(Signature=1397708873,Version=301,Timestamp=922129627,LangId=1033,Platform=0,ScriptType=2,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=1)

I'm running everything as Administrator on an XP system.

I haven't go a custom action in the setup. I can't see how to add one; the Visual Studio setup project doesn't seem to have an option to execute another program which looks like I'll have to use something like InstallShield.
Jul 23, 2007 at 3:02 PM

I suggest you try to repro it by building a minimal application and adding features from there (i.e. start with a clean project, add an installer class, add installers to the installer class, add a class with the attributes used by the reflection based installers, etc), and probably try a different machine as well. I tried it with a new winforms app, adding a project installer class and creating a setup project with just the output of the winforms project and I didn't see the failure you describe, so there must be something else involved.

Btw, You do get an error message from custom action 4B81558F45F544AA8747_05C7EECECA16. You should use some MSI editing tool like Orca to see what is this custom action doing (and try to figure out how it got there...)

Oct 25, 2010 at 12:08 PM

Hi all, in three years.


Installers.Add(new ReflectionInstaller<PerformanceCounterInstallerBuilder>)


Installer refInstaller = new ReflectionInstaller<PerformanceCounterInstallerBuilder>();