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 / October 2004

Tip: Looking for answers? Try searching our database.

Access to C# functions or classes from unmanaged C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Clement - 05 Oct 2004 19:43 GMT
I have made a dll in unmanaged C++ code using Visual Studio.Net 2003. I
would like to access C# functions or class methods from this dll. The C#
code would be in an other dll.

Typically, the C++ code does shell interaction, while the C# part is a
GUI and a web services client. The functions or methods will be called
to have a form displayed, or to get an integer value.

I have tried to use References, without success. I suppose this is to be
used with manages C++ code only, and anyway I couldn't have it working.

An other solution is probably to create a COM class in C# and access it
from C++, but once more I couldn't have anything working.

Do you have any ideas or suggestions ? Any code sample would be welcome.

Signature

Clement Gatin

Luis Abreu - 05 Oct 2004 22:41 GMT
Hello.   have you thought about pinvoke? or is this not possible? take a
look at this:

http://www.codeguru.com/Cpp/COM-Tech/complus/managed/article.php/c3947/

Signature

---
Regards,
Luis Abreu
http://weblogs.pontonetpt.com/luisabreu
http://www.pontonetpt.com

> I have made a dll in unmanaged C++ code using Visual Studio.Net 2003. I
> would like to access C# functions or class methods from this dll. The C#
[quoted text clipped - 11 lines]
>
> Do you have any ideas or suggestions ? Any code sample would be welcome.
Clement - 07 Oct 2004 21:11 GMT
> Hello.   have you thought about pinvoke? or is this not possible? take a
> look at this:
>
> http://www.codeguru.com/Cpp/COM-Tech/complus/managed/article.php/c3947/

Well, my goal is to access C# functions from C++ code, while pInvoke
seems to be made to access c++ code (in dll) from .NET (c#) applications.

But I could achieve my goal using COM finally. I had previously not
tried to use the tlb files (using #import directive), which seem to be
the easiest way to use COM classes from C++.

Thanks for the help anyway.

Signature

Clément Gatin

Luis Abreu - 09 Oct 2004 00:32 GMT
Hello Clement.

Sorry...I didn't understand what you really wnated on the 1st post. However,
in your case, there's another solution which is documented on this article:

http://www.codeproject.com/dotnet/bridge.asp

I think that this approach is more eficient that wrapping the objects in
COM. hope it helps.

Signature

---
Regards,
Luis Abreu
http://weblogs.pontonetpt.com/luisabreu
http://www.pontonetpt.com

> > Hello.   have you thought about pinvoke? or is this not possible? take a
> > look at this:
[quoted text clipped - 9 lines]
>
> Thanks for the help anyway.
Luis Abreu - 09 Oct 2004 11:57 GMT
oh, another thing? if want to call them from unmanaged code, why don't you
build a mixed (i think that this is the right name) c++ component (one that
has support for .net)?

Signature

---
Regards,
Luis Abreu
http://weblogs.pontonetpt.com/luisabreu
http://www.pontonetpt.com

> Hello Clement.
>
[quoted text clipped - 8 lines]
> > > Hello.   have you thought about pinvoke? or is this not possible? take a
> > > look at this:

http://www.codeguru.com/Cpp/COM-Tech/complus/managed/article.php/c3947/

> > Well, my goal is to access C# functions from C++ code, while pInvoke
> > seems to be made to access c++ code (in dll) from .NET (c#) applications.
[quoted text clipped - 4 lines]
> >
> > Thanks for the help anyway.

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.