Hi Shawn,

DTF's FeatureInfo class uses the MsiGetFeatureInfo API to retrieve the 
feature's attributes, title, and description. According to MSDN ( 
http://msdn.microsoft.com/en-us/library/aa368612.aspx ), MsiGetFeatureInfo is 
on the list of functions that "must never be called from a custom action". 

Therefore, DTF does not include that function in the set of native APIs that 
get remoted over the IPC channel between the managed CA process and the 
installer session. Calling any non-remoted APIs with a CA session handle always 
results in an InvalidHandleException because you are calling with a remote 
handle.

Perhaps MsiGetFeatureInfo should be smart enough to recognize when it's being 
called from the context of a CA and then query those values from the database 
instead of using MsiGetFeatureInfo, but it doesn't do that now. As a workaround 
you can do that query yourself, as you have done.

The FeatureInfo.GetCost() method should work from within a CA, since the 
MsiGetFeatureCost API does get remoted. So there might be a bug in that method. 
When I get a chance, I'll try to add a test case to verify GetCost().

-Jason-

-----Original Message-----
From: Shawn Dwyer [mailto:shawn.o.dw...@gmail.com] 
Sent: Tuesday, March 03, 2009 8:57 AM
To: General discussion for Windows Installer XML toolset.
Subject: [WiX-users] DTF Session object properties

Hi,

I'm trying to put together a simple managed custom action using DTF which
will show each of the features, their descriptions, and their cost.  It
seemed straight forward enough


string msg = "";

foreach (FeatureInfo fi in session.Features)

{

msg += string.Format

(

"Title: {0}\r\nDescription: {1}\r\nCost: {2}\r\n\r\n",

fi.Title,

            fi.Description,

            fi.GetCost(false, true, InstallState.Local)

      );

}

MessageBox.Show(msg,"Features");

However, fi.Title thows the exception:

System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. --->
Microsoft.Deployment.WindowsInstaller.InvalidHandleException: The handle is
invalid.
   at Microsoft.Deployment.WindowsInstaller.FeatureInfo.get_Title()

I get a similar error for fi.Description.  For fi.GetCost for one of my 3
features it returns 0, for the others it returns -1099511627776 (=-1TB).
I'm probably missing something obvious here but I can't seem to put my
finger on it.  I have my custom task scheduled as follows:

<InstallUISequence>

      <Custom Action="ShowFeatures" After="CostFinalize" />

</InstallUISequence>

Any ideas?

I am able to query the title and description directly with View v =
Session.Database.OpenView("SELECT * FROM Feature ORDER BY Display");  I am
also able to access FeatureInfo.RequestState and FeatureInfo.CurrentState
without exception.

Thanks,

Shawn


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to