Every premium and members-only resource for $9.99/month, as a no-commitment subscription. See the plans

PalateKit

Menu

Request a resource

Describe the resource you are missing in one sentence. We will email you when it is published.

0 / 280

Unlock PalateKit

Unlock everything

Plan

Paying means accepting our terms of sale.

Secure payment by Stripe. Receipts and invoices sent by email.

Welcome back

Sign in to install, download or save this resource. A free account is enough for free resources.

Call native libraries with P/Invoke v1.0.0

Use this resource to write, review or fix P/Invoke calls to a C or C++ library

New

  • 524 downloads
  • 158 likes
  • 121 saves

Free

Install with the CLI

In a terminal, from the folder you want:

npx --yes palatekit@latest install dotnet-native-interop-pinvoke

With no option, the skill goes to ~/.agents/skills/; add --agent claude-code (or codex, cursor…) to target an agent.

First time: connect the CLI with

npx --yes palatekit@latest login

The agent chooses between DllImport and LibraryImport, maps native types to .NET types and establishes memory ownership. It uses SafeHandle for native handles and handles errors at the managed and native boundary.

Mostly picked by

Updated November 2, 2026

Card for the “Call native libraries with P/Invoke” skill

Details

Generates with
Your agent's model
Licence
MIT

Similar resources

View all

What you get

  • SKILL.md: declaration steps, string marshalling and error handling
  • references/type-mapping.md and diagnostics.md: type mapping and crash diagnosis

Good fit for

  • Your app crashes or corrupts data when calling a native DLL
  • You wrap a C library to use it from .NET 8

Not for

    Tags

    • p/invoke
    • native
    • interop
    • memory

    About

    You say

    “Write the LibraryImport declaration for this C function that returns an allocated string.”

    Card for the “Call native libraries with P/Invoke” skill

    Skill published by dotnet under the MIT license, delivered in its original version.

    Show more

    How to use it

    1. Install the skill in your agent's skills folder
    2. Ask your agent to write, review or fix P/Invoke calls to a C or C++ library
    3. Review and adjust the result

    Content preview

    Files

    • LICENSE1.1 KB
    • NOTICE-PALATEKIT.md0.5 KB
    • references/diagnostics.md3.6 KB
    • references/type-mapping.md3 KB
    • SKILL.md19.2 KB

    Origin and licence

    Listed unmodified

    Author
    dotnet
    Source
    github.com/dotnet/skills/tree/586f13f8d898a60583a3364f146a3b6f5a763164/plugins/dotnet-advanced/skills/dotnet-pinvoke
    Licence
    MIT

    Notice

    « dotnet-pinvoke » (dotnet, MIT) livré dans sa version d'origine : fiche en français et en anglais par PalateKit.

    User reviews

    –

    No ratings yet

    Loading reviews…

    Delete your review?

    Your rating and comment will be removed from the page.