Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET 6 to .NET 8 upgrade is causing System.Private.Corelib: Exc while executing function Could not load file System.Data.Common Version=8.0.0.0

I wanted to upgrade an Azure Function app from .NET 6 to .NET 8 and the FunctionApp version is 4.

The steps I followed was to upgrade Visual Studio to 17.9 and then changed target framework to net8.0. After cleaning and building I am getting this error:

System.Private.Corelib: Exception while executing function:: Could not load file or assembly 'System.Data.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken='". The system cannot find the file specified.

My project is not using System.Data.Common. I even tried installing it explicitly it isn't working. It is showing as .NET 8 in properties as well.

How can I fix this?

Here is the libraries and their versions used in the .csproj file:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>

<ItemGroup>
    <PackageReference Include="Azure. Identity" Version="1.6.0" />
    <PackageReference Include="Azure.Security. KeyVault.Secrets" Version="4.3.0" /> <PackageReference Include="Microsoft.Azure. KeyVault" Version="3.0.5" />
    <PackageReference Include="Microsoft.Azure. Services. AppAuthentication" Version="1.6.2" /> <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
    <PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
</ItemGroup>

<ItemGroup>
    <None Update="host.json">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
</ItemGroup>

</Project>
like image 811
sigma Avatar asked Jan 20 '26 12:01

sigma


1 Answers

.NET 6 to .NET 8 upgrade is causing System.Private.Corelib: Exc while executing function Could not load file System.Data.Common Version=8.0.0.0

I have faced similar issue while upgrading .Net 6 to .Net 8:

enter image description here

I do agree @sigma and I solved the issue by changing the azure function to isolated function as In Process is not supported with .Net 8 : I am using http trigger and changed it as below:

public class Function1
{
    private readonly ILogger<Function1> _logger;

    public Function1(ILogger<Function1> logger)
    {
        _logger = logger;
    }
    [FunctionName("Function1")]
    public IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequest req)

    {
        _logger.LogInformation("Hello Rithwik");
        //othercode
        var responseMessage = "test";
        return new OkObjectResult(responseMessage);
    }
}

Output:

enter image description here

like image 148
RithwikBojja Avatar answered Jan 22 '26 03:01

RithwikBojja