Skip to content

.net maui with .net8 has sql-connection-issues when using dapper #101484

Open
@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
I have a .NET Maui app written in .net 8 which uses dapper to connect to a SQL Server database. When I debug my application, everything works great. My app retrieves and sends data to the database.

However when I use the SQL Server Object Explorer (SSOE) in Visual Studio to browse my data while my application is running the SSOE doesn't show my server and databases anymore. This worked fine before and in other applications like ASP.NET MVC I have no issues like that.

Even when I end debugging, my SSOE is still jammed up, even after refreshing.

Closing VS doesn't help. I have to unlock the files of appData\Local\Microsoft\MS SQL Server Local DB\Instances\MSSQLLocalDb with some file unlocker.

Same thing happens otherwise. When I open my SSOE first or in an other program like Azure Data Studio to connect my server and database and debug or launch my application afterwards I get the message:

Microsoft.Data.SqlClient.SqlException
HResult=0x80131904

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not >accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network >Interfaces, error: 50 - Local Database Runtime error occurred. Error occurred during LocalDB instance startup: SQL Server process failed to start.

Source=Core Microsoft SqlClient Data Provider ...

My eventviewer shows errors like:

Windows API call WaitForMultipleObjects returned error code: 575. Windows system error message is: {Application Error} The application was >unable to start correctly (0x%lx). Click OK to close the application. Reported at line: 3714.

Same solution works here. Unlocking the files with file unlocker gets my app back up and running.

I use Dapper like this:

public IEnumerable<team> GetTeam()
    {
        string sql = @"SELECT * FROM teams Order by name";

using (IDbConnection db = new SqlConnection(ConnectionString))
        {
            var debugVar = db. Query<Team>(sql). ToList();
            return debugVar;
        }
    }

Problems began after upgrading to .NET 8. I got SQL Server Management Studio installed to access my localdb.

Does anyone have any idea how to solve this?


Original Comments

Feedback Bot on 2/29/2024, 03:29 AM:

(private comment, text removed)


Original Solutions

(no solutions)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions