Nothing happens. The value does not get populated in the UI. It still shows the default value of 0.
But I am really just coding in the dark on this. I'm not sure what I am doing and not even sure I have everything correct. I just don't get the whole custom action concept and how properties get read and set? This was just a stab at what I thought would work. Jeff -----Original Message----- From: John Ludlow [mailto:john.ludlow...@gmail.com] Sent: Thursday, February 26, 2015 2:33 PM To: General discussion about the WiX toolset. Subject: Re: [WiX-users] using a custom action to read properties from a XML file When you say "not working", what do you mean exactly? Is it just not calling your CA, not finding the file, not getting any results, or is it throwing an exception? Here are some things you can try: Check whether there any evidence in the log that the custom action has been called, and what the CustomActionData is. Also, put a few session.Log calls in strategic places in the code to see where it's getting to. Try writing similar code in a console application and seeing whether it can load the XML file And of course, the "real" way : http://blog.torresdal.net/2008/10/26/wix-and-dtf-debug-a-managed-custom-action-and-how-to-generate-an-msi-log/ Here are some possible theories: If the custom action data is what you have there, I would suggest that the relative path isn't being evaluated from where you think it would be - you may need to use a property to build up a full path to the file. Is it possible that the XML file has a namespace? If the document has a namespace and you don't handle that in your code (both in the C# and in the XPath) you won't get any results. Hope that helps John On 26 February 2015 at 21:32, Davis, Jeff <jda...@nanometrics.com> wrote: > I am having a heck of time trying get my mind wrapped around the way > to create and use a custom action in my C# Wix Project in Visual Studio 2013. > > I want to be able to open a specified XML file and return an attribute > from a specified key and then use that to initialized a property in > the installer and display it in the dialog. Then when installer is run it > will > write the value to a target XML file to the same key and attribute. In My > case I have a MAC_ID Property that is in a UI text box that I want to > initialize from a XML file attribute and then write to a new XML file > during the install. The write is pretty straightforward since it is built > into WIx. But I can't get the read working. > > I created this Custom Action > > public class CustomActions > { > [CustomAction] > public static ActionResult ReadXmlValue(Session session) > { > string fileName = session.CustomActionData["FileName"]; > string xmlnode = session.CustomActionData["Node"]; > string key = session.CustomActionData["Key"]; > > XmlDocument xmlDoc = new XmlDocument(); > xmlDoc.Load(fileName); > if (xmlDoc.DocumentElement != null) > { > XmlNodeList nodeList = > xmlDoc.DocumentElement.SelectNodes(xmlnode); > > if (nodeList != null) > foreach (XmlNode node in nodeList) > { > var selectSingleNode = node.SelectSingleNode(key); > if (selectSingleNode != null) session["Value"] > = selectSingleNode.InnerText; > } > } > > return ActionResult.Success; > } > } > > > My WXS script looks like this > > > <Property Id="MAC_ID" Secure="yes" Value="0"/> > <Property Id="MACIDTemplate"> > <![CDATA[&&-&&-&&-&&-&&-&&]]> > </Property> > > <CustomAction Id="myActionId" BinaryKey="myAction" > DllEntry="ReadXMLValue" Execute="deferred" Return="check" /> > <CustomAction Id="SetCustomActionDataValue" Return="check" > Property="myActionId" Value="FileName='.\FilesToInstall\Program > Files\Zygo\MetroProX\cfg\NewView.IC.xml';Node='\Settings\Section\Section\Section\add';Key='Mac'" > /> > <CustomAction Id="ReadXMLValue" Property="Value" Value="[MAC_ID]" > /> > > <InstallExecuteSequence> > <Custom Action="SetCustomActionDataValue" > Before="myActionId">NOT Installed</Custom> > <Custom Action="myActionId" Before="InstallFinalize">NOT > Installed</Custom> > </InstallExecuteSequence> > > > But I don't think I have this setup right? > > > Jeff Davis > > ---------------------------------------------------------------------- > -------- Dive into the World of Parallel Programming The Go Parallel > Website, sponsored by Intel and developed in partnership with Slashdot > Media, is your hub for all things parallel software development, from > weekly thought leadership blogs to news, videos, case studies, > tutorials and more. Take a look and join the conversation now. > http://goparallel.sourceforge.net/ > _______________________________________________ > WiX-users mailing list > WiX-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wix-users > ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users