.NET Framework/C##

This guide provides step-by-step instructions for running a Dlubal API client on .NET Framework. Use this package when your project cannot target modern .NET — for example, a plugin or add-in hosted inside an existing .NET Framework application. For new projects targeting .NET 9 or higher, use .NET/C# Client instead.

Prerequisites#

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

  1. Install the .NET Framework 4.8 Developer Pack.

    • This provides the targeting and reference assemblies required to build against net48.

    • It is included with Visual Studio when the .NET desktop development workload is selected.

  2. Install a build toolchain — either:

    • Visual Studio (recommended on Windows), or

    • the .NET SDK, which lets you build SDK-style net48 projects from the command line with dotnet build.

      dotnet --version
      
  3. (Optional) 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#

Create a console application that targets .NET Framework 4.8.

  • In Visual Studio: choose Console App (.NET Framework) and select .NET Framework 4.8 as the target framework.

  • From the CLI (SDK-style project): create the project and set the target framework to net48:

    dotnet new console -o DlubalApiSample
    

    Then edit the generated .csproj so it targets net48:

    <TargetFramework>net48</TargetFramework>
    

Install the Dlubal API Package#

  1. Installing the 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.NetFramework
      
    • If you need to install a specific version of the package (for example, version 2.14.10), you can do so by appending the --version flag followed by the desired version number:

      dotnet add package Dlubal.Api.NetFramework --version 2.14.10
      
    • In Visual Studio you can instead use the Package Manager Console:

      Install-Package Dlubal.Api.NetFramework -Version 2.14.10
      

    Important

    The API client version must match the version of your Dlubal application to ensure full compatibility. For example, API client version 2.14.10 corresponds to RFEM 6.14.0010 / RSTAB 9.14.0010.

  2. Verify the Installation

    • Run the following command

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

Using the Package#

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

class Program
{
   static void Main(string[] args)
   {
      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.