У меня есть основной проект dotnet, который использует Net.IBM.Data.Db2 и отлично работает как в Windows, так и в Linux. Сейчас я пытаюсь запустить его на Apple Macbook M3 Pro, используя Net.IBM.Data.Db2-osx, но получаю следующую ошибку во время выполнения:
System.IO.FileNotFoundException: Could not load file or assembly 'IBM.Data.Db2, Version=8.0.0.200, Culture=neutral, PublicKeyToken=7c307b91aa13d208'. The system cannot find the file specified.
Мое консольное приложение содержит следующий код.
ConsoleApp1.csproj:
Exe
net8.0
enable
enable
Program.cs:
// See https://aka.ms/new-console-template for more information
using IBM.Data.Db2; // note: this is correct, Net.IBM.Data.Db2 does not work
using Dapper;
using System.Data;
Console.WriteLine("Start");
string CONNECTION_STRING = "Server=db.foo.com:50000;Database=foo;UID=foo;PWD=bar;";
var sql = "select * from ST004.students";
using (var connection = new DB2Connection(CONNECTION_STRING))
{
var rows = await connection.QueryAsync(sql);
Console.WriteLine(rows);
}
Console.WriteLine("End");
Приведенный выше код вызывает следующую ошибку времени выполнения:
Exception has occurred: CLR/System.IO.FileNotFoundException
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Private.CoreLib.dll: 'Could not load file or assembly 'IBM.Data.Db2, Version=8.0.0.200, Culture=neutral, PublicKeyToken=7c307b91aa13d208'. The system cannot find the file specified.'
at Program.d__0.MoveNext() in /Users/me/dev/ConsoleApp1/ConsoleApp1/Program.cs:line 17
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at Program.$(String[] args) in /Users/me/dev/ConsoleApp1/ConsoleApp1/Program.cs:line 6
at Program.(String[] args)
Подробнее здесь: https://stackoverflow.com/questions/783 ... on-mac-osx