Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

old C++ called from C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel P. - 29 Jun 2004 14:51 GMT
How can I do that?

Would it work if I added the C++ code to the current C# project/colution? Do
I have to create another assembly with a managed C++ wrapper to the old C++
code?

Thanks!
Shakir Hussain - 29 Jun 2004 15:22 GMT
Daniel,

One way to use ur old c++ code is to compile as a dll. In c#, you can access
the functions using "DllImport".

Unsafe c# is another way to use c++ code. Refer MSDN regarding that.

--
Shak
(Houston)

> How can I do that?
>
[quoted text clipped - 3 lines]
>
> Thanks!
Bill Burris - 29 Jun 2004 18:56 GMT
I used a managed C++ wrapper for my old C++ code.

In your solution add a managed C++ library.  Add your existing C++
source to the project and compile.  Once everything compiles, add
managed C++ classes to create the API that you want your C# code to see.

After doing this you will likely get a LNK 4243 warning.  Search for
this warning in your local MSDN docs or the MSDN website to find out how
to initialize the C run time library.

If you don't already know managed C++ you might want to use a Beta
version of VS 2005, or wait until it is released.  From what I here the
managed C++ syntax will change in VS 2005.

Another posibility is to use the Unix way.  Set up your C++ code as a
separate process.  Use sockets to communicate between the program
written in C++ and the one written in C#.  I was just reading "The Art
of Unix Programming" on the weekend, so havn't tried this technique yet.

Bill

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.