8
votes

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!

5
One of your reference package/project is incompatible so please check the target framework of all referenced library and make sure it is compatible with the your project.Ashish Mishra

5 Answers

12
votes

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

13
votes

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.

2
votes

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

1
votes

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.

0
votes

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