ScottFoster1000
ScottFoster1000

Reputation: 617

Error: Cannot load file or assembly netstandard, Version=2.1.0.0

I have a AzureFunctions project that I needed to upgrade to .NET standard 2.1 (from 2.0) All of my other projects in the solution load and compile correctly but this AzureFunctions project is throwing this error:

Error System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. File name: 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

I've verified all the nuget packages are updated, what else could it be?

Thanks!

Upvotes: 11

Views: 36079

Answers (5)

Lee Cordell
Lee Cordell

Reputation: 276

I had the same problem. I eventually discovered that changing the Azure functions project properties to target .NET Core 3.1 still left the Azure function version on V2. The solution was to edit the CSPROJ and set the AzureFunctionsVersion from v2 to v3.

Upvotes: 16

MaxThom
MaxThom

Reputation: 1401

for me it was the function app configuration on azure that needed to be upgraded. I had to set the runtime to 3 in the settings. See picture.enter image description here

Upvotes: 2

n-0
n-0

Reputation: 427

My project file target netcoreapp3.1 with Microsoft.NET.Sdk.Functions 3.0.3 based on a template gave a similar error. Removing azure-functions-core-tools and installing a different version solved it for me.

npm uninstall azure-functions-core-tools
npm install azure-functions-core-tools@3 --unsafe-perm true

Upvotes: 0

Ashish Mishra
Ashish Mishra

Reputation: 687

Some times you receive this error because you have referenced a library/nuget package that target the incompatible .Net standard. example: If you create project that target to .Net Core 2.2 and you try to add the library which target .net standard 2.1 then you will get the same error because .Net Core 2.2 is compatible with .net standard 2.0 or lower so you can add package/library that target to .Net Standard 2.0 or lower version. Please see the links for more details :

.Net Core and .Net Standard

.Net Standard Compatiblity Table

Upvotes: 18

user1642187
user1642187

Reputation: 31

I get the same error.

I don't think it's related to Microsoft.NET.Sdk.Functions package as you need that package (specifically 1.0.30-beta2 in order to try the preview of .net core 3).

I think it's got something to do with Microsoft.Extensions.Logging. If you create a new azure functions project you'll see the Azure.WebJobs.Extensions.Storage uses v2.1 of the logging package within it. However if you have a project that itself uses the latest logging, then it'll use v3.0 too. But somewhere along the lines I don't think it really wants to and it fails in azure trying to find v2.1.

If your function takes an ILogger as a parameter it'll fail too more specifically showing it can't find that type. I think this is all because ultimately it's a preview, I can't seem to get it to work just now either.

Upvotes: 1

Related Questions