PDA

View Full Version : Automation in c#



Bala000
06-10-2005, 02:53 AM
Hi, I get the error message as listed below. I cannot access the value of a property or cannot get ProductName. A sample code for accessing property, productName, productVersion would help me a lot. And i would like to change the property as well in c# code.

e:\temp\testing\form1.cs(104,21): error CS1545: Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'ISWiAutomation._ISWiProperty.get_Value()' or 'ISWiAutomation._ISWiProperty.set_Value(ref string)'

However it works fine when coded in VBS. We would like to get this to work in C#.
I am using Developer8. And we are planning to buy v11 which i am evaluating at the moment. If this is fixed in v11, it is fine by me.

[With some sample code in c# ... please]

Help!!!

chris_p
06-10-2005, 05:24 AM
Hi Bala000,

would you post the method the error occures in?
i know this error, but, since i'm quite new to installshield, i have no idea how to reproduce this...

chris

Bala000
06-10-2005, 05:50 AM
Hello Chris,
Here is my c# code.
...

ISWiAutomation.ISWiProject m_ISWiProject;
ISWiAutomation.ISWIProperties props;

m_ISWiProject = new ISWiAutomation.ISWiProjectClass();
props = new ISWiAutomation.ISWIPropertiesClass();
MessageBox.Show(props[1].Value);

This will already give you a compilation error.

chris_p
06-10-2005, 06:40 AM
I don't know why this happens, but calling
props[1].get_Value() and
string s ="Test";
p.set_Value(ref s); at least compiles.

seems to be a bug in the library...

Bala000
06-10-2005, 08:08 AM
Guys,
I have found my way around to do this. The below api code works on ism files.

Hresult = db.MsiDatabaseOpenView (db_handle, "UPDATE `Property` SET `Value`='test' WHERE `Property`='PASSWORD'", ref view_handle);

Hresult = db.MsiViewExecute (view_handle, nil);
Hresult = db.MsiDatabaseCommit(db_handle);

By that way i can also select and fetch it. It is not a stopper for now...

Thanks anyway.

chris_p
06-13-2005, 01:50 AM
good luck further on :)