I got the same problem. The Fetch sets a format string in column 0 of the
Record which causes problems with the Delete. The workaround is to do a Seek
on the record before Delete'ing. This restores the column 0 and the delete
works fine.

So it looks like this...

Record record = v.Fetch;
v.Seek(record);
v.Modify(ViewModifyMode.Delete, record);

Cheers
Jonny


darrenstone wrote:
> 
> 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
> 
> 

-- 
View this message in context: 
http://n2.nabble.com/DTF---Deleting-Property-tp2556276p3046280.html
Sent from the wix-devs mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
WiX-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-devs

Reply via email to