Is there a way to have the particular DLL referenced by a P/Invoke (DllImport) signature depend on the CPU architecture?
I\'m working on an application that loads a
I developed a special library for the target: InteropDotNet. It introduces new RuntimeDllImport attribute with dynamical library path resolving (on the fly). In the default way, you can write
[RuntimeDllImport("NativeLib",
CallingConvention = CallingConvention.Cdecl, EntryPoint = "sum")]
int Sum(int a, int b);
And the library will be resolved depends on environment. For example, paths for Win/Linux, x86/x64:
x86/NativeLib.dll
x86/libNativeLib.so
x64/NativeLib.dll
x64/libNativeLib.so