The code snippet below was simplified from a much larger application. I can run against several other functions in Msi.dll without problems. However, I am running into a problem when executing against the MsiGetSummaryInformation function. I get the exception "Object reference not set to an instance of an object" when calling the function. I have tried everything that I can think of. What am I missing?
Thanks
Mik
using System
using System.Runtime.InteropServices
namespace SimpleTestIns
/// <summary
/// Summary description for Class1
/// </summary
class Class
/// <summary
/// The main entry point for the application
/// </summary
///
[DllImport("msi.dll")
private static extern uint MsiGetSummaryInformation(ulong dbhandle,string path,uint updateCount,ref ulong infoHandle)
public void Test(
ulong aHandle = 0
uint rc = MsiGetSummaryInformation(0,null,19,ref aHandle)
Console.WriteLine("Executed successfully.")
[STAThread
static void Main(string[] args
tr
Class1 c1 = new Class1()
c1.Test()
catch(Exception e
Console.WriteLine("\r\n\r\n ERROR MESSAGE: "+e.Message+"\r\n\r\n"+e.StackTrace)
ERROR
ERROR MESSAGE: Object reference not set to an instance of an object
at SimpleTestInst.Class1.MsiGetSummaryInformation(UInt64 dbhandle, String pa
h, UInt32 updateCount, UInt64& infoHandle
at SimpleTestInst.Class1.Test() in d:\hh3-new\rsr-rel1\ingen\build\net\test\
estmsi\simpletestinst\class1.cs:line 2
at SimpleTestInst.Class1.Main(String[] args) in d:\hh3-new\rsr-rel1\ingen\bu
ld\net\test\testmsi\simpletestinst\class1.cs:line 3
Phil Wilson - 26 May 2004 01:19 GMT
What happens if you actually give it a string that it's expecting instead of
a null?

Signature
Phil Wilson [MVP Windows Installer]
----
> The code snippet below was simplified from a much larger application. I can run against several other functions in Msi.dll without problems.
However, I am running into a problem when executing against the
MsiGetSummaryInformation function. I get the exception "Object reference
not set to an instance of an object" when calling the function. I have
tried everything that I can think of. What am I missing?
> Thanks,
> Mike
[quoted text clipped - 50 lines]
> at SimpleTestInst.Class1.Main(String[] args) in d:\hh3-new\rsr-rel1\ingen\bui
> ld\net\test\testmsi\simpletestinst\class1.cs:line 33
Mike Faltys - 26 May 2004 01:31 GMT
Same error. I have tried to pass the location of the msi database. I have also attempted to change the string to an uint and pass 0 and also the valid memory location of a string. All have yielded the "Object reference not set to an instance of an object".
Thanks,
Mike
Phil Wilson - 26 May 2004 01:46 GMT
Ok, it's not the string, it's that the handles need to be IntPtr, and you
haven't allocated one for the first parameter:
[DllImport("msi")]
private static extern uint MsiGetSummaryInformation(IntPtr dbhandle,string
path,uint updateCount,ref IntPtr infoHandle);
public void Test()
{
IntPtr inh = new IntPtr(0); // Should be a real handle even if it's empty
IntPtr aHandle = IntPtr.Zero;
uint rc = MsiGetSummaryInformation(inh,"this",19,ref aHandle); // gets 1620
when you don't have the file path
Console.WriteLine("Executed successfully.");
}

Signature
Phil Wilson [MVP Windows Installer]
----
> Same error. I have tried to pass the location of the msi database. I have also attempted to change the string to an uint and pass 0 and also the
valid memory location of a string. All have yielded the "Object reference
not set to an instance of an object".
> Thanks,
> Mike
MikeFaltys - 27 May 2004 01:46 GMT