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 / Languages / Managed C++ / January 2007

Tip: Looking for answers? Try searching our database.

Parameter passing from C# to C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rich - 11 Jan 2007 16:47 GMT
I need to build a managed DLL in C++ and call it from C#.  I need this
to work with remoting as well.

In C#, class objects are reference types, so if an object is passed
directly to a C++ method it is considered a reference to the object.

C# call:
  i = some_method( some_object );

C++ method:
  int some_method( some_class ^ some_object)
  {
     int result;

     some_object->member1 = 123;
     result = some_object->member2 * 2;

     return result;
  }

This is fine until we need to run with remoting.  For C# to marshal the
class object in both directions (so the function can change members of
the object and pass the new value back), then in C# we must use a "ref"
call:
  i = some_method( ref some_object );

How should the C++ method be written to accept this call?

Thanks - any suggestions are appreciated.
David Anton - 12 Jan 2007 02:29 GMT
int some_method( some_class ^% some_object)

Signature

David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter

> I need to build a managed DLL in C++ and call it from C#.  I need this
> to work with remoting as well.
[quoted text clipped - 25 lines]
>
> Thanks - any suggestions are appreciated.

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.