我在连接到 DB2 时不断收到错误消息.但仅在已部署的(msi 打包或单击一次)应用程序上.(在同一台机器上)
从 Visual Studio 2017 运行应用程序时一切正常.在调试或发布版本中.
我在 Windows 10 上使用 nuget 的 126.96.36.199 版本的库
我也在使用服务器的免费社区版本，最近在 win server 2012 r2 上下载安装.
知道发生了什么吗?这显然在 IBM 代码中......
System.ArgumentOutOfRangeException:长度不能小于零.参数名称:长度在 IBM.Data.DB2.Core.DB2ConnPool.Open(DB2Connection 连接，String& szConnectionString，DB2ConnSettings& ppSettings，Object& ppConn)在 IBM.Data.DB2.Core.DB2Connection.Open()在 FrozenElephant.Symbiotic.DataProviderDB2.DatabaseTypesFactoryDB2.CreateConnection()在 FormDatabaseConnection.btnTestConnection_Click(对象发送者，EventArgs e)
这个问题似乎不是代码错误的结果，而是目标机器上的 DB2 连接器配置失败的结果，或者可能是应用程序的部署方式.需要通过查看连接器的可再分发部分的部署方式来确定罪魁祸首.
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 188.8.131.52 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.
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)
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:
- A different version of the SDK is used for development compared to what is on the target machine
- Perhaps multiple different assemblies of conflicting version or origin have been mixed
- The assemblies may need to be deployed with the application, and not all are. This could be fixed by setting Copy Local = true for the relevant assemblies.
- It might also be that the application is being compiled for a different platform than the client installed on the target machine (say, x64 version x86).
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.
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: