Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I use VS 2008 C# Express.
I have a project coded in C#. I also need C++ code snippets in my project.

Could one say me whether using C++ source codes in C# development environment is possible. If possible, How can I achieve this?

Thanks in advance,

Hasan
Posted
Updated 26-Dec-10 7:07am
v2
Comments
Sergey Alexandrovich Kryukov 27-Dec-10 8:21am    
By the way: why "I also need C++ code snippets in my project."?!

All the problems are in "Express".
If you install it, you choose between Visual Basic Express, Visual C++ Express, Visual C# Express, Visual Web Developer Express, Express for Windows Phone. If I'm not much mistaken, you cannot install two or more of these variants of the environment on the same computer at the same time.

This would make development using two language possible but quite inconvenient: either using separate computers or re-installing then back and force all the time :( .

There is one more option: you can install just C++, and C# programming does not need environment, or you can use SharpDevelop.

When you complete your (for example) C++ project, using it in, say, C# environment will not be a problem: you copy just the compiled assembly, in executable form, and later reference it in your C# project. But as to incremental development using two different environments...

...This would be extremely inconvenient. I would not bother, ever.
 
Share this answer
 
v3
Comments
T2102 27-Dec-10 8:31am    
You can install compilers for multiple languages on one machine; you just need a separate test machine(s). I've run Visual Basic, C++, C# 6.0 Enterprise to 2010 Express on the same machine previously.
Sergey Alexandrovich Kryukov 1-Mar-11 3:32am    
Thank you, I did not really try in real life, just got if from documentation. Good to know.
--SA
Espen Harlinn 28-Feb-11 15:08pm    
Good points, a 5
Sergey Alexandrovich Kryukov 1-Mar-11 3:32am    
Thank you, Espen,
--SA
Yes it is possible. You should encapsulate C++ code in a library project (dll) and reference this dll in your C# project. Hope this helps.
 
Share this answer
 
Comments
dmageiras 26-Dec-10 13:37pm    
If C++ code is unmanaged see this http://msdn.microsoft.com/en-us/magazine/cc301501.aspx.
Sergey Alexandrovich Kryukov 26-Dec-10 13:56pm    
Don't forget, Hasan needs to use Express edition -- this is a problem
dmageiras 26-Dec-10 14:56pm    
You are right, haven't noticed it. I have focused on question "Could one say me whether using C++ source codes in C# development environment is possible" skipping edition detail.
T2102 27-Dec-10 8:32am    
C++/CLI is very close to C#. In fact, Microsoft stops supporting Intellisense for C++/CLI with Visual Studio 2010 most likely to try to force conversion to C#.
Nemanja Trifunovic 27-Dec-10 10:34am    
Microsoft replaced the Intellisense C++ compiler completely and the new one was not ready for C++/CLI in time for VS2010.
C++ can usually be changed to C# with minimal changes normally. The most difficult changes might be related to macro preprocessing and memory. You might need to use the unsafe keyword. You may also need to change :: in C++ to . in C#
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 27-Dec-10 8:23am    
Good point. However I doubt Hasan needs to port from C++. Read: "I have a project coded in C#. I also need C++ code snippets in my project." I asked him why -- it looks strange.
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900