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 / January 2007

Tip: Looking for answers? Try searching our database.

can I call non-exported unmanaged functions from managed code?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
brad - 23 Jan 2007 00:49 GMT
I'm writing test automation for a native dll using manage code.

I know that I can use Platform Invoke to call exported, native
functions from my managed code.

What if the native function isn't exported? Can I still call it using
P/Invoke?

In this particular case, I DO have access to the source code and symbol
files for the native code which I am trying to call.

Thanks,
--brad
William DePalo [MVP VC++] - 23 Jan 2007 19:41 GMT
> What if the native function isn't exported? Can I still call it using
> P/Invoke?
>
> In this particular case, I DO have access to the source code and symbol
> files for the native code which I am trying to call.

In that case, I'd use either of the managed dialects of C++ (Managed
Extensions for C++ in VS2003 or C++/CLI in VS2005) to write your managed
component. That's because MC++ and C++/CLI are the only managed languages
from MS which allow you to mix managed and native code in the same
application. In fact you can have modules which contain both managed and
unmanaged functions. And when you call across the managed / native divide
the compiler does what's necessary to make the transition happen without
effort on the developer's part. Once you have an MC++ or C++/CLI component,
any other managed component can make use of it in the same way that a
component written in C# can make use of one written in Vb.Net.

You can search MSDN for "it just works" aka IJW as this interoperability was
called in VS2003 or "C++ interop" as it is called in VS2005.

Regards,
Will

www.ivrforbeginners.com (Speech enabled telephony without tears)

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.