[Mono-dev] The mcs can not find NpgsqlConnection in Npgsql

bookman bookman bookmanb at gmail.com
Wed Nov 14 05:47:44 EST 2007


Hi ,

I planed to port my asp.net project to Linux ,i chose ubuntu   as
server.These are  the chosen platform:

ubuntu7.10-GutsyGibbon
mono-1.2.5.1
mod_mono-1.2.5
httpd-2.2.6
postgres-8.2.5
Npgsql2.0beta1-bin-mono2.0.tar.bz2

The document root of the website is as follows:

--myWeb
--myWeb/bin
--myWeb/bin/Npgsql.dll
--myWeb/bin/Mono.Security.dll
--myWeb/index.aspx
--myWeb/index.aspx.cs    #with no connection to postgre
--myWeb/test.cs                 #with a connection to postgre

I have decompressed the file
       Npgsql2.0beta1-bin-mono2.0.tar.bz2
and copied the Npgsql.dll and Mono.Security.dll to myWeb/bin  and  i
add the referrence of  Npgsql.dll and Mono.Security.dll.
      I can open the index.aspx in firefox and it works fine.

I compiled the test.cs using directive:
     $mcs  test.cs -r:System.Data -r:/bin/Npgsql.dll
and the errors come:


** (/usr/lib/mono/1.0/mcs.exe:8590): WARNING **: The class
System.Data.Common.DbConnection could not be loaded, used in
System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089

/home/herofox/myWeb/myWeb/test.cs(23,10): error CS0246: The type or
namespace name `NpgsqlConnection' could not be found. Are you missing
a using directive or an assembly reference?

** (/usr/lib/mono/1.0/mcs.exe:8590): WARNING **: The class
System.Data.Common.DbCommand could not be loaded, used in System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

/home/herofox/myWeb/myWeb/test.cs(25,9): error CS0246: The type or
namespace name `NpgsqlCommand' could not be found. Are you missing a
using directive or an assembly reference?

And i can not find the class DbCommand  in the namespace
System.Data.Common in mono-doc .
when i replace the NpgsqlConnection with Npgsql.NpgsqlConnection, the
errors changed:

/home/herofox/myWeb/myWeb/test.cs(23,11) : error CS0234: The type or
namespace name `NpgsqlConnection' does not exist in the namespace
`Npgsql'. Are you missing an assembly reference?
/home/herofox/myWeb/myWeb/test.cs(25,10) : error CS0234: The type or
namespace name `NpgsqlCommand' does not exist in the namespace
`Npgsql'. Are you missing an assembly reference?

I recompiled the test.cs using another directive:
     $gmcs  test.cs -r:System.Data -r:/bin/Npgsql.dll
Surprisingly, it worked and I found test.exe. Then i ran it:
     $mono test.exe
I found the error :

Got a SIGSEGV while excuting native code .this is usall indicate a
fatal error in the mono-runtime or one og the native libraries used by
your application .

 So what is wrong? Can you help me? Thank you very much.

#test.cs
using   System;
using   System.Data;
using   Npgsql;

public static class NpgsqlUserManual
{
  public static void Main(String[] args)
  {
    Npgsql.NpgsqlConnection conn = new
Npgsql.NpgsqlConnection("Server=127.0.0.1;Port=5432;User
Id=wen;Password=123456;Database=test;");
    conn.Open();

    Npgsql.NpgsqlCommand command = new  Npgsql.NpgsqlCommand("insert
into test values(4, 'wen');", conn);
    Int32  rowsaffected;

    try
    {
      rowsaffected = command.ExecuteNonQuery();

      Console.WriteLine("It was added {0} lines in table test", rowsaffected);
    }

    finally
    {
      conn.Close();
    }
  }
}



More information about the Mono-devel-list mailing list