how add c++ code to the c# assembly

  • Thread starter Thread starter tom
  • Start date Start date
T

tom

I make a c# winform project,
and need to reference c++ code.
But how do i add a new c++ code - .cpp file
to the assembly ?
 
tom said:
I make a c# winform project,
and need to reference c++ code.
But how do i add a new c++ code - .cpp file
to the assembly ?
I have add c++ as a project,
and set the namespace ("mynamespace") to be the same
as that in the original c# object. thanks
 
tom said:
I have add c++ as a project,
and set the namespace ("mynamespace") to be the same
as that in the original c# object. thanks

ok, i think I have got it,
could someone comment on if this is good code
(but please dont ask why I have to do this, thanks (i'll ask later)):

1. add a c++ project to the solution
and use visual studio to create a class in it.
The class will automatically be a _gc class
2. in the c++ code: use the same namespace as in the c# .cs, that is the
- the .cpp file, and
- the accompanying .h file
3. ensure all methods, and
all vaiables that the methods may return are public.
4. Now this is weird:
change the ctor in the c++ code to be public,
otherwise, when the class is instantiated form the c# file,
you get a protection level build error.
5. no delegates, no invoke, no import .dll - well thats if im not being
naughty.
thanks
tom
 
Back
Top