DllExporterNet4 2.1.0

dotnet add package DllExporterNet4 --version 2.1.0
NuGet\Install-Package DllExporterNet4 -Version 2.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DllExporterNet4" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DllExporterNet4 --version 2.1.0
#r "nuget: DllExporterNet4, 2.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DllExporterNet4 as a Cake Addin
#addin nuget:?package=DllExporterNet4&version=2.1.0

// Install DllExporterNet4 as a Cake Tool
#tool nuget:?package=DllExporterNet4&version=2.1.0

Usage: Mark the methods you'd like to expose as native code public functions with the [DllExport] attribute like this:

[DllExport]
public static int ShowGUI(int iDestProjNo, [MarshalAs(UnmanagedType.LPTStr)] string sTemplateFileName)
{
    return 0;
}

As a post-build event, call the exe which generates the .il disassembly file, processes it and reassemble it into a .dll like this:

DllExporterNet4.exe $(TargetFileName)
copy $(TargetName).Exports$(TargetExt) $(TargetFileName)

Use LoadLibrary() and GetProcAddress() to call function from native code or just refer to the DLL and function name for cases where add-ins are used.

typedef int(__stdcall* LPSHOWGUIFUNC)(int, LPTSTR);
HINSTANCE hDLL;

hDLL = LoadLibrary(L"DCWGUIx64.dll");

LONG iNewDocId = 0;

if (hDLL != NULL)
{
	// note ANSI string for function name
	LPSHOWGUIFUNC lpfnDllShowGui = (LPSHOWGUIFUNC)GetProcAddress(hDLL, "ShowGUI");

	if (lpfnDllShowGui)
	{
		LPTSTR lptSourceFile = sSourceFile.GetBuffer(0);
		sSourceFile.ReleaseBuffer();
		iNewDocId = lpfnDllShowGui(lDestProjId, lptSourceFile);
	}
	FreeLibrary(hDLL);
}
Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 155 5/15/2024
2.0.0 88 5/14/2024
1.0.1 941 2/3/2022
1.0.0 1,024 2/21/2019

Updated this to use Windows 10 SDK.