Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with type conversion when DllImport

Status
Not open for further replies.

nastoski

Technical User
Oct 21, 2003
21
Dear all,
While importing C++ dll in my C# application I’m experiencing following problem with last parameter sessionID
I’m experiencing a problem while doing

[DllImport("ClientLib.dll", EntryPoint="APIconnect", CallingConvention=CallingConvention.ThisCall)]
public static extern int APIconnect ([MarshalAs(UnmanagedType.LPStr)] string username, [MarshalAs(UnmanagedType.LPStr)] string password,[MarshalAs(UnmanagedType.LPStr)] string address,int port,[MarshalAs(UnmanagedType.LPStr)] string appid, [MarshalAs(UnmanagedType.U4)] uint sessionId);

with last parameter uint sessionID and error is shown:can not reference the object.
int connectRespond = APIconnect("test", "test", "testhost", 1112, "app4", 4);

The function in dll is declared as:

int APIconnect (const char *username,
const char *password,
const char *address,
int port,
const char *appid,
unsigned int *sessionID);

Can anybody help me and tell me how to Marshal unsigned int *sessionID?

Regards

Igor Nastoski
 
My knowledge of C++ is less than minimal, but doesn't [tt] unsigned int *sessionID[/tt] mean that sessionID holds a pointer to an unsigned int as opposed to actually being an unsigned int?


Hope this helps.

[vampire][bat]
 
Unamanged Type U4?

You should be able to take that statement out and just put uint sessionID I think.

Could be wrong :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top