It doesn't look like you're doing anything wrong. I would expect that code to work, so this could be a bug in DTF or MSI.
Compared to your native API calls, there is one thing different that happens under the covers in DTF, which I wouldn't expect to cause this problem but I don't know for sure: Just after the first Record of a View is fetched but before it is returned, there are 2 calls to MsiViewGetColumnInfo (1 for names and one for types), so that returned Records have access to column information of the View they came from. That information enables Record fields to be accessed by name among other things. Could those MsiViewGetColumnInfo calls be putting the view into a state where the deletion no longer works? Would moving those calls to before the first fetch (just after the execute) solve the problem? I'll investigate more later when I have time, but you might get to it first. -Jason- From: [email protected] [mailto:[email protected]] Sent: Monday, March 30, 2009 2:11 AM To: [email protected] Subject: [WiX-devs] DTF - Deleting Property I have just started using the Deployment Tools Foundation libraries in Wix 3.0. However I have come across a problem when trying to delete a property from an existing msi. The code I am using is as follows: // open the database Database database = new Microsoft.Deployment.WindowsInstaller.Database(@"C:\Dev\Temp\IES.msi", DatabaseOpenMode.Direct); // open view Microsoft.Deployment.WindowsInstaller.View v = database.OpenView("SELECT * FROM `Property` WHERE `Property`='Test'"); // execute view v.Execute(); // fetch and delete record Record record = v.Fetch; v.Modify(ViewModifyMode.Delete, record); If have excluded closing the view, database, and checking the outcome of fetch purely for brevity, but when I perform the call to v.Modify I get an InstallerException with the message "Function failed during execution, Database: C:\Dev\Temp\IES.msi. Cursor in invalid state." The record is definitely returned from Fetch and in addition to this updates work fine. To prove there was nothing funny with the msi I did the same directly against the API and it works fine, the code is as follows: // open the database result = SafeNativeMethods.MsiOpenDatabase(@"C:\Dev\Temp\IES.msi", MsiDbPersistMode.Direct, out databaseHandle); // open view result = SafeNativeMethods.MsiDatabaseOpenView(databaseHandle, "SELECT * FROM `Property` WHERE `Property`='Test'", out viewHandle); // execute view result = SafeNativeMethods.MsiViewExecute(viewHandle, recordHandle); // fetch and delete record result = SafeNativeMethods.MsiViewFetch(viewHandle, ref recordHandle); result = SafeNativeMethods.MsiViewModify(viewHandle, 6, recordHandle); Therefore the above two code samples are functionally equivalent but the one using the DTF classes does not work. Does anybody know if I am missing something obvious here? I have not looked too closely at the DTF sources yet as I wanted to rule out user error first. Any advise would be most appreciated. ----------------------------------------------------------------------------------------------------- HBOS plc, Registered in Scotland No. SC218813. Registered Office: The Mound, Edinburgh EH1 1YZ. HBOS plc is a holding company, subsidiaries of which are authorised and regulated by the Financial Services Authority. ==============================================================================
------------------------------------------------------------------------------
_______________________________________________ WiX-devs mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wix-devs
