ComLightInterop 2.0.0

Requires NuGet 3.4.4 or higher.

dotnet add package ComLightInterop --version 2.0.0                
NuGet\Install-Package ComLightInterop -Version 2.0.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="ComLightInterop" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ComLightInterop --version 2.0.0                
#r "nuget: ComLightInterop, 2.0.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 ComLightInterop as a Cake Addin
#addin nuget:?package=ComLightInterop&version=2.0.0

// Install ComLightInterop as a Cake Tool
#tool nuget:?package=ComLightInterop&version=2.0.0                

This package implements a lightweight cross-platform COM interop library for Windows and Linux. Specifically, it allows to expose C++ objects to .NET, and .NET objects to C++. The current version targets 3 platforms: .NET framework 4.7.2, .NET 8.0, and VC++.

The library is designed under the assumption the entry point of your program is a .NET application which needs to use unmanaged C++ code compiled into a native DLL.

By 2024, I have used the library extensively in multiple projects which target Win32, Win64, also Linux running on AMD64, ARMv7, and ARM64 CPUs. Some of these Linuxes were Alpine, the C++ side of the interop is very simple, does not even depend on glibc.

The library only uses good part of the COM, which is the IUnknown ABI. It does not implement type libraries. It’s your responsibility to write both C++ and C# language projections of the COM interfaces you use. The included C++ headers, and C# custom attributes, make it easy to do so.

The interop is limited to COM objects implemented by DLLs running within the current process. The library only supports IUnknown-based COM interfaces, it doesn’t understand IDispatch. You can only use simple types in your interfaces: primitives, structures, strings, pointers, arrays, function pointers, but not VARIANT or SAFEARRAY.

It doesn’t prevent you from calling the same COM object by multiple threads concurrently i.e. it doesn’t have a concept of apartments and treats all objects as free threaded. If you call your objects concurrently, it’s your responsibility to make sure your objects are thread safe and reentrant.

It does not implement class IDs or type registration. A class factory for C++ implemented objects is merely a C function which returns IUnknown-derived interface in an output parameter.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on ComLightInterop:

Package Downloads
WhisperNet

High-performance GPGPU inference of OpenAI's Whisper automatic speech recognition (ASR) model

VrmacGraphics

Vrmac graphics engine

Cgml

GPU-targeted vendor-agnostic AI library for Windows

WhisperNet-TimestampFix

High-performance GPGPU inference of OpenAI's Whisper automatic speech recognition (ASR) model

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on ComLightInterop:

Repository Stars
VRCWizard/TTS-Voice-Wizard
Speech to Text to Speech. Song now playing. Sends text as OSC messages to VRChat to display on avatar. (STTTS) (Speech to TTS) (VRC STT System) (VTuber TTS)
Const-me/Vrmac
Vrmac Graphics, a cross-platform graphics library for .NET. Supports 3D, 2D, and accelerated video playback. Works on Windows 10 and Raspberry Pi4.
Version Downloads Last updated
2.0.0 175 8/19/2024
1.3.8 786 11/8/2023
1.3.7 7,089 4/4/2020
1.3.6 491 3/30/2020
1.3.5 449 3/30/2020
1.3.4 540 3/15/2020
1.3.3 509 3/12/2020
1.3.2 485 3/2/2020
1.3.1 551 2/29/2020
1.3.0 584 2/28/2020
1.2.0 500 2/24/2020
1.1.0 535 8/31/2019
1.0.0 518 8/30/2019

Upgraded .NET runtime to 8.0. The final version which supports older versions of .NET Core runtime is 1.3.8.

In addition to .NET 8, the current version of the library fully supports legacy .NET framework 4.7.2 or newer.

Bugfix, C# objects passed to C++ are protected from GC for the duration of the C++ call, using `GC.KeepAlive` in the runtime-generated code.