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)