views:

34

answers:

1

Hi all,

I allready asked at:

Is it possible to call unmanaged code using C# reflection from managed code ?

if it is possible to call C/C++ library unmanaged function with Invoke and reflection from .NET and the answer is yes. What I am not clear about is can I call using P/Invoke ANY assembly written/compiled/build with other compilers on my Windows PC like Labwindows/CVI(have some kind of C compiler) or Java written dll's, exe. If this is possible is it the same as explained in above given link using "Marshal.GetDelegateForFunctionPointer" ?

Thanks! Milan.

A: 

With P/Invoke you can only call native unmanaged dlls which have listed functions they export in them. Java dlls are managed, written in some pseudocode (like IL in .net), only the java virtual machine knows how to interpret them.

For example, Borland's pascal had it's libraries in some "bpl" files. Pascal applications had compiled some bootstrap code which knew how to load these libraries, but other applications couldn't know how to use them.

So, you can use native dlls with exports and COM dlls.

František Žiačik
Thanks, 1. but how I can get information if some dll have list of function it export ? Or better to ask is there any dll which does not export list of function ?
milan
@milan: look here http://stackoverflow.com/questions/195571/is-there-a-tool-which-lists-exported-methods-from-a-dll
František Žiačik