Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / March 2007

Tip: Looking for answers? Try searching our database.

Help with calling C# assembly from an unmanaged C++/MFC application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SJ - 26 Mar 2007 13:14 GMT
Hi

I have some existing unmanaged MFC/C++ application in VS2005 and VS2003.

I need to modify these apps to call methods already implemented in an
existing C# class library/assembly (retrofit some new functionality) and
redeploy the application.

From doing some reading on this I believe that creating the C# assembly
to support COM interop. and using the COM class from the MFC app is one
solution.

Another suggestion has been to create a C++/CLI class to wrap the C#
assembly, and then this new library can be used in an unmanaged application.

My questions are - is there any other way to achieve this? Which method
would be best in terms or rework and deployment? Has anyone done this
successfully, or has links to any detailed examples of this?

Thanks in advance.
Jayme Pechan - 26 Mar 2007 16:29 GMT
Supporting COM interop in your C# assembly is the easiest way I can think of
doing this.  This is just a flag on the dll build then you can use the
standard #import to create some Smart Pointers to the object.  This makes
interfacing to the DLL quite simple from C++.  Its been too long since I did
MFC programming to remember how it deals with COM objects so I can't give
any specific advise there.  You could also host the CLR and load the DLL in
there.  MSDN has some information on how to do this but unless you have no
control over the DLL build, this is probably more trouble than it is worth.

> Hi
>
[quoted text clipped - 17 lines]
>
> Thanks in advance.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.