0

I am currently working on a Xamarin IOS project. In this project, I need MySql connection in order to complete several tasks.

When I write my code (the code below) the program throws an error.

        using var connection = new MySqlConnection(connectionString); // C# 8!
        connection.Open();

        using var command = connection.CreateCommand();
        command.CommandText = "SELECT * FROM Users WHERE Username = 'jack'"; 

        using var reader = command.ExecuteReader();

The program throws the following error:

The type 'MySqlConnection' exists in both 'MySql.Data.CF, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, Retargetable=Yes' and 'MySql.Data, Version=8.0.25.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' (CS0433) (firstios)

I do not have 'MySql.Data.CF' in my packets folder and it is not included in the .cs folder that I am working on.

2
  • Somewhere there is a reference to MySql.Data.CF. Try to expand the references node in your android/ios projects. You can also try to find the reference using some tool that is able to search text into files and make a search on all you project/solution files. As last resort add the namespace to the MySqlConnection variable declaration (as MySql.Data.MySqlConnection) Commented Dec 12, 2021 at 0:10
  • if you right-click on the error squiggle VS will give you several automated solutions, like fully qualifying the namespace. This is a pretty standard C# error when a class exists in multiple namespaces Commented Dec 12, 2021 at 1:30

1 Answer 1

1

I solved the issue by removing MySql.data and replacing it with MySqlConnector.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.