开发者

What kind of assemblies can be called using P/Invoke?

开发者 https://www.devze.com 2023-01-03 18:20 出处:网络
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 reflectio

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消