Bug #75556 MySql.Data.Entity.EF6.dll cannot be loaded by Mono
Submitted: 19 Jan 2015 16:57 Modified: 13 Jun 2016 11:17
Reporter: Jaime Vetter Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.9.5 OS:Linux (CentOS 7)
Assigned to: CPU Architecture:Any
Tags: EF6, linux, Mono, NET

[19 Jan 2015 16:57] Jaime Vetter
Description:
I am attempting to use the MySql Entity Framework 6 (EF6) libraries on linux with Mono but the EF6 library cannot be loaded by mono.

For example:
[XXXXXXX@localhost]$ unzip mysql-connector-net-6.9.5-noinstall.zip
[XXXXXXX@localhost]$ cd v4.5
[XXXXXXX@localhost v4.5]$ monop -r ./MySql.Data.Entity.EF6.dll

Assembly Information:
MySql.Data.Entity.EF6
Version=6.8.4.0
Culture=neutral
PublicKeyToken=c5687fc88969c44d

Unhandled Exception:
System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetExportedTypes () [0x00000] in <filename unknown>:0
  at MonoP.PrintTypes (System.String assembly, Boolean show_private, Boolean filter_obsolete) [0x00000] in <filename unknown>:0
  at MonoP.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetExportedTypes () [0x00000] in <filename unknown>:0
  at MonoP.PrintTypes (System.String assembly, Boolean show_private, Boolean filter_obsolete) [0x00000] in <filename unknown>:0
  at MonoP.Main (System.String[] args) [0x00000] in <filename unknown>:0

**See attached file for full description....

How to repeat:
- In Windows 8.1
  - Install VS Community 2013
  - Install msql-connector-net-6.9.5
  - Create new solution
  - Create new console project
  - Create new class library project
  - Set console project to reference library project
  - In library project create an entity and bind it to library
  - Add references in the library to the MySql.Data, MySql.Data.Entity.EF6 libs 
  - Create an entity in the library via a diagram and bind it to a MySQL database running on the CentOS box
  - In the program create the entity object and print "Hello World" in code
  - Compile program and copy to your linux box
- On CentOS 7
  - Unzip connector 6.9.5
  - Use gacutil -i to add v4.5 assemblies to the gac
  - Run program
    - You will get the second stack trace in my description
  - Run monop -r against the EF6 assembly
    - You will get the first stack trace in my description
- In Windows 
  - Update the program to also reference the same EF6 does
  - Rebuild and copy over new binaries
- On Linux
  - Run program
    - You will see the 3rd stack trace in my description
  - Uninstall linux MySQL DLLs via gacutil -u
  - Manually copy ones from windows into your programs directory
  - Run program
    - You will see the same 3rd stack trace in my description

- Lower your head in defeat :(

  

Suggested fix:
Get the MySql.Data.Entity.EF6.dll to properly load in Mono
[19 Jan 2015 16:58] Jaime Vetter
Full Description

Attachment: FullDescription.txt (text/plain), 10.19 KiB.

[3 Apr 2015 13:35] Marc Kohaupt
Hi,
I don't know if this helps you, but this issue seems to be fixed in newer version of mono (I actually use mono HEAD, therefore I don't know if it's already fixed in some released version):

./packages/MySql.Data.Entity.6.9.5/lib/net45$ monop -r MySql.Data.Entity.EF6.dll 

Assembly Information:
MySql.Data.Entity.EF6
Version=6.9.5.0
Culture=neutral
PublicKeyToken=c5687fc88969c44d

MySql.Data.Entity.BackoffAlgorithm
MySql.Data.Entity.BackoffAlgorithmErr1040
MySql.Data.Entity.BackoffAlgorithmErr1205
MySql.Data.Entity.BackoffAlgorithmErr1213
MySql.Data.Entity.BackoffAlgorithmErr1614
MySql.Data.Entity.BackoffAlgorithmErr2006
MySql.Data.Entity.BackoffAlgorithmErr2013
MySql.Data.Entity.BackoffAlgorithmNdb
MySql.Data.Entity.MySqlConnectionFactory
MySql.Data.Entity.MySqlDependencyResolver
MySql.Data.Entity.MySqlEFConfiguration
MySql.Data.Entity.MySqlExecutionStrategy
MySql.Data.Entity.MySqlHistoryContext
MySql.Data.Entity.MySqlLogger
MySql.Data.Entity.MySqlManifestTokenResolver
MySql.Data.Entity.MySqlMigrationCodeGenerator
MySql.Data.Entity.MySqlMigrationSqlGenerator
MySql.Data.Entity.MySqlModelCacheKey
MySql.Data.Entity.MySqlProviderFactoryResolver
MySql.Data.Entity.MySqlProviderInvariantName
MySql.Data.Entity.OpType
MySql.Data.MySqlClient.MySqlProviderServices
MySql.Data.MySqlClient.MySqlScriptServices

Total: 23 types.
[mono] ~/Dropbox/Arbeit/Athena/SourceCode/Athena Linux/packages/MySql.Data.Entity.6.9.5/lib/net45$ 
[mono] ~/Dropbox/Arbeit/Athena/SourceCode/Athena Linux/packages/MySql.Data.Entity.6.9.5/lib/net45$ mono -V
Mono JIT compiler version 4.1.0 (master/44bccac Sa 21. Mär 17:17:54 CET 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug 
        LLVM:          supported, not enabled.
        GC:            sgen
[13 Jun 2016 11:17] Chiranjeevi Battula
Hello Jaime Vetter,

Thank you for the bug report.
I could not repeat the issue at our end using with Visual Studio 2013, Connector/NET 6.9.8 and  Entity Framework 6.1.3.
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.