There is something fishy in Sandard/Core versions of MySQL.Data.dll
Posted by: Tuomas Hietanen
Date: October 06, 2017 11:30AM

.NET versions of 6.9.9 and 6.10.3-rc seems to work well. But there is something fishy in .NET CORE / STANDARD versions of 6.10.3-rc and 8.0.9 dmr.

I got constantly errors:

 Derived types must either match the security accessibility of the base type or be less accessible.

Inheritance security rules violated by type: 'MySql.Data.MySqlClient.MySqlCommand'. 
Inheritance security rules violated by type: 'MySql.Data.MySqlClient.MySqlConnection'. 
Inheritance security rules violated by type: 'MySql.Data.MySqlClient.MySqlDataReader'.
Inheritance security rules violated by type: 'MySql.Data.MySqlClient.MySqlException'. 
Inheritance security rules violated by type: 'MySql.Data.MySqlClient.MySqlParameter'. 
Inheritance security rules violated by type: 'MySql.Data.MySqlClient.MySqlParameterCollection'. 
Inheritance security rules violated by type: 'MySql.Data.MySqlClient.MySqlClientFactory'.
Inheritance security rules violated by type: 'MySql.Data.MySqlClient.MySqlConnectionStringBuilder'.


To reproduce, here is a little sample program:

using System;

namespace ConsoleApp4
{
	class Program
	{
		//Add first a reference to System.Data.Common.dll

		static void Main(string[] args)
		{
			var pathToDll = @"C:\source\lib\netstandard1.3\MySql.Data.dll";
			var assembly = System.Reflection.Assembly.LoadFrom(pathToDll);
			try
			{
				//Crash:
				var types = assembly.GetTypes();
			}
			catch (System.Reflection.ReflectionTypeLoadException e)
			{
				foreach(var ex in e.LoaderExceptions)
				{
					Console.WriteLine(ex.Message);
				}
			}
			Console.ReadLine();
		}

	}
}

As said earlier, the previous versions don't have this error. But I would like to use .NET Standard / .NET Core.
I expect this is related to [assembly: AllowPartiallyTrustedCallers] and changed assembly.SecurityRuleSet.

Options: ReplyQuote


Subject
Written By
Posted
There is something fishy in Sandard/Core versions of MySQL.Data.dll
October 06, 2017 11:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.