I'll give you the wix, the installer code, and the usage all side by side:

.wxs fragment:

<Component Id="MyApp" Guid="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" KeyPath="yes">
        <File Name="$(var.MyApp.TargetFileName)" 
Source="$(var.MyApp.TargetPath)" DiskId="1" />
        <File Name="$(var.MyApp.TargetName).pdb" 
Source="$(var.MyApp.TargetDir)$(var.MyApp.TargetName).pdb" DiskId="1" />
        <util:PerformanceCategory Id="MyAppCategory" Name="My Application" 
Help="Custom performance counters for my application." MultiInstance="yes">
                <util:PerformanceCounter Name="My First Counter" Help="The 
first custom counter for my application." Type="numberOfItems64" />
        </util:PerformanceCategory>
</Component>


.cs fragment (installer):
PerformanceCounterInstaller category = new PerformanceCounterInstaller();
category.CategoryName = "My Application";
category.CategoryHelp = "Custom performance counters for my application.";
category.CategoryType = PerformanceCounterCategoryType.MultiInstance;
CounterCreationData counter = new CounterCreationData();
counter.CounterName = "My First Counter";
counter.CounterHelp = "The first custom counter for my application.";
counter.CounterType = PerformanceCounterType.NumberOfItems64;
counterInstaller.Counters.Add(counter);


.cs fragment (usage):

PerformanceCounter counter = new PerformanceCounter();
counter.CategoryName = MyApp.CounterCategoryName;
counter.CounterName = MyApp.FirstCounterName;
counter.InstanceName = newInstanceName;
counter.InstanceLifetime = PerformanceCounterInstanceLifetime.Process;
counter.ReadOnly = false;
counter.Increment(); // This throws InvalidOperationException

-----Original Message-----
From: Sebastian Brand (Instyler Software) [mailto:wix+us...@instyler.com] 
Sent: Wednesday, November 18, 2009 9:25 PM
To: General discussion for Windows Installer XML toolset.
Subject: Re: [WiX-users] Errors using performance counters after installing 
with PerformanceCounter/PerformanceCounterCategory

Can you give us the corresponding .wxs code?

Best regards,
Sebastian Brand

Deployment consultant
E-Mail: sebast...@instyler.com

Instyler Setup - Creating WiX-based MSI installations, elegantly.
http://www.instyler.com

On 18.11.2009, at 21:13, Rich Daniel wrote:

> I'm in the process of migrating my app installation to wix. It's a .NET 2.0 
> app that currently uses installutil to add some custom performance counters 
> and event log sources. Seeing as how I noticed that WixUtilExtension.dll 
> supplies this functionality from the installer, I thought I'd give it a try 
> instead.
> 
> I'm rubbing up against an issue, however. The installation completes just 
> fine, but the moment my app attempts to modify a counter, it goes bang with 
> the following exception:
> 
> System.InvalidOperationException: PerformanceCounterInstanceLifetime.Process 
> is not valid in the global shared memory.  If your performance counter 
> category was created with an older version of the Framework, it uses the 
> global shared memory.  Either use PerformanceCounterInstanceLifetime.Global, 
> or if applications running on older versions of the Framework do not need to 
> write to your category, delete and recreate it.
> 
> If I believe that error, the way I've defined the counters in my wxs file 
> installs them in the global shared memory (or uses the .NET 1.* approach to 
> install them). Is there a way to tell it to do things the new way instead of 
> the old or should I give up for now and just have some custom actions call 
> installutil once the bits land on the box?
> 
> Thanks
> - Rich Daniel
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to