I have a problem with setting data that contains semicolons to CustomActionData property. By default CustomActionData class uses semicolon as DataSeparator and it breaks my data, when it contains semicolons. Is there any way to put semicolons to CustomActionData except of replacing them by come keyword?
-
Have you tried putting the data with semicolons inside into a property? In this case it will be look like `param1=[value1];param2=[value2]`, etc. – Yan Sklyarenko Apr 07 '11 at 11:30
-
Yes. Actualy I have a semicolon inside one of my properties. In this case I have brocken data in CustomAction because CustomActionData separate my property value in two parts. – Roman Kuzyk Apr 07 '11 at 11:58
-
Try using backslash `(\)` to escape semicolon – Yan Sklyarenko Apr 07 '11 at 12:21
-
Replace ";" with "\;"? I don't know when actually semicolon will be, because this is password property populated by user. P.S. Yes, I know that this is not secure. :( – Roman Kuzyk Apr 07 '11 at 12:30
-
Using "\;" didn't works for me. – Roman Kuzyk Apr 07 '11 at 14:01
-
Ok, I ran out of ideas... hope someone else can help... – Yan Sklyarenko Apr 07 '11 at 15:08
3 Answers
to pass a semicolon in your CustomActionData you should add one more semicolon.
Example:
CustomActionData="key1=value1;key2=value2.1;;value2.2;;value2.3" - this will pass key1=value1 and key2=value2.1;value2.2;value2.3
If you don't know where the semicolons are then I guess you can create method that escapes them by replacing each semicolon with two semicolon.
If there are more symbols that you don't know how to escape you easily find out creating a simple app that creates a CustomActionData instance, adds a key-value pair and outputs the CustomActionData string representation using ToString().
Example:
CustomActionData data = new CustomActionData();
data.Add("key1", "value1");
data.Add("key2", "value2.1;value2.2;value2.3");
Console.WriteLine(data.ToString());
I hope the information is helpful.

- 76
- 1
-
Tnx. I created a additional CustomAction to replace semicolons by keyword. – Roman Kuzyk Apr 08 '11 at 12:12
-
You can also access the raw string via `session["CustomActionData"]` if you want to take control of how it is deserialized. That is all [session.CustomActionData](https://stackoverflow.com/a/46965464/521757) does. – jnm2 Oct 27 '17 at 00:02
Back in 2006 I wrote a blog article and sample project:
InstallScript, meet CustomActionData
Basically I used the pattern: /KEY1=VALUE1 /KEY2=VALUE2
The library worked by calling a lookup function passing it "/KEY1=". It then returned all data until the end of until the next " /".
Regardless I don't really use this much any more since I've moved onto C# DTF which has a CustomActionData class handles the derialization/deserialization for me.

- 54,556
- 6
- 63
- 100
-
Added a quick answer with your JSON approach for CustomActionData. – Stein Åsmul Mar 25 '19 at 01:42
JSON Strings: Chris Painter - who has also answered this question with an older approach - has a blog entry that revolutionizes CustomActionData
handling by using JSON strings
. Now there is no string parsing to do, so far as you use a proper JSON library. Built-in serialization / deserialization: http://blog.iswix.com/2011/10/beam-me-up-using-json-to-serialize.html.
Technically: The technical nitty-gritties would be different depending on language, but JSON strings themselves are simple:
Groups=[{"Name":"Rockers","Description":"People who rock!"}]
You can resurrect an object in deferred mode! Just by calling Serialize
and Deserialize
.

- 39,960
- 25
- 91
- 164
-
This would still break when the model contains a semicolon in one of the values ... – ViRuSTriNiTy May 28 '21 at 10:05
-
I haven't tested it, but here is a sample using the [DTF serialization approach](https://github.com/glytzhkof/WiXDeferredModeSampleDTF). [See the custom action code here for interesting part](https://github.com/glytzhkof/WiXDeferredModeSampleDTF/blob/main/CustomActionSample/CustomAction.cs#L16). Also [see this answer](https://stackoverflow.com/a/66326396/129130). Here is [a sample of the "manual way" to do CustomActionData](https://github.com/glytzhkof/WiXDeferredModeSample) (using custom actions yourself). – Stein Åsmul May 28 '21 at 10:28