How to use unmanaged codes in managed ones.

G

Guest

Hello Esteemed Developers
I face problems using some managed codes in unmanaged ones and vice versa. For exampla I frequently took the following error message. That is
C2440: 'type cast' : cannot convert from 'sockaddr_in __gc*' to 'sockaddr*
O
C2664: 'WSAStartup' : cannot convert parameter 2 from 'WSADATA __gc*' to 'LPWSADATA

I noticed that my problem is converting managed types/codes to unmanged types/codes. I found some web pages about conversion. But those examples or explanations seems to me complex. Marshal is a tecnique to do this conversion

If you kindly forward me to a site, which explains this subject, is also prefereable

I would like to thank you in advance foe your sincere considerations and guidances
 
T

Tomas Restrepo \(MVP\)

Alper,
Hello Esteemed Developers,
I face problems using some managed codes in unmanaged ones and vice versa.
For exampla I frequently took the following error message. That is:
C2440: 'type cast' : cannot convert from 'sockaddr_in __gc*' to 'sockaddr*'
OR
C2664: 'WSAStartup' : cannot convert parameter 2 from 'WSADATA __gc*' to 'LPWSADATA'

I noticed that my problem is converting managed types/codes to unmanged
types/codes. I found some web pages about conversion. But those examples or
explanations seems to me complex. Marshal is a tecnique to do this
conversion.
If you kindly forward me to a site, which explains this subject, is also prefereable.

I would like to thank you in advance foe your sincere considerations and
guidances

No need to marshal. Your problem is that you need to pin the objects in
order to be able to pass them to unmanaged code. Look for __pin in the
documentation.,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top