Reputation:
I keep getting a error when connecting to DB2. But only on the deployed (msi packaged or click-once) app. (And on the same Machine)
Everything works perfectly when running the app from Visual Studio 2017. in either debug or release builds.
I'm using libs from nuget for version 1.3.0.100 on windows 10
I'm also using the free community version of the server, a recent download install on win server 2012 r2.
Any idea whats going on? This obviously inside IBM code...
I know this is not much to go on, but hoping someone has ran into this problem before.
Stack Below:
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at IBM.Data.DB2.Core.DB2ConnPool.Open(DB2Connection connection, String& szConnectionString, DB2ConnSettings& ppSettings, Object& ppConn)
at IBM.Data.DB2.Core.DB2Connection.Open()
at FrozenElephant.Symbiotic.DataProviderDB2.DatabaseTypesFactoryDB2.CreateConnection()
at FormDatabaseConnection.btnTestConnection_Click(Object sender, EventArgs e)
Upvotes: 1
Views: 2899
Reputation: 117579
I had the exact same problem. I solved it by putting the directory clidriver
inside the working directory. Also, I set the following environment variables:
#!/bin/bash
cd /opt/app/deployments/v1.0
export DB2_CLI_DRIVER_INSTALL_PATH="/opt/app/deployments/v1.0/clidriver"
export LD_LIBRARY_PATH="/opt/app/deployments/v1.0/clidriver/lib"
export PATH=$PATH:"/opt/app/deployments/v1.0/clidriver/bin:/opt/app/deployments/v1.0/clidriver/adm:/opt/app/deployments/v1.0/clidriver/lib"
export ASPNETCORE_URLS=http://+:5000
export ASPNETCORE_ENVIRONMENT=STAGING
export ASPNETCORE_INSTANCENAME=app01
/opt/app/runtime/aspnetcore-runtime-3.0.0-linux-x64/dotnet /opt/app/deployments/v1.0/Launcher.dll
Upvotes: 0
Reputation: 2901
Summarizing the findings above in the form of an answer, since I may not get back to elaborate on my comments for a while.
It appears that this problem is the result not of a code error, but of the disposition of the DB2 connector on the target machine that fails, or perhaps in how the application is deployed. Deciding which is the culprit will need to be done by looking at how the redistributable parts of the connector are deployed.
One user said that he "was not referencing the assemblies correctly in my application". A few possibilities this might indicate include:
Another person mentions the same error message arising from a similar, but slightly different, cause. This one says "It seems to be an installation issue. Some files are not found."
In this case, you would probably be looking at reinstalling the client or diagnosing the install in another way. The second link above mentions a tool, testconn20, which may be available in the client you have installed. Your connection string might also offer some hints; if there's anything in it which might depend on the specific client you have installed, or its capabilities, that'd be another place to check.
Edit:
Per my comment below, you may be missing some files or folders from the ClickOnce deployment. If you determine that the clidriver folder, which has DB2-related files in it, is necessary for the application to function properly, you should check the build action, copy to output directory, and ClickOnce application files settings. The last one may be key. To check that, go to Publish in the project properties:
Then you may need to check "Show all files" to confirm the status of each file in the deployment:
Upvotes: 1