Skip to content

Tweety-Lab/NetLeaf

Repository files navigation

NetLeaf

A Simplified way to run C# from native C++ Apps.

NetLeaf allows simple and fast .NET C# Hosting from C++ Code through a handful of easy to understand methods.

License Release

Features

Feature Supported
Class Instances ✔️
Method Running ✔️
Method Arguments ✔️
Method Return Values ✔️

NetLeaf utilises the .NET Runtime to support .NET 9.0.0 by default.

Getting Started

Once you have NetLeaf installed and NetLeaf.h included in your file, you can get started with just a few calls.

Load NetLeaf with a .NET Runtime backend:

#include "NetLeaf/DotNetBackend.h"
NetLeaf::LoadCSharpBackend(new DotNetBackend());

Load a C# Assembly:

NetLeaf::LoadAssembly("AssemblyName.dll");

Run a Static C# Method:

NetLeaf::RunCSharpMethod("Namespace.ClassName.MethodName()");

Create an Instance of a C# Class:

NetLeaf::CreateInstance("Namespace.ClassName");

Create an Instance and run one of it's Methods:

NetLeafInstance* instance = NetLeaf::CreateInstance("Namespace.ClassName");
instance->RunMethod("MethodName()");

Building

Prerequisites

Premake5

Windows

  1. Navigate to the Repo
  2. Open a Command Prompt
  3. Build with the appropriate Premake5 Command (i.e., premake5 vs2022 for Visual Studio 2022)

About

A Simplified way to run C# from native C++ Apps.

Resources

License

Stars

Watchers

Forks

Packages

No packages published