[Mono-dev] Problem in running an EXE (mono + Npgsql +PostgreSQL + Linux)

Ramprasad G ramprasad.g at enterprisedb.com
Wed Dec 10 06:00:11 EST 2008


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20081210/ca3cbf75/attachment-0001.html 


More information about the Mono-devel-list mailing list