I am getting the above mentioned error message. I have made enough research and tried out various options but still no luck.
Here arethe details below:
OS: Windows 7 64 bit version
Visual studio version: 2013 Premium
.NET framework version is : 4.0.30319
ASP.NET version: 4.0.30319.34249
IIS version: 7.0
DB2 installed path: C:\Program Files (x86)\IBM
DLL path: C:\Program Files (x86)\IBM\SQLLIB\BIN\netf40\IBM.DB2.dll
DLL Version: 9.7.4.4
I have also changed my solution configuration manager platform to Any CPU and also I have changed the settings in the application pool by setting the property enable 32-bit application to True.
But still am getting the same error. Is there any other workaround?
Please help me with your suggestions.
DB2 Install
After adding connection you can test the connection with testconn40.exe. Open cmd and locate to C:\Program Files\IBM\IBM DATA SERVER DRIVER\bin and execute:
> testconn40 DBDSNSAMPLE
This command won't login you (because we did't specify user credentials in .cfg file), but at least it will show the proper message, which means your .NET app will work. Otherwise, it will show some exception errors.
DB2 in Visual Studio
Notes
from cmd you can try this:
I'm going to jump in here and put my steps to fully automate the deploy of the .Net Data Providers from IBM since this is the first of MANY errors that I ran into attempting to get this to work. I hope someone avoids being put on the wheel of pain by reading these steps.
Next, you will need to set the DLLs that you just referenced not be included in the BIN folder by setting the DLLs to Copy Local FALSE by Right Clicking the references and going to properties.
If these are put in the BIN you will get the error message:
IBM's reference to the issue: http://www-01.ibm.com/support/docview.wss?uid=swg21902663
Now you need to deploy and you realize you have a problem with automating installing a DB2 driver and start looking for solutions:
Not wanting to manually install on DEV/QA/STG/PROD, I found the that you can install IBM Data Server Client Package silently via command line using a response file. About halfway down this page: https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.swg.im.dbclient.install.doc/doc/t0007315.html you will find the relevant information after this line:
A link to a sample response file to copy and change with your information is here: https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.apdv.sample.doc/doc/dsdriver/s-dsdriver-rsp.html
Now you are all set right? WRONG. Apparently a "successful install" doesn't include moving the appropriate DLLs to the GAC and registering them in the Registry. Thanks IBM: https://www-01.ibm.com/support/docview.wss?uid=swg21618434
Not wanting to give up in my automated deploy dreams, I put all the above knowledge into a Powershell script:
Now you will find that you are getting another error. Until now you were only fighting IBM.Data.DB2.*.dll issues. The following error is now present:
Come on IBM!! A quick Google search finds the same results we got with the #1. "Change your app to 32-bit" This is wrong, of course, we know better now!
I'll help you out and let you know that this DLL was installed along with the OTHER DLLs, just in a different path!
Just add them to the bottom of the Powershell script:
Now you have a fully automated DB2 .Net Provider to connect to a DB2 Server.
Hope this helps.
EDIT: You can alternately isolate the required DLLs and only include those in a folder (like /lib/) and deploy those instead of installing with an exe. Reference the /lib/ location instead of the driver install location to move to the GAC.
In my case, this was happening with Windows Server 2012 R2 Standard, This is an error caused by the package not installing in the Global Cache Assembly make sure you check C:\Windows\Assembly to ensure your program is installed properly under GAC_32 , GAC_64, you should see
If not this is what I had to do in order to solve it.
1)I had to check the version I had installed in order to ensure compatibility.
2)The "IBM DATA SERVER CLIENT" did not install properly, using the GUI due to a bug, so it had to be run silently using this as an administrator
3) Due to the server nature I had to install .Net 3.5 using IBM-Steps <-- Link That did not work for me so I had to use MS-Steps <-- Link with these lines
4) Found out the one of the issues is that the "IBM DATA SERVER CLIENT" was still not install properly by checking the DB2LOG folder which is in your C:\User_Dir\Document\DB2LOG
5) Had to install the "IBM DATA RUN TIME CLIENT" latest fix in my case for 9.7 is fix 10, can be accessed free on IBM's download page you just have to register it takes 1 minute and you get a response asap, make sure you follow through else wait until your stupidity factor kicks in.... me...
6) Then I was able to install "IBM DATA SERVER CLIENT"
7) Double check to ensure you can see "DB2COPY1" or whatever you choose to call your installation copy.
I'm sure you don't need both, however I will no loginder mess with this thing.
It sounds like you are trying to load a 32 bit compiled IBM DB2 driver from a .NET application running in 64 bit mode. Try changing configuration manager to run in x86 mode.
I just recently had this problem. I found that the publishing process in Visual Studio was putting a copy of IBM.Data.DB2.dll in the BIN directory of the web application. When it is manually deleted, the web application starts operating correctly. I do not know why it's getting published, as it is not directly referenced.
The easiest way I've found to resolve this, is to use a Post-build event.
Project properties --> Build Events --> Post-build event command line
Here's the command line I'm using:
This problem happened me these days and it was solved following what this IBM document says, that is to go to the reference in the project and set "Copy local" to false for DB2 dlls, referencing diretly the ones from the DB2 client setup