Trying to use Femyou to run FMU (OpenModelica) but shows error “Could not find or load the native library”

I am running Visual Studio 2019. I am relatively new to this.
I need to use the Nuget Femyou, which is only available for NetStandard 2.1. (edit) I also installed the nuget NativeLibraryLoader. I initially put the target framework as .NET Standard 2.1, but I later changed to .NET CORE 3.1 after some help.

My code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> using System;
using System.Collections.Generic;
using System.Text;
namespace TesteFMU_set2024
{
public class Program
{
public static void Main(string[] args)
{
TestFMU test = new TestFMU();
test.Calculation();
Console.Write("Calculation concluded.");
}
}
using System;
using Femyou;
using System.IO;
namespace TestFMU
{
public class TestFMU
{
public void Calculation()
{
string fmuFolder = File.ReadAllText(@"C:FMUTests");
using var model = Model.Load(Path.Combine(fmuFolder, "TestFemyou.fmu"));
using var instance = Tools.CreateInstance(model, "test");
var x = model.Variables["x"];
var y = model.Variables["y"];
var z = model.Variables["z"];
Console.WriteLine("x = " + Convert.ToString(x));
}
}
}
</code>
<code> using System; using System.Collections.Generic; using System.Text; namespace TesteFMU_set2024 { public class Program { public static void Main(string[] args) { TestFMU test = new TestFMU(); test.Calculation(); Console.Write("Calculation concluded."); } } using System; using Femyou; using System.IO; namespace TestFMU { public class TestFMU { public void Calculation() { string fmuFolder = File.ReadAllText(@"C:FMUTests"); using var model = Model.Load(Path.Combine(fmuFolder, "TestFemyou.fmu")); using var instance = Tools.CreateInstance(model, "test"); var x = model.Variables["x"]; var y = model.Variables["y"]; var z = model.Variables["z"]; Console.WriteLine("x = " + Convert.ToString(x)); } } } </code>
   using System;
   using System.Collections.Generic;
   using System.Text;

   namespace TesteFMU_set2024
   {
      public class Program
      {
         public static void Main(string[] args)
         {
            TestFMU test = new TestFMU();
            test.Calculation();
            Console.Write("Calculation concluded.");
         }
      }

using System;
using Femyou;
using System.IO;

namespace TestFMU
{
    public class TestFMU
    {
        public void Calculation()
        {
            string fmuFolder = File.ReadAllText(@"C:FMUTests");
            using var model = Model.Load(Path.Combine(fmuFolder, "TestFemyou.fmu"));
            using var instance = Tools.CreateInstance(model, "test");
            var x = model.Variables["x"];
            var y = model.Variables["y"];
            var z = model.Variables["z"];
            Console.WriteLine("x = " + Convert.ToString(x));
        }
    }
}

However, when I try to run it, I get this error on the console:

An unhandled exception of type ‘System.IO.FileNotFoundException’
occurred in NativeLibraryLoader.dll Could not find or load the native
library:
C:UserAppDataLocalTempFemyouTestFemyou.fmubinarieswin64TestFemyou.dll


> *Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ‘netstandard, Version=2.1.0.0, Culture=neutral,
> PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The
> system cannot find the file specified.*

And this error on the output:

The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core. The program ‘[14520] TesteFMU_set2024.dll’ has exited with code -532462766 (0xe0434352).

I checked Visual Studio Installer, but I can’t figure what might be missing of .NET Core that is relevant to NetStandard 2.1. This is what I don’t have installed:

  • .NET 5.0 Runtime (out of support)
  • .NET Core 2.1 Runtime (out of support)
  • .NET Core 2.2 Runtime (out of support)
  • .NET Core 3.0 Runtime (out of support)
  • .NET Core 3.1 Runtime (out of support)
  • .NET Framework 3.5 development tools
  • .NET Framework 4.6.1 SDK
  • .NET Framework 4.6.2 SDK
  • .NET Framework 4.6.2 targeting pack
  • .NET Framework 4.7 SDK
  • .NET Framework 4.7 targeting pack
  • .NET Framework 4.7.1 SDK
  • .NET Framework 4.7.1 targeting pack
  • .NET Framework 4.7.2 SDK
  • .NET Framework 4.8 targeting pack
  • .NET Native
  • .NET Portable Library targeting pack
  • .NET SKD (out of support)
  • Development Tools plus.NET COre 2.1 (out of support)
  • Web Development Tools plus .NET Core 2.1 (out of support)

Am I missing something?
Thank you in advance!

New contributor

Beatriz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

6

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật