milindsm
Joined: 12 Mar 2010 Posts: 2
|
Posted: Fri Mar 12, 2010 12:06 pm Post subject: Regarding MsiDatabaseCommit in Msi.dll |
|
|
Hello,
I am using this method
| Code: |
[DllImport("Msi.dll")]
static extern
UInt32 MsiDatabaseCommit(IntPtr hDatabase); |
While calling this method, it throws an exception as "Attempt to read/write protected memory. Memory could be corrupt". I tried changing it to,
| Code: |
[DllImport("Msi.dll")]
static extern unsafe
UInt32 MsiDatabaseCommit(IntPtr hDatabase); |
But no luck. This occurs randomly. If I run the project from Visual Studio, it never occurs. Urgent help needed...!!!! _________________ Regards,
MSM |
|
Paul.Martin
Joined: 03 Feb 2010 Posts: 83 Location: Cambridgeshire
|
Posted: Fri Mar 12, 2010 7:55 pm Post subject: |
|
|
Could you tell me what other operations you are doing on the MSI Database object?
I can't replicate the problem at all with a simple open, query, change and commit alogrithm. It does seems really strange that it works in Visual Studio hosting but not always outside of it. The two usual culprits for a program that works differently in VS than in real life are permissions or more frequently timing issues. Is your application multi-threaded? |
|
milindsm
Joined: 12 Mar 2010 Posts: 2
|
Posted: Mon Mar 15, 2010 6:56 am Post subject: |
|
|
I am using most of the APIs to manipulate MSI database like
| Code: |
enum DATABASEOPENMODE
{
MSIDBOPEN_READONLY = 0,
MSIDBOPEN_TRANSACT = 1,
MSIDBOPEN_DIRECT = 2,
MSIDBOPEN_CREATE = 3,
MSIDBOPEN_CREATEDIRECT = 4
}
[DllImport("Msi.dll")]
static extern unsafe UInt32 MsiOpenDatabase(
string szDatabasePath,
IntPtr pPersist,
out IntPtr hDatabase);
[DllImport("Msi.dll", ExactSpelling = true)]
static extern UInt32 MsiCloseHandle(IntPtr pHandle);
[DllImport("Msi.dll", CharSet = CharSet.Unicode)]
static extern UInt32 MsiDatabaseOpenView(
IntPtr hDatabase,
[MarshalAs(UnmanagedType.LPWStr)] string szQuery,
out IntPtr hView);
[DllImport("Msi.dll", SetLastError = true)]
static extern UInt32 MsiEnableUIPreview(
IntPtr hDatabase,
out IntPtr hPreview);
[DllImport("Msi.dll", SetLastError = true)]
static extern UInt32 MsiPreviewDialog(
IntPtr hPreview,
string szDialogName);
[DllImport("Msi.dll", CharSet = CharSet.Unicode)]
static extern UInt32 MsiViewExecute(
IntPtr hView,
IntPtr hRecord);
[DllImport("Msi.dll", CharSet = CharSet.Unicode)]
static extern UInt32 MsiViewFetch(
IntPtr hView,
out IntPtr hRecord);
[DllImport("Msi.dll", CharSet = CharSet.Unicode)]
static extern UInt32 MsiRecordGetString(
IntPtr hRecord,
int iField,
[Out] StringBuilder szValueBuf,
ref int pcchValueBuf);
[DllImport("Msi.dll", ExactSpelling = true)]
static extern long MsiRecordGetInteger(
IntPtr hRecord,
int iField);
[DllImport("Msi.dll")]
static extern unsafe UInt32 MsiDatabaseCommit(
IntPtr hDatabase);
[DllImport("Msi.dll", ExactSpelling = true)]
static extern UInt32 MsiRecordReadStream(
IntPtr hRecord,
int iField,
[Out] byte[] szDataBuf,
ref int pcbDataBuf);
[DllImport("Msi.dll", ExactSpelling = true)]
static extern int MsiViewClose(IntPtr hView);
|
It is not a multi-threaded application. I am using Visual Studio 2008. _________________ Regards,
MSM |
|