PDA

View Full Version : AddProperty(), Can it be used at all?



Rennison
06-08-2004, 08:33 AM
Has anybody got a clue why the following code throws a NullReferenceException on the prop.Value="1" line?

Dim project As ISWiAuto10.ISWiProject
Dim prop As ISWiAuto10.ISWiPropertyClass

project.OpenProject(msiName, False)
prop = project.AddProperty("ALLUSERS")
prop.Value = "1"
project.SaveProject()
project.CloseProject()

David Thornley
06-08-2004, 09:10 AM
I'm fairly sure you need to do

Set prop = project.AddProperty("ALLUSERS")

Rennison
06-08-2004, 09:12 AM
Thanks, but Set is optional in VB. Has been since V4 as far as I'm aware. Same as LET in most other BASICs.

David Thornley
06-08-2004, 09:54 AM
Hmmm, I guess thats what I get for still using VB 6...where Set is required or you get runtime error 91.

You are correct that the set is not required in VB7. I ran a test and it worked with the following code.

Dim project As ISWiAuto10.ISWiProject
project = CreateObject("ISWiAuto10.ISWiProject")
project.OpenProject("C:\My InstallShield X Projects\My Project Name-66.ism", False)
Dim prop As ISWiAuto10.ISWiPropertyClass
prop = project.AddProperty("ALLUSERS")
prop.Value = "1"
project.SaveProject()
project.CloseProject()


Then I thought about your variable name 'msiName' and so I tried using this on an MSI package directly instead of an ISM file. When I did this I was able to get the NullReferenceException.

To be honest, I'm not sure that we anticipated people using end user automation in direct mode. It is an interface designed explicitly for working with ISM files. The MSI opens successfully because the internal code called to open the project is the same code that the IDE uses to open files. I have created Work order 1-PDUOO to have a developer verify the end user automation functionality in direct MSI mode. For the time being I would recommend using Windows Installer automation directly.

Rennison
06-09-2004, 04:00 AM
Thanks for the prompt response. I believe I have a little extra information.

In addition to the issue highlighted by the earlier code fragment, I also needed to alter the property 'DefaultUIFont'. This is present in the property list of the MSI, but is not exposed as a class property so can only be accessed through the properties collection.

The value of this property cannot be amended either so it would appear the problem is not related to adding new properties so much as amending properties which are not directly exposed as class properties.

Rennison
07-26-2004, 10:29 AM
I have heard nothing on this subject in quite a while. Has any progress been made?

I am currently (as suggested) implementing the full Windows Installer solution, so it's not really an issue any more, but I'd like to see closure.

mberterm
01-20-2006, 05:55 PM
Taken from a recent attempt at using AddProperty with the IS 11.5 Automation...


I can now successfully use the "AddProperty" method of the ISWIProject object.


Here's the syntax:

Set m_ISWiProject = CreateObject ("ISWiAuto1150.ISWiProject")

m_ISWiProject.OpenProject strFile
// "strFile" is a variable that contains the location and name of the ism file I'm working with.

Set pHandle = m_ISWIProject.AddProperty("AllFilesInProject")
// This is the syntax that creates a new property named AllFilesInProject