Example usage in Visual Studio - shmishleniy/DLLExprorter GitHub Wiki
Steps
- Add to your project attribute definition:
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class DllExport : Attribute { }
- Add to post-buid in your project (Project Properties -> Build Events -> Post-build event command line)
D:\DLLExprorter.exe -in:"$(TargetPath)" -out:"D:\OutputFolder\$(TargetFileName)"
or with -noclean argument to save *.il and *.res
D:\DLLExprorter.exe -in:"$(TargetPath)" -out:"D:\OutputFolder\$(TargetFileName)" -noclean
- Mark method to export
[DllExport]
public static int Foo(int i)
{
return i*i;
}
-
Build you project
-
Console output
1> ------ DLLExporter Start ------
1> Copying dll:
1> from: C:\Users\Andrey\documents\visual studio 2012\Projects\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll
1> to: D:\OutputFolder\ClassLibrary1.dll
1> Processing: ClassLibrary1.dll
1> Find 1 methods:
1> - Foo
1> Export Successful
1> Clean output folder (remove *.il and *.res). To disable run with -noclean argument.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
- Now you can invoke C# method from C++ or other languages.