Xamarin Mac and MySql.Data

MarkAnthonyHobbsMarkAnthonyHobbs GBMember
edited May 2016 in Xamarin.iOS

I've been using the MySql.Data package (which I believe is managed by Oracle) with a command line Xamarin project perfectly well for a number of months but I'm struggling to get it running with Xamarin.Mac.

Even when compiling I'm getting a significant number of serious sounding warnings, but compiles. The first few warnings out of 23 are along the lines of:

Warning MM2006: Native library '/Users/username/Test_OSX/Test_OSX/bin/Debug/Test_OSX.app/Contents/MonoBundle/libMonoPosixHelper.dylib' was referenced but could not be found. (MM2006) (Test_OSX)
Warning MM2006: Native library '/Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.2.1/lib/libsecur32.dylib' was referenced but could not be found. (MM2006) (Test_OSX)
Warning MM2006: Native library 'libsecur32.dylib' was referenced but could not be found. (MM2006) (Test_OSX)
Warning MM2009: Referenced by MySql.Data.MySqlClient.Authentication.MySqlWindowsAuthenticationPlugin.AcquireCredentialsHandle (MM2009) (Test_OSX)

However, when attempting to run the Xamarin.Mac application with some test/example MySQL connection code I get the following error on NSApplication.Init():

System.IO.FileNotFoundException has been thrown. Could not load file or assembly 'System.Drawing' or one of its dependencies

Which is a bizarre and seemingly unrelated error that goes away when removing the MySQL Connection code.

Should we be expecting the MySQL.Data package in the official NuGet gallery to work out of the box with Xamarin.Mac? I have even tried compiling the package from source direct from Oracle (in case it was an issue with x86/x64 platform types or something) but that hasn't help either - I get the same issue.

Any help would be appreciated.

Regards
Hobsie

Best Answer

Answers

  • MarkAnthonyHobbsMarkAnthonyHobbs GBMember

    Thanks Chris!

    Well I managed to strip out any reference to System.Drawing in the source of MySQL.Data from Oracle, but now it's complaining about another missing package at runtime (System.Configuration.Install).

    So i'm just going to tear this thing to shreds and see if it still works for our purposes after I'm done with the code machete.

    Regards
    Hobsie

  • MarkAnthonyHobbsMarkAnthonyHobbs GBMember

    I think that's done it.

    For the benefit of anyone looking to use Oracle's MySQL.Data (v6.9.8) package with Xamarin.Mac I had to delete the following references in their source package (using the solution called MySQLClient-VS2013.sln in Xamarin on Mac):

    • System.Drawing
    • System.Configuration.Install
    • System.Configuration
    • System.Management

    And then removed/commented out any code/files relating to those packages.

    That seems to work for now (it's connecting to a local MySQL database at least). No doubt I'll have broken something somewhere but this looks promising for now.

    Thanks again Chris,
    Hobsie

  • RaulDuqueRaulDuque USMember

    Dear Mark,

    I'm creating a new project using MySql package v6.9.9 and I'm getting the same error from a Android project ...

    did you created a branch of the patched code?
    did you have any issue with this patched version?

  • wombi1973wombi1973 USMember

    @RaulDuque said:
    Dear Mark,

    I'm creating a new project using MySql package v6.9.9 and I'm getting the same error from a Android project ...

    did you created a branch of the patched code?
    did you have any issue with this patched version?

    Hi all,

    I too would be interested in this. I have just started using the new VisualStudio 2017 for mac....basically same setup as for Xamarin.mac and cannot get anything to do with loading MySQL references/packages working.

    Being such a common and popular database, it is extremely annoying to not be able to write a Xamarin.mac app using MySQL.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    As I noted before, much of this feedback is more appropriately send to the package maintainer. The fact that their SQL package depends on System.Drawing is more than a bit suspect.

    Mono's implementation of System.Drawing depends on libgdiplus which has broken customer applications more than once.

    We have considered adding extending the XM BCL package to include https://github.com/mono/sysdrawing-coregraphics . However, as it surfaces only a subset of the API, it would likely be even more confusing - "My application has System.Drawing.dll references and loaded, why am I getting these TypeLoad errors?"

Sign In or Register to comment.