Automation Interface get property by name (C#)
Posted 10 July 2017 - 22:33
I'm trying to use the automation interface to get or set a property by its name.
All the documentation and most of the examples online are in VB so I'm struggling with the syntax.
Attempting to do it like the documentation says results in errors.
Project.ISWIProperties.Item("ALLUSERS"); // Says definition for Item doesn't exist
Project.ISWIProperties("ALLUSERS"); // Says ISWIProperties can't be accessed like a method
I tried accessing it like this
And like this
// Get an InstallShield property by name
private static ISWiProperty GetISProperty(ISWiProject Project, string propertyName)
.First(x => x.Name.Equals(propertyName));
...both resulted in a run-time error. Help?
Posted 11 July 2017 - 16:53 Best Answer
This was the right syntax.
I had just forgotten to open the project first.