[...]
> 1.) It looks like the only way to combine the C++ code into the .NET project
> is to convert it into "managed code" (which involves quite a bit of
[quoted text clipped - 4 lines]
> to write C++ code that can be conditionally compiled as either managed or
> not managed?
To access the same classes directly from C#, yes, you would have to do
that. There is a #define that you can check to see if you're compiling
managed code, but I can't think of it offhand... and the number of
differences between what unmanaged and managed classes are allowed to do
would make this a nightmare, IMO.
> 2.) I gather that we could compile the C++ modules into one DLL and then
> access it from the .NET project using some kind of wrapper?? I frankly don'
> t fully understand what this means. Could someone recommend a link to a
> good article on this topic?
This is what I'd suggest. Here's an article about it:
http://www.ondotnet.com/pub/a/dotnet/2004/03/29/mcpp_part3.html
Jesse
Hi Bruce,
Additionally, you can make your C++ business logic code into COM
components, them use COM Interop to access them from C# applications:
COM Interop Tutorials
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/
vcoricominteroptutorial.asp
COM Interop Part 1 Sample
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cssample/ht
ml/vcsamCOMInterOpSample.asp
Advanced COM Interop
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconadvancedcominterop.asp
Thanks!
Best regards,
Gary Chang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Bruce Schechter - 01 Jun 2004 17:20 GMT
Gary and Jesse,
Thanks very much for your answers and links. Although I have more analysis
to do, it tentitively looks to me like the best solution in my case is to
keep our C++ code independent of the .NET framework, compile it into a COM
component, and then let vs.net take care of building the wrapper around it
for interop with my C# UI.
Thanks again,
-- Bruce
> Hi Bruce,
>
> Additionally, you can make your C++ business logic code into COM
> components, them use COM Interop to access them from C# applications:
>
> COM Interop Tutorials
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/
> vcoricominteroptutorial.asp
>
> COM Interop Part 1 Sample
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cssample/ht
> ml/vcsamCOMInterOpSample.asp
>
> Advanced COM Interop
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
> l/cpconadvancedcominterop.asp
>
[quoted text clipped - 8 lines]
> This posting is provided "AS IS" with no warranties, and confers no rights.
> --------------------
Gary Chang - 03 Jun 2004 04:38 GMT
Hi Bruce,
After re-considering your problem carefully, I recognized that the best
approach for your case is used the IJW to interop between the unmanaged and
managed code, I agree with the Jesse and Nat's opinion.
The COM interop is for use of calling OLE Automation compatible COM
components(such as some Office automation components), which it appears not
your scenario.
However, the IJW(It Just Works) is a managed C++-specific feature which
enables flat APIs and COM APIs to be used directly, it is for use of
wrapping complex unmanaged flat APIs(or wrapping unmanaged flat APIs which
changing frequently during developing) and calling IDL based COM
components, so I think it is the proper approach to your case.
Please refer to the following detail document:
An Overview of Managed/Unmanaged Code Interoperability
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/manunmancode.asp
Thanks for your understanding!
Best regards,
Gary Chang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Bruce Schechter - 02 Jun 2004 09:29 GMT
Gary,
I would like to try the COM interop approach described in this article.
But I need help with one more element of that approach... Can you point me
to an article to explain how I can take my set of (unmanaged, legacy) C++
classes and create a COM object from them? (All my experience so far with
Microsoft tools has been with the .NET framework. I have no comprehension
of what kind of effort is required to create a COM object.)
Thanks, Bruce
> Hi Bruce,
>
> Additionally, you can make your C++ business logic code into COM
> components, them use COM Interop to access them from C# applications:
>
> COM Interop Tutorials
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/
> vcoricominteroptutorial.asp
>
> COM Interop Part 1 Sample
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cssample/ht
> ml/vcsamCOMInterOpSample.asp
>
> Advanced COM Interop
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
> l/cpconadvancedcominterop.asp
>
[quoted text clipped - 8 lines]
> This posting is provided "AS IS" with no warranties, and confers no rights.
> --------------------
The easiest solution might be to write the UI in managed c++ (instead of
c#).
Then you can combine everything into a single project. Compile the legacy
c++ code using /clr (no source changes), and "it just works".
nwells
> Background: I have nearly two years of experience with C# and the .NET
> framework, as well as a fair amount of C experience from many years ago, but
[quoted text clipped - 31 lines]
>
> Bruce
Bruce Schechter - 08 Jun 2004 01:30 GMT
Nat,
Thanks for the message. That is a very interesting prospect.
I will give that a try.
cheers, Bruce
> The easiest solution might be to write the UI in managed c++ (instead of
> c#).
[quoted text clipped - 43 lines]
> >
> > Bruce