简体   繁体   中英

C# Mono MySql connector :Unable to connect to any specified MySQL hosts

I'm assuming this is a bug with the MySQL connector with mono but i thought i'd ask incase somone has found a work around.

I have a VS solution running .net 4(latest mono), i'm using the latest version of the MySQL connector fresh off their website this morning.

If I open the project with visual studio , compile and run the MySQL connector connects to the MySQL database almost instantly and all is well.

If I open the exact same project in MonoDevelop (causing it to be built with mono rather then MS .net4) with not a single line of code changed, the MySQL connector reply's with "Unable to connect to any specified MySQL hosts"

This cannot be a database problem else I would be seeing the problem on both builds. Even remaining in MonoDevelop and building with the MS .net framework from there still results in a good connection.

My connection string contains server, port, uid, password,Connection timeout, database, pooling

More details :

Windows 7 x64 visual studio 2010 Mono 2.10.8 MonoDevelop 3.0.2

I've seen a large number of results from googling my question, but they all seems to be differing issues, or due to old bugs that have since been fixed by method's that certainly haven't worked in this case.

Edit : can anyone replicate what I am seeing here ?

Try to add "TrustedConnection" as "True" to your connection string. Also make sure you are building as x86 not "Any Cpu". Hope it helps

Check http://www.mono-project.com/MySQL for MySQL specific instructions. Specifically make sure that MySql.data.dll is in the GAC:

cd path_to_your MySql.Data.dll assembly
gacutil -i MySql.Data.dll

There is also some example code on the site that may help.

Best of luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM