[Mono-list] MySql.Data problems

DevLOOP devloop at flight.us
Wed Jan 2 04:00:12 UTC 2013


On January 1, 2013 at 4:57 PM Daniel Lo Nigro <lists at dan.cx> wrote:

>
>  As the error mentions, you need to reference System.Data as well as
> MySql.Data.
>

I take it you mean reference it in my *.cs file, with "using <blah>" statements.
 Remember, I am a complete newbie, so I'm still very unsure where anything fits,
with the variety of contexts (the web-request/config context, command-line
context (cli arguments), the C-sharp code, etc.,etc.

OK, so, I persisted further with the referencing and got my "helloworld.cs" to
compile...

It turns out, apparently, that the "MySql.Data" and "System.Data" modules (each)
need to be referenced TWICE, (redundantly?), with the CLI compilation.  You need
to include the modules on the command line AS WELL AS inside the *.cs file, with
the "-r:" switch:

         gmcs -r:MySql.Data.dll -r:System.Data helloworld.cs

So, it compiled to "helloworld.exe". But when I run the executable ...

           mono  helloworld.exe

... the executable throws an error:


Missing method .ctor in assembly
/opt/mono-3.0.2/lib/mono/gac/MySql.Data/6.6.4.0__c5687fc88969c44d/MySql.Data.dll,
type System.Security.SecurityRulesAttribute
Can't find custom attr constructor image:
/opt/mono-3.0.2/lib/mono/gac/MySql.Data/6.6.4.0__c5687fc88969c44d/MySql.Data.dll
mtoken: 0x0a00002a

Unhandled Exception:
System.TypeLoadException: Could not load type
'System.Security.SecurityRulesAttribute' from assembly 'MySql.Data'.
  at X.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type
'System.Security.SecurityRulesAttribute' from assembly 'MySql.Data'.
  at X.Main () [0x00000] in <filename unknown>:0



>  ---
>  Regards,
>  Daniel
>
>  Sent from my phone - please excuse any typos.
>
>  On 02/01/2013 7:35 AM, "DevLOOP" < devloop at flight.us
> <mailto:devloop at flight.us> > wrote:
>    > >    When I run:
> >
> >    gmcs -r:MySql.Data.dll helloworld.cs
> >
> >    I get:
> >
> >    helloworld.cs(9,8): error CS0246: The type or namespace name
> > `IDbConnection'
> >    could not be found. Are you missing an assembly reference?
> >    helloworld.cs(10,20): error CS0012: The type
> > `System.Data.Common.DbConnection'
> >    is defined in an assembly that is not referenced. Consider adding a
> > reference to
> >    assembly `System.Data, Version=4.0.0.0, Culture=neutral,
> >    PublicKeyToken=b77a5c561934e089'
> >    helloworld.cs(10,8): error CS0841: A local variable `dbcon' cannot be
> > used
> >    before it is declared
> >    helloworld.cs(11,8): error CS0841: A local variable `dbcon' cannot be
> > used
> >    before it is declared
> >    helloworld.cs(13,8): error CS0246: The type or namespace name
> > `IDbCommand' could
> >    not be found. Are you missing an assembly reference?
> >    helloworld.cs(19,8): error CS0841: A local variable `dbcmd' cannot be
> > used
> >    before it is declared
> >    helloworld.cs(20,8): error CS0246: The type or namespace name
> > `IDataReader'
> >    could not be found. Are you missing an assembly reference?
> >    helloworld.cs(22,14): error CS0841: A local variable `reader' cannot be
> > used
> >    before it is declared
> >    helloworld.cs(23,13): error CS0103: The name `Console' does not exist in
> > the
> >    current context
> >    Compilation failed: 9 error(s), 0 warnings
> >
> >    -----------------
> >
> >    I thought I installed the component:  I downloaded the connector from
> > mysql.com <http://mysql.com> ,
> >    and ran:
> >
> >    gacutil -i -package 4.0 v4/MySql.Data.dll
> >
> >    (also, with "-package 4.5" and "-package 2.0")
> >
> >    and I can see the installed files:
> >  /opt/mono-3.0.2/lib/mono/4.0/MySql.Data.dll
> >    (a symlink to
> > 
> >   /opt/mono-3.0.2/lib/mono/gac/MySql.Data/6.6.4.0__c5687fc88969c44d/MySql.Data.dll
> >    )
> >
> >    and I also have:
> > 
> >   /opt/mono-3.0.2/lib/mono/gac/MySql.Data/6.6.4.0__c5687fc88969c44d/MySql.Data.dll
> >
> >    What is missing or incorrect?
> >
> >    thanks
> >    _______________________________________________
> >    Mono-list maillist  -   Mono-list at lists.ximian.com
> > <mailto:Mono-list at lists.ximian.com>
> >    http://lists.ximian.com/mailman/listinfo/mono-list
> > <http://lists.ximian.com/mailman/listinfo/mono-list>
> >  >


More information about the Mono-list mailing list