Global Data Management Forum

Expand all | Collapse all

Could not load file or assembly 'IBM.Data.Db2, Version=5.0.0.200, Culture=neutral, PublicKeyToken=7c307b91aa13d208' - Azure WebJobs

  • 1.  Could not load file or assembly 'IBM.Data.Db2, Version=5.0.0.200, Culture=neutral, PublicKeyToken=7c307b91aa13d208' - Azure WebJobs

    Posted Thu April 22, 2021 11:29 AM

    Hi,

    This a console app - deployed in Azure - WebJobs. I'm getting the error below:

    [04/22/2021 13:55:36 > 8d1531: INFO] D:\local\Temp\jobs\triggered\sml.globe.track.app\spurlx43.yod>dotnet sml.globe.track.app.dll
    [04/22/2021 13:55:38 > 8d1531: ERR ] Unhandled exception. System.BadImageFormatException: Could not load file or assembly 'IBM.Data.Db2, Version=5.0.0.200, Culture=neutral, PublicKeyToken=7c307b91aa13d208'. An attempt was made to load a program with an incorrect format.
    [04/22/2021 13:55:38 > 8d1531: ERR ] File name: 'IBM.Data.Db2, Version=5.0.0.200, Culture=neutral, PublicKeyToken=7c307b91aa13d208'
    [04/22/2021 13:55:38 > 8d1531: ERR ] at sml.globe.track.library.Infrastructure.Data.DBConnectionFactory.CreateDbConnection(DatabaseConnectionName connectionname)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at sml.globe.track.library.Infrastructure.Repositories.Db2BaseRepository..ctor(IDbConnectionFactory dbConnectionFactory) in C:\Users\luis.barahona\source\repos\Sml.Globe.Track.App\sml.globe.track.library\Infrastructure\Repositories\Db2BaseRepository.cs:line 13
    [04/22/2021 13:55:38 > 8d1531: ERR ] at sml.globe.track.library.Infrastructure.Repositories.BookingCustomerRepository..ctor(IDbConnectionFactory connection, IConfiguration config, ILogger`1 log) in C:\Users\luis.barahona\source\repos\Sml.Globe.Track.App\sml.globe.track.library\Infrastructure\Repositories\BookingCustomerRepository.cs:line 19
    [04/22/2021 13:55:38 > 8d1531: ERR ] at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
    [04/22/2021 13:55:38 > 8d1531: ERR ] at sml.globe.track.app.Program.Main(String[] args) in C:\Users\luis.barahona\source\repos\Sml.Globe.Track.App\Sml.Globe.Track.Sync\Program.cs:line 19
    [04/22/2021 13:55:38 > 8d1531: ERR ] at sml.globe.track.app.Program.<Main>(String[] args)
    [04/22/2021 13:55:38 > 8d1531: SYS INFO] Status changed to Failed
    [04/22/2021 13:55:38 > 8d1531: SYS ERR ] Job failed due to exit code -532462766

    This application works on my dev machine without any issue. 

    Project configuration:
     
    <Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
    <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <PlatformTarget>x64</PlatformTarget>
    </PropertyGroup>
    <ItemGroup>
    <PackageReference Include="IBM.Data.DB2.Core" Version="3.1.0.400" />
    <PackageReference Include="IBM.EntityFrameworkCore" Version="5.0.0.200" />
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
    <PackageReference Include="Refit" Version="6.0.38" />
    <PackageReference Include="Serilog.Extensions.Hosting" Version="4.1.2" />
    <PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
    <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
    <PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
    </ItemGroup>
    <ItemGroup>
    <ProjectReference Include="..\sml.globe.track.library\sml.globe.track.library.csproj" />
    </ItemGroup>
    <ItemGroup>
    <None Update="appsettings.json">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    </ItemGroup>
    </Project>

    Does anyone have any advice on this issue?

    Thanks,
    Luis


    ------------------------------
    Luis Barahona
    ------------------------------

    #DataManagementGlobal
    #DataServerDrivers


  • 2.  RE: Could not load file or assembly 'IBM.Data.Db2, Version=5.0.0.200, Culture=neutral, PublicKeyToken=7c307b91aa13d208' - Azure WebJobs

    Posted Tue April 27, 2021 03:22 PM
    Have you tried using the x64 runtime in the webjobs web app? BadImageFormatException usually means a mismatch between the runtime and the assembly (x86 vs x64).

    ------------------------------
    John Rummell
    ------------------------------



  • 3.  RE: Could not load file or assembly 'IBM.Data.Db2, Version=5.0.0.200, Culture=neutral, PublicKeyToken=7c307b91aa13d208' - Azure WebJobs

    Posted Tue May 04, 2021 11:14 AM
    Hi Luis,

     Here you need to follow to overcome the above issue.
    1.  In Azure Portal have to configure the 64 bit platform.
    2.  Always Preferred to use same version 5.0.0.200 (IBM.EntityFrameworkCore and IBM.Data.DB2.Core).
    For Azure settings please follow the attached file 

    Thanks,
    Naveen

    ------------------------------
    NAVEENKUMAR N L
    ------------------------------