[Mono-list] newbie: "using System.Data.MySql" fails

Mike Morano mmorano at mikeandwan.us
Tue Sep 18 18:52:16 EDT 2007


As the compiler indicates, you are not specifying the correct namespace
for mysql.  It is not "System.Data.MySql", rather, you should have
something more along the lines of:

using MySql.Data.MySqlClient;


For future reference, you can easily get a listing of the types defined
in a dll using monop2.  You can do:

monop2 -r:MySql.Data.dll

and this will show all the types and namespaces defined in the dll.


-Mike


Daniel Soto wrote:
> Hello :-)
> 
> The same problem happened to me, but in a web application.
> Are you compiling with mcs? In my case, these driver not worked fine in 
> .net 1.1 (mcs, mono-apache-server, xsp) but it worked fine in .net 2.0 
> (gmcs, mono-apache-server2, xsp2).
> 
> Try compiling with gmcs.
> 
> Regards.
> 
> R.A.M. escribió:
>> Hello
>> I am writing my first Mono console application that connects to MySQL
>> database. I have installed MySQL 5.0, I installed MySQL Connector .NET
>> driver and I copied it to GAC with a command: sudo gacutil -i
>> MySql.Data.dll. I have created new C# project (TestMono) in MonoDevelop with
>> such code:
>>
>> using System;
>> using System.Data.MySql;
>> namespace TestMono
>> {
>>     class MainClass
>>     {
>>         public static void Main(string[] args)
>>         {
>>         ...
>>         }
>>     }
>> }
>>
>> The problem is that I receive a compile error:
>>
>> [Task:File=/home/robert/Projects/TestMono/TestMono/Main.cs, Line=2,
>> Column=1, Type=Error, Description=The type or namespace name
>> `System.Data.MySql' could not be found. Are you missing a using directive or
>> an assembly reference?(CS0246)
>>
>> I also tried to add reference to copy of MySql.Data.dll but I got the same
>> message. However, I would prefer to have my driver in GAC.
>>
>> Could anyone help me please to solve the problem?
>> Thanks!
>> /RAM/
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list


More information about the Mono-list mailing list