asp.net-coreinformix

ASP.NET CORE 6.0: Informix Connection: Error Connecting


I am trying to connect to an Informix database using the Informix.Net.Core.dll in an asp.net core 6.0 web api. I have set the path to InformixDir\bin directory on my machine and have used setnet32 to define an Informix Server and a Host. I have installed System.Security.Permissions nuget package(4.4) but still my web api throws the exception that this package is not found(on IfxConnection).

These are the steps I followed:

  1. Installed Informix.4.50.FC11 CSDK on a Windows 11 64-bit machine
  2. Added C:\Program Files\Informix.4.50.FC11\bin to the path
  3. Defined a new Server and a Host in my setnet32
  4. Below is my web api code that makes a connection to an Informix server:
  5. The error I am getting is: FileNotFoundException: Could not load file or assembly 'System.Security.Permissions, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
string _connectionString = "Host=<IPADDRESS>;Service=<PortNumber>;Protocol=onsoctcp;Server=<DBServer Name>;Database=<DBNAME>;User Id=<UID>;Password=<PASSWORD>;DB_LOCALE=en_US.819;CLIENT_LOCALE=en_US.819;":
con = new Informix.Net.Core.IfxConnection(_connectionString); //it fails on this line
await con.OpenAsync();
IfxCommand cmd = new IfxCommand("mySPName", con);
cmd.CommandType = CommandType.StoredProcedure;                    
IfxDataAdapter ifxAdpter = new IfxDataAdapter(cmd);
System.Data.DataSet ifxDS = new System.Data.DataSet();

ifxAdpter.Fill(ifxDS, "emp");


Solution

  • This might help anyone trying to code an asp.net core web application connecting to Informix database.

    Upgrade the Informix.Net.Core package to the latest available in Nuget Package Manager.