Is your reading custom action supposed to be deferred (ran as system) or run 
under the user context? I am assuming it's deferred, in which case you want to 
add a :

<CustomAction Id="CA_CreateTitusDatabase.SetProperty" 
Property="CA_CreateTitusDatabase" 
Value="DATABASE_CREATE_SCHEMA=[DATABASE_CREATE_SCHEMA]" />

And then schedule this CA to be ran before your CA:

<Custom Action='CA_CreateTitusDatabase.SetProperty' Before=' 
CA_CreateTitusDatabase'>NOT Installed OR FirstInstall OR 
REINSTALL="ALL"</Custom>

Jacob

-----Original Message-----
From: StevenOgilvie [mailto:sogil...@msn.com] 
Sent: Friday, September 14, 2012 4:09 PM
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] MSI property not being read in via custom action?

Hi,

I have a property being set to 0 at start in product.wxs <Property 
Id="DATABASE_CREATE_SCHEMA" Secure="no" Value="0"/>

In a C# custom action I set it to 1:
SetSessionProperty(session, "DATABASE_CREATE_SCHEMA", "1");

where SetSessionPropertyis:
 private static void
SetSessionProperty(Microsoft.Deployment.WindowsInstaller.Session session, 
string propertyName, string value)
        {
            try
            {
                session[propertyName] = value;
           }
            catch (Exception ex)
            {
                WriteErrorLogInstall(session, "Exception when executing 
SetSessionProperty.", ex, true);
            }
        }
the above is done during the "dialog" viewing stage...

I call this custom action:
<Custom Action="CA_CreateTitusDatabase" After="PublishProduct">NOT 
Installed</Custom>
    </InstallExecuteSequence>

in another custom action (same C# custom action dll) I read the property:
string createDatabaseSchema = GetSessionProperty(session, 
"DATABASE_CREATE_SCHEMA", true); MessageBox.Show("DATABASE_CREATE_SCHEMA is: " 
+ createDatabaseSchema);

where GetSessionProperty is:
private static string
GetSessionProperty(Microsoft.Deployment.WindowsInstaller.Session session, 
string propertyName, bool isCustomActionData)
        {
            string sessionProperty = "";

            try
            {
                if (isCustomActionData)
                {
                    sessionProperty =
session.CustomActionData[propertyName];
                }
                else
                {
                    sessionProperty = session[propertyName];
                }
            }
            catch (Exception ex)
            {
                WriteErrorLogInstall(session, "Exception when executing 
GetSessionProperty.", ex, true);
            }
            return sessionProperty;
        }

The messagebox returns a blank value, meaning the property isn't being set 
properly or read in properly?

Anybody know why?

Steve





--
View this message in context: 
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/MSI-property-not-being-read-in-via-custom-action-tp7580545.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to