473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to use unmanaged codes in managed ones.

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
Nov 17 '05 #1
3 1431
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.,

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #2
Managed pointer as a member to an unmanaged class, or a global
http://msdn.microsoft.com/library/en...nsSpec_16_3.as

Managed pointer that can be converted to an unmanaged pointer
http://msdn.microsoft.com/library/en...vclrf__pin.asp
Nov 17 '05 #3
Thank you MCCOYN
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that...
3
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
2
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking afterwards with ILDASM at what is visible in those assemblies from a...
14
by: Jon | last post by:
Whether I can compile a class or not, depends on the order of functions in my class. My question is (see example below): 1) Is it a bug that the class 'WillCompile' will compile and execute, or...
5
by: Anthony Evans | last post by:
Greetings I'm using VC++.NET to create a class library. The class library contains managed classes that wrap legacy unmanaged classes by the same name. I use regasm to register the DLL for...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
1
by: Sparhawk | last post by:
Hi, my company is going to migrate a large VC++ application to .NET to make use of Windows Forms (the old class library is not updated any more). We are not planning to migrate the rest of the...
1
by: Sarwan | last post by:
Hello everybody I have a solution in which there is an unmanaged MFC application. Then i added a new managed .Net Windows Form application. I was trying to refer an header file of unmanaged...
2
by: querry | last post by:
Hi all, I am developing a Windows Form Application in VC++. I am using using Visual Studio 2005. My project requires me to use the Boost Libraries www.boost.org] These boost libraries are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.