You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2020/04/01 20:41:14 UTC

[GitHub] [openwhisk-runtime-dotnet] dmlo opened a new issue #39: Action cannot load Microsoft.Extensions.DependencyInjection.Abstraction

dmlo opened a new issue #39: Action cannot load Microsoft.Extensions.DependencyInjection.Abstraction
URL: https://github.com/apache/openwhisk-runtime-dotnet/issues/39
 
 
   I have a c# OpenWhisk Action:
   ```csharp
   using System;
   using IHWhisk.Models;
   using Newtonsoft.Json.Linq;
   
   namespace IHWhisk
   {
       public class Hello
       {
           public JObject Main(JObject args)
           {
               var handian = new Handian();
   
               string errorText = "";
               
               try
               {
                   using var db = new IHDbContext();
                   db.Handians.Add(handian);
                   db.SaveChanges();
               }
               catch (Exception e)
               {
                   errorText = e.Message;
               }
   
               var message = new JObject();
               message.Add("Content-Type", new JValue("application/json"));
               message.Add("body", new JValue($"<p>Error: {errorText}</p>"));
               return message;
           }
       }
   }
   ```
   which uses EF Core dependency injection to configure and access the database, like so:
   ```csharp
   using System;
   using Microsoft.EntityFrameworkCore;
   using IHWhisk.Models;
   
   namespace IHWhisk
   {
       public class IHDbContext : DbContext
       {
           public DbSet<Handian> Handians { get; set; }
   
           protected override void OnConfiguring(DbContextOptionsBuilder builder)
           {
               var connectionString = "Server=#.#.#.#;Database=ih;Port=5432;User Id=postgres;Password=supersecretpassword";
               builder
                   .UseNpgsql(connectionString, o
                       => o.EnableRetryOnFailure());
           }
   
           protected override void OnModelCreating(ModelBuilder modelBuilder)
           {
               modelBuilder
                   .HasPostgresExtension("uuid-ossp")
                   .Entity<BaseEntity>(entity =>
                   {
                       entity.HasIndex("Discriminator");
                       entity.Property(p => p.Uuid)
                           .HasDefaultValueSql("uuid_generate_v4()"); // All IH entities get a postgres Uuid4
                   })
                   .Entity<Handian>(entity => { entity.Property<DateTime>(p => p.Birthday).HasDefaultValueSql("now()"); });
           }
       }
   }
   ```
   which when run inside my OpenWhisk installation fails with the error:
   
   ```
   Error: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (0x80131621)
   ```
   I test this Action locally by invoking it from a clean console app like so:
   ```csharp
   namespace WhiskTester
   {
       class Program
       {
           static void Main(string[] args)
           {
               var ihwhisk = new IHWhisk.Hello();
               var callArgs = new JObject();
               var result = ihwhisk.Main(callArgs);
               Console.WriteLine(result);
           }
       }
   }
   ```
   It works when tested locally... a new record is written to the database as expected.
   
   Things I've tried to resolve the issue:
   * Successfully performed a DB insert without EF Core, ruling out a DB misconfiguration or a problem with the NGPSQL drivers
   * Replaced NGPSQL with Microsoft's SQLite driver and replicated the issue to further rule out a NGPSQL problem
   * Verified that Microsoft.Extensions.DependencyInjection.Abstractions.dll v3.1.3 is in the zip file I am sending to OpenWhisk
   * Downgraded Microsoft.EntityFrameworkCore, Microsoft.EntityFrameworkCore.Abstractions, Microsoft.EntityFrameworkCore.Design, Microsoft.EntityFrameworkCore.Tools and Npgsql.EntityFrameworkCore.PostgreSQL to version 3.1.2. The error message now references missing `Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.2.0`
   
   At this point I've reached the edge of my knowledge and would be grateful for any advice or guidance you could offer.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services