azure-functions-host: Function App v2 referencing .NET Standard Lib (with ASP.NET Core packages): System.Private.CoreLib: Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Server.Abstractions, Version=2.0.1.0

I have a very simple Function App v2 (with .NET Core 2.0). This Function app references a .NET Standard lib (which in turn references some ASP.NET Core packages) and uses types from that lib.

When I start the Functions host locally & try to HTTP GET an address like http://localhost:7071/api/foo I get this exception:

[28/01/2018 19:49:35] A ScriptHost error has occurred
[28/01/2018 19:49:35] Exception while executing function: Function1. FunctionApp1: The type initializer for 'FunctionApp1.Function1' threw an exception. FunctionApp1: Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Server.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Server.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Those assemblies are all ‘there’ in the folder of the Function app.

There are some similar issues already posted, like: https://github.com/Azure/Azure-Functions/issues/625 https://github.com/Azure/azure-functions-cli/issues/253 https://github.com/Azure/azure-functions-cli/issues/335

And a related SO post: https://stackoverflow.com/questions/48039880/azure-functions-2-0-not-loading-referenced-libraries

However, none of them provide a solution or a viable work around.

Is there anything I am doing wrong here? Thanks!

You can find a simple repro here: https://github.com/ChristianWeyer/Functions-NetStandardLib_Repro

My setup: -VS 2017 15.6.0 Preview 3.0 -Azure Functions and Web Jobs Tools: 15.0.40118.0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (3 by maintainers)

Most upvoted comments

Oh my god - yes, this did it. Thanks @cschwendtner !

Hopefully this will be fixed soon 😃

Thanks for this hint @cschwendtner I had this version on my machine (although I have the latest Tools extension in VS!):

Azure Functions Core Tools (1.0.7)
Function Runtime Version: 1.0.11375.0

I did npm install -g azure-functions-core-tools@core

and now I have this version:

Azure Functions Core Tools (2.0.1-beta.22)
Function Runtime Version: 2.0.11415.0

In VS I still get this: image

… and the same errors.