-
-
Notifications
You must be signed in to change notification settings - Fork 133
Quick start
Start with:
DllExport
-action Configure
~ ~ ~ --- ~ ~ ~
Since v1.6 provides new manager, you can configure your projects in a few seconds by the following steps below. For example:
- Get DllExport.bat into solution folder.
- Use command
-action Configure
- Or just click DllExport_Configure.bat if you can't above.
- Select some available projects for install operation, then configure this as you need.
- (optional) Define storage for your settings to get more automation.
- Click [Apply].
Now you're ready to provide exported-functions for unmanaged environments from your managed .NET projects.
For creating your first function: Just define DllExport
attribute for your favorite static methods.
For example:
[DllExport]
public static void hello() { }
[DllExport]
public static int hello(IntPtr ptr)
{
return 0;
}
You can also define specific calling convention and custom name:
[DllExport("Init", CallingConvention.Cdecl)]
// __cdecl is the default calling convention for our library as and for C and C++ programs
[DllExport(CallingConvention.StdCall)]
[DllExport("MyFunc")]
Since this operates under PInvoke, you should try to use only primitive/scalar types. It will be used anyway through internal marshaling, however, non-scalar types can require additional handling like for managed strings.
Thus, you need only scalar types in arguments/return value for your happy using. Use pointer to allocated data for any complex types if you need. For example, IntPtr
instead of String
.
Here, you can also find how to use any structures and strings: https://www.youtube.com/watch?v=QXMj9-8XJnY (Complex types and Strings).
Related:
Conari, to me, looks like a dynamic way of doing calling c++ libraries
It was developed for work with any data from unmanaged memory (including native or binary data from the heap) so it can help together with DllExport i.e. even if you have unmanaged host side that will communicate with CLR. You can even access to complex types like structures without their declaration at all.
It also contains different wrappers for types like unmanaged structures, unmanaged strings, and so on. See related screencasts.
But yes, the main features is an dynamic way of doing something with any pe-modules (exe, dll) when CLR is host side.
Except where otherwise noted, wiki content is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. (CC BY-SA 4.0).
🗎
- 🗎 Home
- 🗎 Quick start (+📹)
- 🗎 .Net Core
- 🗎 Export
- 🗎 Pre-processing
- 🗎 Conari support
- 🗎 ILMerge support
- 🗎 [x]AssemblyResolve
- 🗎 Post-processing
- 🗎 Examples
- 🗎 C++ ❤ C# (+📹)
- 🗎 String & struct (+📹)
- 🗊 Complete Examples
🗔
📂
- 📢 Q/A