4

I'm trying to connect to a AS400 server using the .net classes.
I have added a reference to IBM.Data.DB.iSeries and I use the following code:
var conn = new iDB2Connection("DataSource=111.111.111.111;UserID=xxx;Password=xxx; DataCompression=True;");
conn.Open();

But I get the following exceptions
Running 64 bit: "The provider cannot run in 64-bit mode."
Running 32 bit: An unexpected exception occurred. Type: System.DllNotFoundException, Message: Unable to load DLL 'cwbdc.dll': The operating system cannot run . (Exception from HRESULT: 0x800700B6).

I have uninstalled the Client Access and installed it again. The cwbdc.dll does exist in the system32 and syswow64 . I have no problem connecting to the AS400 if I use odbc.

I'm running a 64 bit verion of Windows 7.
Any ideas?

/Jimmy

Jimmy Engtröm
  • 1,998
  • 4
  • 23
  • 34

1 Answers1

5

It seems that the driver you are using is not supported on 64 bit systems. In the properties of your project in the Build tab try setting the Platform Target to x86 instead of Any CPU.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • 1
    When setting it to x86 I get the other errormessage: "An unexpected exception occurred. Type: System.DllNotFoundException, Message: Unable to load DLL 'cwbdc.dll': The operating system cannot run . (Exception from HRESULT: 0x800700B6)." – Jimmy Engtröm Mar 23 '10 at 10:26
  • 1
    +1 - I was getting the same error, found your answer and it worked. Thank you! – David Dec 23 '10 at 15:34
  • I had a similar issue and replacing Visual C++ 2008 Redistributable with its [SP1](http://www.microsoft.com/en-us/download/details.aspx?id=5582) resolved it. (Hint: http://stackoverflow.com/a/3412380/908336) – Masood Khaari Nov 18 '13 at 12:16