-
-
Notifications
You must be signed in to change notification settings - Fork 133
Quick start
Starting with v1.6 you can configure your projects in a few seconds by the following steps below through new manager.
Detailed first configuring looks like:
- Get this (~19 Kbytes) into solution folder. Then, just [Click it] (or command this)
- Select preferred projects to install and configure as you need.
- (optional) Define storage for your settings to get more automation.
- Click [Apply].
Now you're ready to export.
Still not sure? See Various cases in a few steps (Screencast) πΉ
To Upgrade Version, use this command. Or starting with 1.7-RC you can also use GUI updater. [?]
To create first exported 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")]
<DllExport>
Public Shared Sub hello()
' ...
End Sub
<DllExport>
Public Shared Function hello(ByVal ptr As IntPtr) As Integer
Return 0
End Function
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")>
See also complete examples, like π Basic communication with managed .NET libraries from unmanaged native C++
You can configure our tool for any related namespaces in your projects for some additional purpose or just for your convenience in your work.
It's safe because the final modified .net module (.dll or .exe) will not contain any links with our libraries.
The most standardized namespace is System.Runtime.InteropServices
. However, we recommend to isolate this within the individual project for future incompatible modification from Microsoft.
Since this operates under P/Invoke, you need only primitive/scalar types. It will be used anyway through internal marshaling, however, non-scalar types can require additional handling like for managed strings.
About default marshaling behavior you can read here:
So you can try to use MarshalAsAttribute, e.g.: [MarshalAs(UnmanagedType...
. Or try to use only scalar types in arguments/return value for your happy using. It's more powerful way to control anything. And it's enough for work with any types, like:
- Pointer to allocated data for any complex types if you need. ~
IntPtr
instead ofString
.
Here, you can also find how to use any structures and strings: https://www.youtube.com/watch?v=QXMj9-8XJnY (wiki: π Complex types and Strings).
Related:
Our .NET DllExport is ready for .NET Core projects starting with v1.7 release
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.
This is an dynamic way of doing something with any pe-modules (exe, dll) when CLR is host side.
- Our examples are waiting you, here: [ Examples ]
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 (+πΉ)
- π Configuring
- π First function
- π Data types
- π .Net Core
- π Export
- π Pre-processing
- π Conari support
- π ILMerge support
- π [x]AssemblyResolve
- π Post-processing
- π Examples
- π C++ β€ C# (+πΉ)
- π String & struct (+πΉ)
- π Complete Examples
π
- π DllExport Manager
π
- π’ Q/A