MySqlConnector icon indicating copy to clipboard operation
MySqlConnector copied to clipboard

Unable to deploy mySqlConnector with my application

Open paulisidore opened this issue 1 year ago • 5 comments
trafficstars

HI, for 2 weeks I have been trying to move from MySql.Data to MySqlConnector for .NET, the program works correctly on the development machine (Visual Studio 2022) but once deployed it does not work and I receive this exception:

Unable to load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The specified file can not be found.

Development OS: Windows 10 Pro 22H2 Deployment OS: Windows 10 Pro 22H2 and 1607 MariaDB Server 10.5.13

The System.Runtime.CompilerServices.Unsafe file is present in the application folder on all machines. Also, the same application using mysql.data works correctly on all computers.

I also deleted MySql.Data.dll from the application folder but I still got the same result.

I also changed the version of my MariaDB Server to version 10.11 but no results while version 10.5.13 works without problems on my development computer.

Please, could you help me?

paulisidore avatar May 04 '24 05:05 paulisidore

You need to "nuget" System.Runtime.CompilerServices.Unsafe

Make sure to copy the .dll where your app is deployed.

tcsaddul avatar May 04 '24 06:05 tcsaddul

Hello @tcsaddul and thank you for your answer. I have already installed this Nuget and I mentioned it in my previous post. I also checked that it is deployed in the application folder. I think it's a nuget dependency that I don't know about...

paulisidore avatar May 04 '24 12:05 paulisidore

Make sure that your application has the privilege (manifest) to access the folder and the version of the .dll is the same. Also make sure the declaration in the exe.config are the same version or remove the line.

tcsaddul avatar May 04 '24 13:05 tcsaddul

Sounds like a binding redirect issue; see my answer (for a different assembly) here (and follow similar steps): https://github.com/mysql-net/MySqlConnector/issues/1139#issuecomment-1041548740.

bgrainger avatar May 04 '24 20:05 bgrainger

@tcsaddul , The application has acces to the folder since when I return to MySQL.Data.Dll the application works without problems on all workstations. For the version of the dlls, I am thinking of using the "Binding Redirect" option, I have no way of checking the ideal versions except to look at the NuGet package manager. Besides, is there a way to check the version of the assembly loaded by the application to find incompatibilities?

Hello @bgrainger and thank you for your messages, I will try the Binding Redirect option on Mondays and will get back as soon as possible.

paulisidore avatar May 04 '24 22:05 paulisidore