2
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging; //Nuget package
using MyComp.MyLib.Contracts.Configuration;  // Custom namespace after adding reference of my custom custom class library

namespace FunctionApp1123
 {
   public static class Function1
   {
      [FunctionName("Function1")]
      public static void Run([QueueTrigger("myQNamec", Connection = "connstring")]string myQueueItem, ILogger log)
        {
          var appConfig = new ApplicationConfig(); // custom class available on  above referred custom "**MyComp.MyLib.Contracts.Configuration**" name
           log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
        }
   }
}

Error received: [2/3/2020 4:46:17 PM] Executed 'Function1' (Failed, Id=93d4305e-d2de-426c-9922-f0320888cddb) [2/3/2020 4:46:17 PM] System.Private.CoreLib: Exception while executing function: Function1. FunctionApp1123: Could not load file or assembly 'MyComp.MyLib.Contracts.Configuration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'MyComp.MyLib.Contracts.Configuration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

My custom c# class library "MyComp.MyLib.Contracts.Configuration" has been consumed by other "non Azure function" project without issues but can't able to consume it in Azure function project. Is it possible to refer custom class library in azure function project using visual studio? if yes, what Im missing?

Note: In Azure function can able refer & consume packages from Nuget but can't able to consume my custom class library by adding project reference in visual studio.

4
  • What version of Azure Functions are you using? What type of class library is this? Framework? .Net Standard? Commented Feb 3, 2020 at 19:00
  • Azure Functions v2, Net Standard 2.0 class library, Platform Target x64 Commented Feb 3, 2020 at 19:04
  • Are you using dependency injection? Have you set up a Startup.cs in your project? Commented Feb 4, 2020 at 7:41
  • The problem is NOT related to dependency injection but in general in Azure functions I can able to consume Nuget packages but I cant able to consume/refer my own class library .ddl or project. During runtime it is throwing exception "System.Private.CoreLib: Could not load file or assembly 'MyComp.MyLib.Contracts.Configuration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'." Commented Feb 4, 2020 at 14:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.