IBM.Data.DB2.Core throws exception in azure function app

0

I'm using nuget package IBM.Data.DB2.Core version 1.3.0.100 dll to connect DB2 database from Azure functions with AzureFunctionsVersion V2. Application builds successfully.

When I run the application and hit it with Postman I get the exception:

System.Private.CoreLib: Exception while executing function: Personal-GetAgencyDownload. AgencyDownload: Could not load file or assembly 'IBM.Data.DB2.Core, Version=1.2.2.201, Culture=neutral, PublicKeyToken=7c307b91aa13d208'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'IBM.Data.DB2.Core, Version=1.2.2.201, Culture=neutral, PublicKeyToken=7c307b91aa13d208'.

I see the 1.3.0.100 package, there isn't any other package. Why is it looking for 1.1.1.201 in runtime?

c#
azure
db2
azure-function-app
asked on Stack Overflow Feb 28, 2020 by george warner • edited Feb 28, 2020 by Paulo Campez

2 Answers

1

Know this is a little late, but just in case others have this issue with the latest version of IBM.Data.DB2.Core (version 3.1.0.300 at time of writing) for me it was due to the Azure function platform defaulting to 32bit, and the IBM dll (or one of its dependencies) required 64bit. Changing the platform setting to 64 bit resolved this error. You can find the setting under configuration > general settings in the azure portal.

answered on Stack Overflow Oct 8, 2020 by Sarah
0

This could happen if you have the IBM.DataDB2.dll file lying around in directories other than the DB2 client install location. This could have happened without your knowledge where Visual Studio copies the necessary dll into the bin directory of the project.

IBM.Data.DB2.dll has dependencies on other client libraries in DB2 Client installation. So refer the DLL from the DB2 Client installation location only and do not save a local copy in the application directory.

Go to the reference in the project and set Copy local to false for DB2 dlls, referencing directly the ones from the DB2 client setup.

answered on Stack Overflow Mar 3, 2020 by Joey Cai

User contributions licensed under CC BY-SA 3.0