Tivoli C library and unsafe C# (a void** problem)

  • Thread starter Thread starter Francois Vanderseypen
  • Start date Start date
F

Francois Vanderseypen

Concerning marshalling of unmanaged data types from and to a
C-library, what does this error mean?


"An unhandled exception of type
'System.Runtime.InteropServices.MarshalDirectiveException' occurred in
TivoliUML.exe

Additional information: Can not marshal parameter #1: Invalid
managed/unmanaged type combination (Int/UInt must be paired with I or
U)."

Thank you for any help!
 
Francois, what does your p/invoke statement look like? That exception
usually means you are trying to use an unsupported MarshalAs attribute.
 
Hi Greg,

I posted a more detailed message earlier but basically I have the following:

The C-lib signature is:

int SIT_Registry_Initialise( void ** _LdapSession ,
char* _szHost_Port,
char* _szAdmin_DN,
char* _szAdmin_Pwd);

I understand that the void** is a "byref" argument. The _LdapSession
is passed (as a connection object) to other calls thereafter. I guess
the _LdapSession is a C-structure.

How should I wrap this dll function?

At this moment it looks like:

[DllImport("SIT_UML.dll", EntryPoint="SIT_Registry_Initialise")]public
static extern int InitializeRegistry([MarshalAs(UnmanagedType.AsAny)]UIntPtr
LDAPSession,[MarshalAs(UnmanagedType.LPStr)]string
HostPort,[MarshalAs(UnmanagedType.LPStr)]string
AdminUserID,[MarshalAs(UnmanagedType.LPStr)]string AdminPassword);

and the actual call is:

UIntPtr LDAPSession=UIntPtr.Zero;
int ret=UML.InitializeRegistry(LDAPSession,"blabla","blabla","blabla");


Thanks for your help!
 
Back
Top