Menu

#41 Database.Commit() throws an exception on Windows Vista

v1.1
open
legalize
MSI.Interop (6)
5
2014-12-14
2006-10-04
No

I converted the MSI.Interop over to VS2005 on Windows
Vista and created a simple WinUI application to
consume it. I have a form that creates an instance of
a class that opens an MSI database in direct mode. I
then use a property accessor for get/set tied to two
methods that hit the MSI for data storage via the
interop. Thet get method works but when I try to
save data back to the MSI I get an exception. If I
take the compiled EXE and Pahvant.MSI.Interop assembly
and run it on Windows XP it works just fine.

I'm sure it's not a permissions problem because when I
do have a permissions problem I fail on opening the
database in direct mode where readonly mode works.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog
box.

Sample Code:
namespace ConfigurePackage
{
public class FormManager
{
private Pahvant.MSI.Database database;

public string productVersion
{
get
{
Pahvant.MSI.View view = new
Pahvant.MSI.View(database, "select `Value` from
`Property` where `Property`='ProductVersion'");
view.Execute();
Pahvant.MSI.Record record = view.Fetch
();
string version = record.GetString(1);

record.Dispose();
view.Dispose();

return version;
}
set
{
Pahvant.MSI.View view = new
Pahvant.MSI.View(database, "update `Property` set
`Value` = '6.6.6' where `Property`='ProductVersion'");
view.Execute();
database.Commit();
}
}

public FormManager( string msiPath )
{
database = new Pahvant.MSI.Database
(msiPath, Pahvant.MSI.Database.OpenMode.Direct);

}
}
}

************** Exception Text **************
System.AccessViolationException: Attempted to read or
write protected memory. This is often an indication
that other memory is corrupt.
at Pahvant.MSI.Database.MsiDatabaseCommit(IntPtr
handle)
at Pahvant.MSI.Database.Commit()
at
ConfigurePackage.FormMain.buttonProductVersionSave_Clic
k(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp
(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message&
m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message&
m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMess
age(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndPro
c(Message& m)
at System.Windows.Forms.NativeWindow.Callback
(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.112 (rtmLHS.050727-1100)
CodeBase:
file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/m
scorlib.dll
----------------------------------------
ConfigurePackage
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/ConfigurePackage.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.112 (rtmLHS.050727-1100)
CodeBase:
file:///C:/Windows/assembly/GAC_MSIL/System.Windows.For
ms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.112 (rtmLHS.050727-1100)
CodeBase:
file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b7
7a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.112 (rtmLHS.050727-1100)
CodeBase:
file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0
.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Pahvant.MSI.Interop
Assembly Version: 1.1.2468.27389
Win32 Version: 1.1.2468.27389
CodeBase: file:///C:/Pahvant.MSI.Interop.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config
file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms
section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the
computer
rather than be handled by this dialog box.

Discussion


Log in to post a comment.