dotnet-native-interop

Installation
SKILL.md

dotnet-native-interop

Platform Invoke (P/Invoke) patterns for calling native C/C++ libraries from .NET: [LibraryImport] (preferred, .NET 7+) vs [DllImport] (legacy), struct marshalling, string marshalling, function pointer callbacks, NativeLibrary.SetDllImportResolver for cross-platform library resolution, and platform-specific considerations for Windows, macOS, Linux, iOS, and Android.

Version assumptions: .NET 7.0+ baseline for [LibraryImport]. [DllImport] available in all .NET versions. NativeLibrary API available since .NET Core 3.0.

Scope

  • LibraryImport (.NET 7+) and DllImport declarations
  • Struct and string marshalling patterns
  • Function pointer callbacks and delegates
  • NativeLibrary.SetDllImportResolver for cross-platform resolution

Out of scope

  • AOT-specific P/Invoke concerns (direct pinvoke) -- see [skill:dotnet-native-aot]
  • COM interop and CsWin32 source generator -- see [skill:dotnet-winui]
  • WASM JavaScript interop (JSImport/JSExport) -- see [skill:dotnet-aot-wasm]
Related skills

More from novotnyllc/dotnet-artisan

Installs
4
GitHub Stars
208
First Seen
Feb 24, 2026