Error loading assembly when calling CloudCodeFunction

I’m writing a CloudCode module that reads data from a remote PostgreSQL database.

I added Npgsql to my module via Nuget which I use to connect to my database. Npgsql has a dependency on Microsoft.Extensions.Logging.Abstractions, which is an “Implicitly Installed Package”

When I call my CloudCodeFunction, I get this error:

Invocation Error
ScriptRunner.Exceptions.CloudCodeRuntimeException: Error executing Cloud Code function. Exception type: FileNotFoundException. Message: Could not load file or assembly ‘Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60’. The system cannot find the file specified.

at Npgsql.NpgsqlConnection.SetupDataSource()
at CloudCode.Module.CloudCodeFunction() in D:\Project\Module.cs:line 24

I tried explicitly adding the Microsoft.Extensions.Logging.Abstractions to my project via Nuget and verified that the DLL is included in my package, but the problem persists.

Is there something I need to do in order to handle implicitly installed packages?

Implicitly installed packages are fine. Cloud Code Modules currently uses version 7 for the Microsoft.Extensions.Logging package, which is conflicting with the version 8 the latest version of Npgsql is using. We’ll be updating Cloud Code to support .NET 8 and associated packages soon, but in the meantime you’ll need to use an earlier version of Ngpsql that’s compatible with v7. This is also something we should document better in the future. Apologies for the inconvenience.

2 Likes