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:
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!
Beatriz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
6