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++ / June 2007

Tip: Looking for answers? Try searching our database.

Pass CString and byte array from native C++ to managed C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Notre Poubelle - 26 Oct 2006 19:21 GMT
Hello,

I have a scenario where  my CPP project is not compiled with CLR support,
but some of the CPP files have the /clr option set.  In file1.cpp, the /clr
switch is not set.  In file2.cpp, the /clr switch is set.  file2.h is the
header for file2.cpp, and this header is included in file1.cpp.  file2.h
contains method signatures containing only native types, including some
funtions which take a CString parameter or a const pointer to char, e.g.

void MyFunc (const char* param);

Methods in file1.cpp calls the functions declared in file2.h (and
implemented in file2.cpp), including the two with a CString and const pointer
to char parameters.  My question is, should I be doing any marshalling of
data at this point (presumably in file1.cpp) when moving from native to
managed code?  If so, what type of marshalling should I do and how?

Thank you,
Notre
David Lowndes - 26 Oct 2006 21:11 GMT
>My question is, should I be doing any marshalling of
>data at this point (presumably in file1.cpp) when moving from native to
>managed code?

No, it should just work seamlessly.

Are you having a problem?

Dave
Notre Poubelle - 26 Oct 2006 22:15 GMT
Hi David,

No, I'm not seeing any problem.  I just thought that when passing
non-primitive values from native to managed code I would need to do some type
of marshalling.

The compiler does complain when trying to use native & managed types that
don't match. However, the compiler doesn't catch the case where native code
holds a reference to a managed object, which can be garbage collected if not
pinned. I thought there might be something I need to do in the scenario I
described earlier as well (but don't know what)...

Notre
David Lowndes - 27 Oct 2006 00:35 GMT
>Hi David,
>
>No, I'm not seeing any problem.

That's always reassuring :)

>I just thought that when passing
>non-primitive values from native to managed code I would need to do some type
>of marshalling.

I won't pretend to know what goes on since I've not yet needed to
know, but one of the essential points of the C++ compiler was that it
should just work (the old IJW "It Just Works" TLA) with /clr.

Dave
P.GopalaKrishna - 18 Jun 2007 18:08 GMT
Hello,

Please check if the post at:
http://blogs.msdn.com/gpalem/archive/2007/06/18/having-hard-time-marshalling-par
ameters-from-c-to-net.aspx

is useful.

P.Gopalakrishna.
http://www.geocities.com/krishnapg/

> Hello,
>
[quoted text clipped - 15 lines]
> Thank you,
> Notre

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.