Problem Description
I'm trying to integrate an external .NET library (Npgsql) into my custom Creatio package to connect with a PostgreSQL database. However, I'm encountering version compatibility issues with System.Runtime.

 Current Setup
- Package Name: UsrWebServiceLog
- Target Library: Npgsql
- Current Error:
 

Assembly 'Npgsql' with identity 'Npgsql, Version=8.0.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' uses 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime'

 What I've Tried
1. Adding the library reference directly to my package project
2. Attempting to use an older version of the library
3. Adding System.Runtime reference

 Questions
1. What is the correct approach to include external .NET libraries in a Creatio custom package?
2. Are there specific version requirements or limitations I should be aware of?
3. Should the library be installed at the workspace level or package level?
4. Is there a specific location where external DLLs should be placed?

 Code Context
I'm trying to implement a web service that connects to PostgreSQL:

namespace Terrasoft.Configuration.UsrPostgressConnection
{
   [ServiceContract]
   public class UsrPostgressConnection : BaseService
   {
       // Service implementation
   }
}

Any guidance on best practices for managing external .NET dependencies in Creatio would be greatly appreciated. Thank you in advance!

 Environment Details
- Creatio Version: 8.1.3
- Development Environment: On-site
- .NET Framework Version: 4.7.2

Like 1

Like

2 comments
Best reply

Kyrylo Atamanenko,

According to your suggestion, it might function if I use an older version of the Npgsql driver.

Hello!

 

Actually this issue occurs because Npgsql assembly (version 8.0.5) depends on System.Runtime version 8.0.0, which is a newer version than the System.Runtime the version currently referenced in your project.

 

.NET Framework 4.7.2 does not support System.Runtime version 8.0.0, as this version of System.Runtime is associated with .NET 8, which is part of the .NET (formerly .NET Core) family, not .NET Framework.

The highest System.Runtime version that .NET Framework 4.7.2 supports is within the 4.x series. .NET 8.0 and its libraries, including System.Runtime version 8.0.0, are compatible only with .NET Core 8 / .NET 8 or higher.

Kyrylo Atamanenko,

According to your suggestion, it might function if I use an older version of the Npgsql driver.

Show all comments

Hi community,

I’m working on a custom web service in Creatio that connects to an external PostgreSQL database deployed on Neon. My goal is to query data from this external database, acting like a custom ORM. However, I’m running into an issue with using the Npgsql package inside Creatio’s source code.

 

I’ve added the necessary references, but I keep getting the following error:

The type or namespace name 'Npgsql' could not be found (are you missing a using directive or an assembly reference?)

 

I’ve already added the Npgsql.dll to the Terrasoft.web/bin folder and modified the web.config to include a binding redirect for Npgsql. After restarting the IIS server and flushing Redis, I now get a 'System.Data.Common' assembly error.

Here’s the code I’m using:

using Npgsql;
using System;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.ServiceModel.Activation;
using System.Data;
using System.Collections.Generic;
using Terrasoft.Core;
using Terrasoft.Web.Common;
 
namespace Terrasoft.Configuration
{
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class PostgresService : BaseService
    {
        private string connectionString;
 
        public PostgresService()
        {
            // PostgreSQL connection string
            connectionString = "Host=your_host;Port=5432;Database=your_database;Username=your_username;Password=your_password";
        }
 
        [OperationContract]
        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetData")]
        public List<Dictionary<string, object>> GetData()
        {
            var result = new List<Dictionary<string, object>>();
            try
            {
                using (var connection = new NpgsqlConnection(connectionString))
                {
                    connection.Open();
                    string sql = "SELECT * FROM users LIMIT 100";
 
                    using (var cmd = new NpgsqlCommand(sql, connection))
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var row = new Dictionary<string, object>();
                            for (int i = 0; i < reader.FieldCount; i++)
                            {
                                row.Add(reader.GetName(i), reader.GetValue(i));
                            }
                            result.Add(row);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Error retrieving data: {ex.Message}");
            }
 
            return result;
        }
 
 
 
    }
}

 

Like 1

Like

1 comments

Hello,

 

Please revert all the changes and perform the setup in the following manner:

 

  1. 1) Deploy another website that will be used as a mediator between the custom PostgreSQL database and your local Creatio app.
  2. 2) Create an endpoint in this separate server that can be accessed either via POST\GET request and that can receive some parameters in the request body.
  3. 3) Create a code in this separate server that will communicate with the custom PostgreSQL server in some method (that will be used as an endpoint to be called).
  4. 4) Call this endpoint from the webservice in local Creatio app and get data from the database as a JSON string and then process it as you need in the local Creatio app.
Show all comments

Hi everyone,

I’m working on a custom web service and tried integrating Npgsql. After encountering a "no namespace found" error, I took the following steps:

  1. Added the Npgsql.dll file to the Tearsoft.web/bin directory.
  2. Modified the web.config file with the following binding redirect:

    xml
     

  3. <dependentAssembly>
        <assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.5.0" newVersion="8.0.5.0" />
    </dependentAssembly>
  4. Restarted the IIS server.
  5. Flushed Redis via the Clio CLI.

After these steps, I'm now facing the following error: Could not load file or assembly 'System.Data.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. (Screenshot attached for reference)

I've already checked assembly binding logging, but I’m unsure how to resolve this error. Any suggestions or help would be appreciated!
 

Additional Context:

  • Working with PostgreSQL using Npgsql in the custom web service.
  • I made changes to the web.config file after adding the Npgsql DLL.


    this is the current state for my local instance .
     

Thanks in advance!

Like 0

Like

1 comments

Hi,

This issue requires a deeper analysis, and we advise you to create a case for Creatio support.

Thank you!

Show all comments