asp.net core 5 application and microsoft.data.sqlclient

Sławomir Piotrowski 1 Reputation point
2021-05-10T14:21:03.237+00:00

Hello,

I'm working on an asp.net core 5 application.

Trying to use Microsoft.Data.SqlClient on development machine and it works, but after installing on test server the result is like that:

An error occurred while starting the application.
PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.
Microsoft.Data.SqlClient.SqlConnection..ctor(string connectionString)
PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.
Microsoft.Data.SqlClient.SqlConnection..ctor(string connectionString)
TelsatRcpAccess.Startup.CreateDatabaseIfItsNotThere(string OriginalConnectionString) in Startup.cs

Where should I search for source of the problem?

Current content of 'dependencies / packages':
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (5.0.4)
Microsoft.AspNetCore.Identity.EntityFrameworkCore (5.0.4)
Microsoft.AspNetCore.Identity.UI (5.0.4)
Microsoft.Data.SqlClient (2.0.1)
Microsoft.EntityFrameworkCore.SqlServer (5.0.4)
Microsoft.EntityFrameworkCore.Tools (5.0.4)
Microsoft.Extensions.Caching.SqlServer (5.0.1)
Microsoft.VisualStudio.SlowCheetah (3.2.26)

The fact that it works on development machine suggests that problem is with lack of installing something required by sqlclient.
I am installing .net framework 4.8 and .net core 5 before installing test application.
Test server is Windows Server 2019 with IIS and SQL Server 2019.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,282 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Cheong00 3,471 Reputation points
    2021-05-11T06:13:03.163+00:00

    What is your usage?

    From their source code, seems the only cause that would raise PlatformNotSupportedException with default error message on Windows is when with enclave attestation (more information here)

    If the Application is UAP but it's trying to create LocalDB connection, it will have custom error message to explicitly state that; and I assume you don't use SqlFileStream which will also raise with custom error message to tell you exactly what happened.

    1 person found this answer helpful.
    0 comments No comments

  2. Duane Arnold 3,216 Reputation points
    2021-05-11T05:47:51.657+00:00

    @Sławomir Piotrowski

    Your development machine is running what O/S? What O/S is MS SQL Server hosted on in this situation, and what version of MS SQL Server is being used?

    On the flip-side, what is the same information asked above when the solution is deployed?


  3. Sławomir Piotrowski 1 Reputation point
    2021-05-11T12:21:27.533+00:00

    Looks like the source of the problem is... setup project.

    My setup project (generated by Visual Studio extension) doesn't install applicationname.deps.json file. I have copied that file by hand and it works now. Should be able to add the file manually from publish folder on my development machine (the file is copied when publish function is used), but still wonder why wasn't it included automatically in setup.

    0 comments No comments