vinnylinux
vinnylinux

Reputation: 7024

.NET Core 2 with MySql.Data results in permission error

I'm using Dapper, .NET Core 2 and MySql.Data to create a small REST API on Linux. Unfortunately, i keep getting this error on my connection:

Exception has occurred: CLR/System.IO.FileNotFoundException
An exception of type 'System.IO.FileNotFoundException' occurred in MySql.Data.dll but was not handled in user code: 'Could not load file or assembly 'System.Security.Permissions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.'
at MySql.Data.MySqlClient.MySqlConnection.AssertPermissions()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at Dapper.SqlMapper.<QueryImpl>d__124`1.MoveNext()

Does anyone have any idea what is going on?

Upvotes: 5

Views: 5965

Answers (4)

shados250
shados250

Reputation: 1

Yes, it seems is bug of MySql.Data.dll (My version is 6.10.6 from nugget-repository).

I'm trying to connect to Maria DB and get the same error:

Database not found on server with connection string in settings: Could not load file or assembly 'System.Security.Permissions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

error screenshot

I had solved that: There are 3 kinds of "MySql.Data.dll" lib at Nuget-package mysql.data 6.10.6.0:

  1. netcoreapp 2.0 lib
  2. netstandard 1.3 lib
  3. netstandard 2.0 lib

During using netcoreapp 2.0 or netstandard 2.0 - it cames error. During using netstandard 1.3 lib - it works finally, and has no error!

Upvotes: 0

vinnylinux
vinnylinux

Reputation: 7024

I solved by upgrading to 8.0.8-dmr.

Upvotes: 2

knowledgeseeker
knowledgeseeker

Reputation: 1203

Try adding System.Security.Permissions, Version=4.0.0.0 from nuget.

Upvotes: 9

user8534733
user8534733

Reputation: 1

I don't know what's happening, but I get the same issue.

I have noticed that if you look at the DEPENDANCICES.NuGET node under the solution and look at the "MySqlData(6.9.9)" and expand it, you'll see a warning messages about something was restored with .net Framework 4.6.1. (in my case anyway)

It looks like to me, something in the NuGet package from the author isn't correct.

Upvotes: 0

Related Questions