Background
A C#/.NET web application that accesses an Informix database.
The Client SDK is installed locally.
Project references the IBM.Data.Informix.dll in the IBM SDK directory
I'm using the older dll because the Informix database we have to access is ancient (Version 7.something)
It works perfectly on my machine (Windows 10) when running in debug mode through Visual Studio. Great, I'll deploy it to the Test server (Windows Server 2012 R2).
First attempt
- Straightforward file deployment from Visual Studio
- Run the app to access the database
- Error
Could not load file or assembly 'IBM.Data.Informix, Version=3.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208' or one of its dependencies.
The system cannot find the file specified.
Second attempt
- Copied dll to a project folder named lib
- Changed project reference to this dll
- Deployed
- Same error as first attempt
OK, I'd better research this. See below for references.
Third attempt
- Removed reference to sdk dll
- Installed from NuGet - the Avatar Solucoes version
- Deployed
- Same error as first attempt
More research
Fourth attempt
- Copied gacutil files to server and installed dll from third attempt into GAC
- Deployed
- New error
The type initializer for 'IBM.Data.Informix.IfxConnection' threw an exception.
Unable to load DLL 'iclit09b.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
More research
Fifth attempt
- Uninstalled NuGet package
- Referenced dll from sdk
- Added sdk .dll to gac on server
- Refreshed app
- Same error as first attempt
More research
Sixth attempt
- Installed from NuGet - the Avatar Solucoes version again
- added same dll to gac on server
- created new folder C:\informix on server
- copied iclit09b.dll from ibm sdk to this folder
- added folder to PATH
- Restarted IIS
- Deployed
- Error same as fourth attempt
More research
Seventh attempt
- Copied iclit09b.dll to the deployed bin folder.
- Deployed
- Error same as fourth attempt
More research
Found this ominous paragraph https://www.ibm.com/developerworks/data/library/techarticle/dm-0510durity/index.html
Important: The IBM Informix ADO.Net driver is not self-contained in the IBM.Data.Informix.dll file that gets installed in the /bin directory of your installation. Apparently, it uses some of the other client code installed by the SDK. This means that you must install the Informix Client SDK on any machines that will use the ADO.Net driver. You cannot just include the IBM.Data.Informix.dll in your distribution. This could be a serious limitation for some applications. You also need to go through the SDK setup (SetNet32) to define your Informix data sources.
Do we really need to install the SDK on production servers? And have to install DLLs in the GAC? If so, how can people deploy to servers over which they have no control?
As you can probably tell, I don't have much experience with Informix and .NET.
I literally have no idea what to do next.
Any suggestions will be most gratefully received.
References in no particular order
- Could not load file or assembly '' or one of its dependencies
- https://social.msdn.microsoft.com/Forums/vstudio/en-US/8289751b-be25-4a23-a5e2-709645b8c651/net-4-gacutil-on-production-server
- Unable to load DLL 'iclit09b.dll'
- Assembly load error for 64 bit .NET Informix ADO.NET provider
- http://www-01.ibm.com/support/docview.wss?uid=swg21618434
- C# could not load file or assembly...system cannot find file specified
- Could not load file or assembly 'Microsoft.AI.Web' or one of its dependencies. The system cannot find the file specified.
- Could not load file or assembly The system cannot find the file specified
- Could not load file or assembly or one of its dependencies. The system cannot find the file specified. (No GAC allowed)
- https://learn.microsoft.com/en-us/dotnet/api/system.appdomain.assemblyresolve?redirectedfrom=MSDN&view=netframework-4.7.2
- https://www.ibm.com/developerworks/data/library/techarticle/dm-1007dsnetids/index.html
- https://www.ibm.com/support/knowledgecenter/en/SSGU8G_12.1.0/com.ibm.netpr.doc/ids_net_010.htm
- IBM .net driver cannot find db2locale.dll
- https://social.msdn.microsoft.com/Forums/vstudio/en-US/5e23ebf7-33e1-4c85-beb5-bab6f51c02c4/informix-adonet-data-provider-connection-test
- http://galhano.com/blog/?p=1184
Update 2019-01-25
Following on from @Satyan's answer I uninstalled all previous versions of the SDK and cleared the GAC
Eighth attempt
- I installed the latest SDK
- I referenced the net40 version of IBM.Data.Informix.dll
- I added this version to the GAC
- On my local machine I got the same error as the first attempt
Ninth attempt
- I referenced the net20 version of IBM.Data.Informix.dll
- I added this version to the GAC
- On my local machine I got the same error as the first attempt
Tenth attempt
Fortunately I still had a copy of the older IBM.Data.Informix.dll
- I referenced the older version of IBM.Data.Informix.dll
- I added this version to the GAC
- On my local machine I can run the program successfully again. Phew!
- I deployed to the server
- Get the same error as the fourth attempt
More research
Found these articles
- http://www-01.ibm.com/support/docview.wss?uid=swg21645914
- https://www-01.ibm.com/support/docview.wss?uid=swg21613231
which suggest the resolution is
Set INFORMIXDIR and PATH as system environment variables and then bounce the Microsoft Internet Information Server or the whole machine and try to run your ASP application again.
Eleventh attempt
- Added new INFORMIXDIR system environment variable
- Restarted IIS
- Try the application
- Nope. Still get the same error as the fourth attempt.
In my research I have found reference to 'Informix Connect' which is supposedly used to install client products and in the client_install.pdf in the SDK download it makes reference to installconnect.exe, but that exe does not exist in the SDK I downloaded. If it is a separate download to the SDK, then I can't find it.
Update 2019-02-08
Decided to have another crack at this
Twelfth attempt
- Added informix directory nearer to start of environment path
- Restarted IIS
- New error
SQL0035N The file "en_us\IBM.Data.Informix.xml" cannot be opened.
at IBM.Data.Utilities.IfxResource..ctor(CultureInfo cultureInfo, String dirName, String fileName, String szMsgPath, String xpath)
at IBM.Data.Utilities.IfxResources.GetResource(CultureInfo cultureInfo, String xpath)
at IBM.Data.Informix.IfxException.get_Message()
Aha! A new error, I'm getting somewhere.
Thirteenth attempt
- Copied C:\Program Files\Informix Client-SDK 4.10.FC9\msg folder to INFORMIX folder on the server
- Added IIS_IUSRS to informix folder
- Restarted IIS
- Same error as twelfth attempt
I also tried copying just the en_us folder into the informix folder - nope!
More references
- https://www.ibm.com/developerworks/community/forums/html/threadTopic?id=77777777-0000-0000-0000-000013802669
- Connect to informix database windows form application
Update 2019-02-14
Fourteenth attempt OK. I decided to risk it and install the SDK on the server.
What I didn't expect was the installation restarting the server without asking me first.
Anyway, when it came back up we were back to the original error
Could not load file or assembly 'IBM.Data.Informix, Version=3.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208' or one of its dependencies.
The system cannot find the file specified.
OK. That didn't work. It also somehow messed up the installation of TFS which could no longer be accessed via a browser.
OK, I'll uninstall the SDK. Nope. The uninstall feature crashed out with a Java stack overflow error. Fortunately the server is a virtual, so I got last night's backup restored. All OK again.