Bug #88459 Could not load file or assembly
Submitted: 13 Nov 2017 10:49 Modified: 15 Nov 2017 12:38
Reporter: Adam Sarzyński Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:5.7.20-log OS:Any
Assigned to: CPU Architecture:Any

[13 Nov 2017 10:49] Adam Sarzyński
Description:
I have a MySQL 5.7.20-log server running on Windows Server 2012.

I can connect to this server remotely without problems using MySQL Connector from C# Windows Forms Application (.NET) using 6.9.10 Connector.

The problem is when I try to connect with UWP application. I get an error "Could not load file or assembly" (details below). I have proper NuGet package with 6.9.10 MySql.Data library.

Exception:
„Exception has been thrown by the target of an invocation.”

InnerException:
FileNotFoundException: Could not load file or assembly 'System.Diagnostics.Process, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 

How to repeat:
public MainPage()
        {
            this.InitializeComponent();

            TestMySqlConnection();
        }

        private void TestMySqlConnection()
        {
            string dbConnectionString =
            " Server = 192.168.0.12;" +
            " Database = rcp;" +
            " Uid = rcp;" +
            " Pwd = papu52;";      

            using (MySqlConnection dbConnection = new MySqlConnection(dbConnectionString))
            {
                dbConnection.Open();
            }
        }
[13 Nov 2017 11:05] Adam Sarzyński
Application view

Attachment: error.png (image/png, text), 146.28 KiB.

[13 Nov 2017 11:08] Adam Sarzyński
When I try to connect to different version of MySql server (5.1.73) installed on other computer it works without problems.
[14 Nov 2017 12:03] Chiranjeevi Battula
Hello Adam,

Thank you for the bug report.
I could not repeat the issue at our end using with Visual Studio 2015, MySQL 5.7.20 and Connector/NET 6.10.4 version.

Thanks,
Chiranjeevi.
[14 Nov 2017 13:20] Adam Sarzyński
I tried 6.10.4 connector in UWP and the same problem exists.

I created test project in Windows Forms Application to connect to the same MySQL server (using the same connection string) and there was no problem.
[15 Nov 2017 12:38] Adam Sarzyński
I asked people on Stackoverflow and I found the solution:

This is what "Xavier Xie - MSFT" wrote:

Connecting to MySql database directly in UWP is a new feature which is introduced from .NET Standard 2.0.

For the previous Universal Windows Platform, it only supports .NET Standard 1.4.

So, that's the issue you're facing. I also can reproduce it on my side if I set my project's target version is 16299, but min version is the previous version (15063,14393 etc).

To solve this issue, you would need to make the project's target version and min version are 16299.