Mixing C# and C++

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I will be starting a project that may need to use C# and C++ for different
parts of the project. What is the best way to go about this?

e.g which project type should i use and what issues do i need to look out for?

Thanks In Advance
Macca
 
Macca,

What is the purpose of using C++? Do you really need it? I would use
..NET for most of the development, and dive down into C++ only when you need
it.

If you have pre-existing C++ classes which you want to use in .NET, then
you will have to create managed wrappers so that you can use them. Either
that, or make them into COM objects and use COM Interop to access them.

If you simply have functions that you have exported from DLLs then you
can just make those calls through the P/Invoke layer. If you have functions
in libs, then you will have to create a dll which exports those functions.

Hope this helps.
 
The C# will have a C# project type. The C++.NET (is the C++ part C++.NET)
will have a C++.NET project type. Both project types will coexist in the
same Solution. You should also be able to use the debugger as if all were in
the same language. There aren't any special issues other than the fact that
the C++.NET is difficult to work with. It has better facilities for
interacting with the non .NET world, however. It may be best to do as much
in C# as you can.
 
Back
Top