Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load FMU with Femyou not working #6

Open
bflo96 opened this issue Sep 20, 2024 · 1 comment
Open

Load FMU with Femyou not working #6

bflo96 opened this issue Sep 20, 2024 · 1 comment

Comments

@bflo96
Copy link

bflo96 commented Sep 20, 2024

Hello!

I have a program in C#, running on Visual Studio 2019, with target framework netcoreapp3.1.
I used Open Modelica v1.22.3 (64-bit).

My code:

using System;
using System.Collections.Generic;
using System.Text;

namespace TesteFMU
{
    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 load the FMU, it shows this error:

System.IO.FileNotFoundException: 'Could not find or load the native library: C:\Users\10376\AppData\Local\Temp\Femyou\TestarFemyou.fmu\binaries\win64\TestarFemyou.dll

I don't understand why it tries to load a native library and why it fails despite the DLL being available when I manually check the folder.
Could it be a compatibility issue?
The example BouncingBall.fmu works just fine.

Thank you!

@Oaz
Copy link
Owner

Oaz commented Sep 21, 2024

My best guess here would be to check the dependencies of TestarFemyou.dll and make sure that they are all included in TestarFemyou.fmu
Missing dependencies is a common case of dll loading error.
I have not used MS Windows for a long time but, if I remember correctly, a free tool such as DependenciesWalker could help : https://dependencywalker.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants