Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Pull request Compare This branch is 56 commits behind jeikabu:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


.NET Core bindings for NNG.


Currently only works in projects targetting:

  • .NET Core App 1.0+
  • .NET Standard 1.5+
    • SuppressUnmanagedCodeSecurity is used with .NET Standard 2.0+ for improved PInvoke performance
  • .NET Framework 4.6.1+

After installing the package and building your output folder should have runtimes/ directory containing native binaries.

On .NET Core/Standard you can either use NngLoadContext (or your own AssemblyLoadContext) to load the appropriate native library and use NNG:

var path = Path.GetDirectoryName(typeof(Program).Assembly.Location);
var ctx = new nng.NngLoadContext(path);
var factory = nng.NngLoadContext.Init(ctx);
// Use factory...

.NET Framework 4.6.1

System.Runtime.Loader is not available in .NET Framework, so the correct assembly must be loaded by some other means.

If your application is targetting .Net Framework 4.6+ and you get lots of:

message NETSDK1041: Encountered conflict between 'Reference:XXX\.nuget\packages\subor.nng.netcore\0.0.5\lib\netstandard2.0\Microsoft.Win32.Primitives.dll' and 'Reference:Microsoft.Win32.Primitives'.  NETSDK1034: Choosing 'Reference:XXX\.nuget\packages\subor.nng.netcore\0.0.5\lib\netstandard2.0\Microsoft.Win32.Primitives.dll' because file version '4.6.26419.2' is greater than '4.6.25714.1'.


XXX\Properties\AssemblyInfo.cs(8,12,8,25): error CS0246: The type or namespace name 'AssemblyTitleAttribute' could not be found (are you missing a using directive or an assembly reference?)

Try adding the following to your project:


Build & Run

  1. Build: dotnet build
  2. Run: dotnet run or dotnet test tests

Updating nng native shared library:

  1. Download/clone nng source
  2. On Windows, create Command Prompt suitable for Visual Studio:
    • Run x64 Visual Studio Developer Command Prompt to create a 64-bit library (or x86 for 32-bit)
    • OR, run vcvars64.bat in cmd.exe (or vcvars32.bat)
  3. Make sure cmake and Ninja are in your PATH
  4. Run:
    mkdir build && cd build


Very pre-alpha. Using latest nng release (currently v1.1.0-rc). Once this is a bit farther along will track nng version numbers.

NuGet Build status Build status codecov

Implementation status of various APIs is as follows:

Core Functionality

Feature Pinvoke Wrapper Tests Notes
aio 100% 75% 75% Missing get/set_input/output/iov
ctx 100% 50% 50% Doesn't seem to be ctx-supported options other than nng_duration
dialer 75% 50% 50%
iov 0% 0% 0%
listener 75% 50% 50%
msg 75% 75% 75%
pipe 0% 0% 0%
socket 100% 50% 50% Missing synchronous methods and nng_getopt_string
raw socket 0% 0% 0% Low priority
compat 0% 0% 0% No plans to implement
TLS 0% 0% 0% Low priority
Http 0% 0% 0% No plans to implement
CV/Mtx/thread 0% 0% 0% No plans to implement

Protocols and Transports

Feature Pinvoke Wrapper Tests Notes
bus 75% 50% 25%
inproc 100% 50% 50%
ipc 100% 50% 50%
pair 0% 0% 0% Low priority
pub/sub 100% 50% 50%
push/pull 100% 50% 50%
req/rep 100% 50% 50%
respondent 0% 0% 0% Low priority
surveyor 0% 0% 0% Low priority
tcp 100% 50% 50%
tls 0% 0% 0% Low priority
ws 50% 25% 25%
zerotier 0% 0% 0% Low priority


nng.NETCore is meant to be a completely different approach than zplus/csnng (our fork of csnng). Namely:

  • Async first: using nng_aio and nng_ctx ready for async/await
  • Native layer: P/Invoke in separate files/namespace. Don't like our high-level OO wrapper? Re-use the pinvoke and make your own. Will also make it easier to do cross-platform-friendly pinvoke
  • Tests as Documentation: xUnit unit/integration tests in "plain" C# much like you'd write
  • .NET Core friendly: Using dotnet and targetting .NET Standard from the start
  • Simple class heirarchy (maybe) and minimal exceptions

See also runng. Our like-minded NNG binding/wrapper for Rust.

You can’t perform that action at this time.