user19627024
user19627024

Reputation: 13

System.PlatformNotSupportedException with MAUI and MySql.Data on .NET 6

I'm trying to create a direct connection to a MySQL database with MAUI .NET6 using MySql.Data 8.0.30.

        MySql.Data.MySqlClient.MySqlConnection conn;
        conn = new MySql.Data.MySqlClient.MySqlConnection();
        conn.ConnectionString = Constants.connectionString;
        conn.Open();

I'm getting a System.PlatformNotSupportedException: Operation is not supported on this platform. exception from .Open(). I know this is pretty self explanatory, but I was under the impression that .NET 6 was completely cross platform, is there a way round this? What should I be looking for in NuGet packages to indicate they are compatible with MAUI if its not .NET 6?

Thanks in advance

Upvotes: 1

Views: 1432

Answers (1)

Guangyu Bai - MSFT
Guangyu Bai - MSFT

Reputation: 4476

There might be some issues when you built the connection between the MySql sever and your project. The method you chose is right. Then I found a course you can refer to this.

In addition, the doc also provide the method about how to connect to the project.

Upvotes: 0

Related Questions