Thanks for your help, Nishant. I enjoyed your website also. I have a
couple of follow-up questions:
1) All of the examples I've seen so far talk about creating managed c++.
What I am trying to do is use a C# class in an unmanaged C++ project that
has the managed extensions enabled (/clr). I'm using the gcroot template to
instantiate the managed "pointer". Do you know of some good examples of
this?
2) I have several legacy c++ projects in a .NET 2003 solution and a single
C# project. What is the correct c++ syntax to include the C# classes for
use in my legacy projects? Is this the correct way to do it?
Here's what I have in the header:
#using <mscorlib.dll>
#using <system.dll>
// PetToolTCPLib.dll is the output of my C# project.
// If this is part of the VS.NET solution that houses my C++ legacy code, do
I need to do this?
#using "PetToolTCPLib.dll"
using namespace PetToolTCPLib;
using namespace System;
gcroot<CToolMain*> m_pTCPTool; // CToolMain is a C# class in
PetToolTCPLib.dll
Here's what I have in the .cpp file (unmanaged legacy):
#pragma push_macro("new")
#undef new
m_pTCPTool = new CToolMain;
#pragma pop_macro("new")
Nishant S said:
Damn [pasted the same URL for the blgo entry too]
The blog-entry URL is :-
http://blog.voidnish.com/index.php?p=11
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com /* MVP tips tricks and essays web site */
Nishant S said:
Two more things
(1) You'll need to do a lot of managed-unmanaged data marshalling on your
own
(2) This syntax is now more or less obsolete. In the next version of the
VC++ compiler, MS is giving us C++/CLI, though the older syntax will
also
be
supported but not recommended
http://www.codeproject.com/managedcpp/cppcliintro01.asp - an intro to
C++/CLI
http://www.codeproject.com/managedcpp/cppcliintro01.asp - a blog entry on
whether you should use MC++ or not (in its current syntax)
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com /* MVP tips tricks and essays web site */
You'll also need to be well versed with the managed extensions
syntax
to
be
able to instantiate and use the C# classes.
Here is a simple intro from my web site - you'll find lots of others on
MSDN, CodeProject and other sites
http://www.voidnish.com/articles/ShowArticle.aspx?code=mcppintro01
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com /* MVP tips tricks and essays web site */
Hello,
I have a VS 2003.NET solution which consists of four c++ unmanaged
legacy
projects. I am adding a new project to the solution which will be in
c#.
What do I need to do to my c++ projects in order to call my c# modules
from
within c++? From what I understand, I need to convert my c++ code from
unmanaged to managed using the /clr switch (IJW). Is this
correct?
Are
there any other considerations I need to be aware of?
Ben