Skip to main content
All CollectionsGetting started with MeshLibС#
How to install MeshLib with C# for 3D Geometry Applications
How to install MeshLib with C# for 3D Geometry Applications

This article will guide you through integrating MeshLib into your C# project using two methods: via NuGet and a manual distribution setup.

Updated over 4 months ago

MeshLib is an open-source 3D geometry library designed to streamline the creation of powerful 3D applications. It provides an extensive range of functionalities for manipulating and analyzing 3D meshes, making it a valuable tool for developers in fields such as computer graphics, computational geometry, and simulation. This article will guide you through integrating MeshLib into your C# project using two methods: via NuGet and a manual distribution setup.

1. Installation via NuGet

The easiest way to incorporate MeshLib into your C# project is by using NuGet, a popular package manager for .NET. Here’s how you can do it:

  1. Open your C# project in Visual Studio:

    • Right-click on the project in the Solution Explorer.

    • Select "Manage NuGet Packages" from the context menu.

  2. Search for MeshLib:

    1. In the NuGet Package Manager, go to the Browse tab.

    2. Enter "MeshLib" in the search box.

  3. Install MeshLib:

  • Find the MeshLib package in the search results and click "Install".

  • Follow any additional prompts to complete the installation.

Once installed, you can start using MeshLib in your project by adding using MR.DotNet; at the top of your C# files.

2. Manual Distribution Setup

For situations where you prefer or need to manually integrate the library, follow these steps using the MeshLibDotNetDist.zip distribution. This method involves including the necessary DLLs directly in your project.

Steps:

  1. Download the Distribution:

    • Obtain the MeshLibDotNetDist.zip file, which contains the compiled dynamic libraries (.dll files) for MeshLib and any dependent third-party libraries.

  2. Create a New C# Project:

    • In Visual Studio, create a new C# project or open an existing one.

  3. Modify the Project File:

    • In Solution Explorer, double-click on the project file (with a .csproj extension) to open it.

    • Add the following lines before the closing </Project> tag:

       <PropertyGroup>
      <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
      <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
      </PropertyGroup>

      <ItemGroup>
      <Reference Include="MRDotNet">
      <HintPath>path\to\distribution\$(Configuration)\MRDotNet.dll</HintPath>
      </Reference>
      </ItemGroup>
    • Replace path\to\distribution with the actual path where the DLLs are extracted.

  4. Extract the DLLs:

    • Extract the contents of MeshLibDotNetDist.zip to your project's bin directory. This ensures that the dynamic libraries are available during build and runtime.

  5. Using MeshLib:

    • Reference the extracted DLLs in your project by adding using MR.DotNet; in your C# files, allowing you to access MeshLib functionalities.

Important Note

MeshLib distribution currently supports x64 builds only. Ensure your project configuration aligns with this to avoid compatibility issues.

By following these steps, you can harness the power of MeshLib to develop advanced 3D applications with ease. Whether you choose the NuGet method for convenience or the manual setup for more control, MeshLib offers robust tools for working with 3D geometry in C#.

Did this answer your question?