X
Xinjie ZHANG
I use a third-party C library in my .NET CF application. The method signature for one of the C functions is:
int PlaceInstance( U32 Handle, U16 ParticleID, U16 Layer, char* InstanceName, SFLOAT X, SFLOAT Y, char* Path, char** DstPath );
In C++ applications, it can be called like this:
PlaceInstance(handle, 123, 222, "name", 10, 50, NULL, NULL)
I have tried many ways to make it work, but unfortunately, I can not
public static extern int PlaceInstance( uint Handle, ushort ParticleID, ushort Layer, string InstanceName, float X, float Y, string Path, out StringBuilder DstPath );
call ==>
StringBuilder builder = new StringBuilder(1024);
PlaceInstance(handle, 123, 222, "name", 10, 50, null, out builder)
public static unsafe extern int PlaceInstance( uint Handle, ushort ParticleID, ushort Layer, string InstanceName, float X, float Y, char* Path, char** DstPath );
call ==> PlaceInstance(handle, 123, 222, "name", 10, 50, (char*)0, (char**)0)
public static unsafe extern int PlaceInstance( uint Handle, ushort ParticleID, ushort Layer, string InstanceName, float X, float Y, byte* Path, byte** DstPath );
call ==> PlaceInstance(handle, 123, 222, "name", 10, 50, (byte*)0, (byte**)0)
public static extern int PlaceInstance( uint Handle, ushort ParticleID, ushort Layer, string InstanceName, float X, float Y, IntPtr Path, out IntPtr DstPath );
call ==>
IntPtr ptr = IntPtr.Zero;
PlaceInstance(handle, 123, 222, "name", 10, 50, IntPtr.Zero, out ptr )
They always fail in PlaceInstance call with "Object reference not set to an instance of an object" error. It makes me crazy Could anyone helps me out? Thanks !
int PlaceInstance( U32 Handle, U16 ParticleID, U16 Layer, char* InstanceName, SFLOAT X, SFLOAT Y, char* Path, char** DstPath );
In C++ applications, it can be called like this:
PlaceInstance(handle, 123, 222, "name", 10, 50, NULL, NULL)
I have tried many ways to make it work, but unfortunately, I can not
public static extern int PlaceInstance( uint Handle, ushort ParticleID, ushort Layer, string InstanceName, float X, float Y, string Path, out StringBuilder DstPath );
call ==>
StringBuilder builder = new StringBuilder(1024);
PlaceInstance(handle, 123, 222, "name", 10, 50, null, out builder)
public static unsafe extern int PlaceInstance( uint Handle, ushort ParticleID, ushort Layer, string InstanceName, float X, float Y, char* Path, char** DstPath );
call ==> PlaceInstance(handle, 123, 222, "name", 10, 50, (char*)0, (char**)0)
public static unsafe extern int PlaceInstance( uint Handle, ushort ParticleID, ushort Layer, string InstanceName, float X, float Y, byte* Path, byte** DstPath );
call ==> PlaceInstance(handle, 123, 222, "name", 10, 50, (byte*)0, (byte**)0)
public static extern int PlaceInstance( uint Handle, ushort ParticleID, ushort Layer, string InstanceName, float X, float Y, IntPtr Path, out IntPtr DstPath );
call ==>
IntPtr ptr = IntPtr.Zero;
PlaceInstance(handle, 123, 222, "name", 10, 50, IntPtr.Zero, out ptr )
They always fail in PlaceInstance call with "Object reference not set to an instance of an object" error. It makes me crazy Could anyone helps me out? Thanks !