Global Data Management Forum

 View Only
Expand all | Collapse all

Net.IBM.Data.Db2-osx not working

  • 1.  Net.IBM.Data.Db2-osx not working

    Posted Fri April 05, 2024 10:44 AM
    Edited by Piper Wilson Wed April 10, 2024 09:42 AM

    Hello,

    I have a dotnet core project using Net.IBM.Data.Db2 and it works with both Windows and Linux. I am now trying to get it to run on a Apple Macbook M3 Pro, however, it fails at run time with the following error:

    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.

    My console app contains the following code.

    ConsoleApp1.csproj:

    <Project Sdk="Microsoft.NET.Sdk">
    
        <PropertyGroup>
            <OutputType>Exe</OutputType>
            <TargetFramework>net8.0</TargetFramework>
            <ImplicitUsings>enable</ImplicitUsings>
            <Nullable>enable</Nullable>
        </PropertyGroup>
    
        <ItemGroup>
            <PackageReference Include="Dapper" Version="2.1.37" />
            <!-- <PackageReference Include="Net.IBM.Data.Db2" Version="8.0.0.200" Condition="$([MSBuild]::IsOsPlatform('Windows'))" /> -->
            <!-- <PackageReference Include="Net.IBM.Data.Db2-lnx" Version="8.0.0.200" Condition="$([MSBuild]::IsOsPlatform('Linux'))" /> -->
            <!-- <PackageReference Include="Net.IBM.Data.Db2-osx" Version="8.0.0.200" Condition="$([MSBuild]::IsOsPlatform('OSX'))" /> -->
            <PackageReference Include="Net.IBM.Data.Db2-osx" Version="8.0.0.200" />
    </ItemGroup>
    
    </Project>

    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");

    The above throws the following run time error:

    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.<<Main>$>d__0.MoveNext() in /Users/me/dev/ConsoleApp1/ConsoleApp1/Program.cs:line 17
       at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
       at Program.<Main>$(String[] args) in /Users/me/dev/ConsoleApp1/ConsoleApp1/Program.cs:line 6
       at Program.<Main>(String[] args)

    The same project works perfectly fine on Windows and Linux so I'm at a loss as to what could be wrong.



    ------------------------------
    Tariq M
    ------------------------------



  • 2.  RE: Net.IBM.Data.Db2-osx not working