JNA has a great collection of native functions, constants and structures. I need a similar library for C#. But I can not find anything after a lot of searching. Does anybody know any alternative for JNA library in C#?
Asked
Active
Viewed 980 times
2
-
What exactly are you trying to do, rather, which WinAPI are you trying to call in your Java code that can't be exposed through "normal" Java libraries? C# is a language that (typically) "links" against the .NET library; if there's a specific .NET function you need, you might check out `jni4net` (http://jni4net.com/) .. otherwise you'll probably have to COM/PInvoke/IPC if the Java API's don't have what you need. – txtechhelp Apr 14 '15 at 07:28
-
I am not asking it for any specific task/project. I need it to use it later in other projects in future. A library like JNA would help me greatly and reduce my workhour. – Dipu Apr 14 '15 at 07:33
1 Answers
2
I don't know a direct equivalent of JNA for C#. However, by using P\Invoke you can call any (or almost any) native function. Another aproach migh be to use COM Interop. Here is a general article about interoperability in C#.
As you said using P\Invoke might be troublesome. But, there is pinvoke web site which might be very helpful. It contains declarations of many native funcions, structures... ready to use.

Michał Komorowski
- 6,198
- 1
- 20
- 24
-
Yeah. I know that. But its a lot of pain to find values for constants and writing functions in every project. – Dipu Apr 14 '15 at 07:09
-
[pinvoke](http://www.pinvoke.net/) is indeed a great site. But I hope there is somebody who collected all of them and united them together. – Dipu Apr 14 '15 at 07:18