Alternative approach to your usual P/Invoke!
Use C# interfaces to bind to native code - quick and easy usage of C API in C# code, on any platform.
Gone are the days of broken DllImport
and annoying workarounds for the different runtimes.
Fully compatible with Mono, .NET Framework, .NET Core, and .NET Standard. Compatible with Mono DLL mapping on all platforms and runtimes. Configurable and adaptible.
extern
. Use your native API as if it were first-class objects.Read the Docs, or install via NuGet and get started.
Nullable<T>
and string
without any extra codeDeclare your interface
public interface IMyNativeLibrary
{
long MyNativeGlobal { get; set; }
int MyNativeMultiply(int a, int b);
void MyOtherNativeFunction(MyStruct strct, ref MyStruct? maybeStruct);
}
Activate it
const string MyLibraryName = "MyLibrary";
var activator = new NativeLibraryBuilder();
var library = activator.ActivateInterface<IMyNativeLibrary>(MyLibraryName);
Use it
library.MyNativeGlobal = 10;
var result = library.MyNativeMultiply(5, 5);
var myStruct = new MyStruct();
MyStruct? myOtherStruct = null;
library.MyOtherNativeFunction(myStruct, ref myOtherStruct);
See the Quickstart for more information.
Get it on NuGet!
If the library's license doesn't fit your project or product, please contact us. Custom licensing options are available, and we are always open to working something out that fits you - be it modified, commercial, or otherwise.
AdvancedDLSupport's public release is licensed under the GNU Lesser General Public License, Version 3 (LGPLv3). See the LICENSE for details. Without the support of the open-source movement, it would never have existed.