[Mono-dev] Problem in running an EXE (mono + Npgsql +PostgreSQL + Linux)
Rafael Teixeira
monoman at gmail.com
Tue Dec 16 10:19:26 EST 2008
Use gmcs, as you are using a version of Npgsql that requires .NET 2 system
classes. and it is compiling with dependencies to 1.x.
Hope it helps,
2008/12/10 Ramprasad G <ramprasad.g at enterprisedb.com>
> Hello,
> I am using *Mono* in Linux 32-bit Ubuntu.,I want to connect to PostgreSQL
> 8.3 database server using Npgsql driver
>
> This is my sample c# code:
>
> using System;
> using System.Data;
> using Npgsql;
>
> public static class NpgsqlUserManual
> {
> public static void Main(String[] args)
> {
> NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User
> Id=postgres;Password=postgres;Database=npgsql;");
> conn.Open();
>
> NpgsqlCommand command = new NpgsqlCommand("insert into test values(2004)",
> conn);
> Int32 rowsaffected;
>
> try
> {
> rowsaffected = command.ExecuteNonQuery();
>
> Console.WriteLine("It was added {0} lines in table test", rowsaffected);
> }
>
> finally
> {
> conn.Close();
> }
> }
> }
>
> I am able to compile the CS code using mcs.
>
> * mcs SimpleExample.cs -r:System.Data -r:Npgsql.dll*
>
> It creates an EXE named SimpleExample.exe,then i tried to run that EXE
> using mono
>
> *mono SimpleExample.exe*
>
> It throws the following error
>
> *** (SimpleExample.exe:18076): WARNING **: The class
> System.Data.Common.DbConnection could not be loaded, used in System.Data,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
>
> Unhandled Exception: System.TypeLoadException: Could not load type
> 'System.InvalidProgramException' from assembly 'mscorlib,
> Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.*
>
>
> The Npgsql.dll is the same directory only.
>
> FYKI :Information about Mono in my machine:
>
> Mono:
>
> Mono JIT compiler version 20081007 (tarball)
> Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
> TLS: __thread
> GC: Included Boehm (with typed GC)
> SIGSEGV: altstack
> Notifications: epoll
> Architecture: x86
> Disabled: none
>
> mcs:
>
> mcs --version
> Mono C# compiler version 200.1007.0.0
>
> This is a run time issue since the compilation was successful. Any solution
> to this will be highly appreciated.
>
> --
> Thanks & Regards,
> Ramprasad G
>
>
>
>
>
>
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
--
Rafael "Monoman" Teixeira
---------------------------------------
"I myself am made entirely of flaws, stitched together with good
intentions."
Augusten Burroughs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20081216/a788eb8f/attachment.html
More information about the Mono-devel-list
mailing list