.NET/C# Client#

This guide provides step-by-step instructions for running a Dlubal API client on .NET 8, .NET 9, and .NET 10.

Supported Target Frameworks#

The Dlubal.Api package is multi-targeted and ships a separate assembly for each supported framework:

Package

Target frameworks

Use it for

Dlubal.Api

net8.0, net9.0, net10.0

Modern .NET projects (this guide)

Dlubal.Api.NetFramework

net48

Projects that cannot target modern .NET — see .NET Framework/C#

There is nothing to choose or configure. NuGet reads the TargetFramework of your project and resolves the matching assembly automatically during dotnet restore, so a net8.0 project and a net10.0 project both install the same package.

Prerequisites#

Before you begin, ensure your system meets the following requirements:

  1. Install the .NET SDK (version .NET 8.0 or later).

    • You’ll need the .NET SDK to install and use NuGet packages in a .NET-based project.

    • Install the SDK for the framework your project targets. There is no need to upgrade an existing .NET 8 project in order to use the API client.

    • Verify the installation by running:

      dotnet --version
      
  2. Install Visual Studio Code with the C# Dev Kit extension:

    • Open the Extensions view by pressing Ctrl+Shift+X.

    • Search for C# Dev Kit and click Install.

Create a New Project#

  1. Open Visual Studio Code.

  2. Create a New Project with the C# Dev Kit installed:

    • Open the Command Palette by pressing Ctrl+Shift+P

    • Type .NET: New Project... and select it from the list.

    • Choose Console App or another project type from the options.

    • Follow the prompts to select a project template, the target framework, and the location to create the project.

      Any of .NET 8.0, .NET 9.0, or .NET 10.0 works with the API client.

  3. Opening the Project

    • Once the project is created, VS Code will automatically open the folder containing your project, so you can start working directly on it.

Install the Dlubal API Package#

  1. Installing NuGet package from the Terminal (CLI)

    • Open the Terminal in your project directory (press Ctrl+`)

    • Run the following command to install the Dlubal API package into your project.

      dotnet add package Dlubal.Api
      
    • If you need to install a specific version of the package (for example, version 2.14.8), you can do so by appending the --version flag followed by the desired version number:

      dotnet add package Dlubal.Api --version 2.14.8
      

    Important

    The API client version must match the version of your Dlubal application to ensure full compatibility. For example, API client version 2.14.8 corresponds to RFEM 6.14.0008 / RSTAB 9.14.0008.

    Changed in version 2.15.9: The Dlubal.Api NuGet package supports net8.0, net9.0, and net10.0. Versions 2.14.1 through 2.15.8 targeted net9.0 only; projects that stayed on 2.13.12 for that reason can now upgrade without retargeting.

  2. Verify the Installation

    • Run the following command

      dotnet list package
      
    • Ensure Dlubal.Api appears in the list of installed packages.

Using the Package#

using System;
using Rfem = Dlubal.Api.Rfem;
using Common = Dlubal.Api.Common;

ApplicationRfem? rfemApp = null;

try
{
   rfemApp = new ApplicationRfem();

   Common.ApplicationInfo appInfo = rfemApp.get_application_info();
   Console.WriteLine(appInfo);

   // Create a new model
   rfemApp.create_model(name: "my_first_model");

   // Create a single node at coordinates [1.0, 2.0, 3.0] (in meters)
   rfemApp.create_object(
      new Rfem.StructureCore.Node
      {
         No = 1,
         Coordinate1 = 1.0,
         Coordinate2 = 2.0,
         Coordinate3 = 3.0
      }
   );
   Console.WriteLine("Created node No. 1.");
}

catch (Exception ex)
{
   Console.WriteLine($"Error: {ex.Message}");
}
finally
{
   if (rfemApp != null) rfemApp.close_connection();
}

For details on API key options and config.ini management, see the Authentication documentation.