G
Guest
I am using .NETCF 2.0.5238.0 and presently (as VS2005 is unavailable in
Germany) still VS .NET 2003
I am working on interop between an unsave C-written DLL and C#.
Now, in a constructor of a class I am trying to get a structure copied from
unsafe to a safe structure (class actually) using Marshal.PtrToStructure
(IntPtr, Object). Returning from here my pointer goes to 0. What am I missing?
I tried the same with Marshal.PtrToStructure (IntPtr, Type) and IntPtr is
not null thereafter (but as I am using it in the constructor I guess I need
to use the first one). Regardless which version is used, the managed
structure/class properly receives the values from the unmanaged side
Thanks ahead for any help!!
tb
PS: here's the code:
..
..
public IntPtr cp;
//constructor
public WrapCP()
{
cp = myUnsafeDll_new();
log.Debug("cp initialized " + (int)cp); // this confirms a non zero return
value
Marshal.PtrToStructure(cp,this); //this properly fills the struct/class
log.Debug("cp now " + (int)cp); // cp now points to 0
}
Germany) still VS .NET 2003
I am working on interop between an unsave C-written DLL and C#.
Now, in a constructor of a class I am trying to get a structure copied from
unsafe to a safe structure (class actually) using Marshal.PtrToStructure
(IntPtr, Object). Returning from here my pointer goes to 0. What am I missing?
I tried the same with Marshal.PtrToStructure (IntPtr, Type) and IntPtr is
not null thereafter (but as I am using it in the constructor I guess I need
to use the first one). Regardless which version is used, the managed
structure/class properly receives the values from the unmanaged side
Thanks ahead for any help!!
tb
PS: here's the code:
..
..
public IntPtr cp;
//constructor
public WrapCP()
{
cp = myUnsafeDll_new();
log.Debug("cp initialized " + (int)cp); // this confirms a non zero return
value
Marshal.PtrToStructure(cp,this); //this properly fills the struct/class
log.Debug("cp now " + (int)cp); // cp now points to 0
}