В Visual Studio я создал простой vNext консольное приложение и установлен Npgsql с командойNpgsql.NpgsqlConnection не реализует интерфейс System.Collections.IEnumerator
Install-Package Npgsql
.
Вот код, Program.cs и project.json
using Npgsql;
using System;
namespace ConsoleApp3
{
public class Program
{
public void Main(string[] args)
{
Console.WriteLine("Hello postgresql!");
// Specify connection options and open an connection
NpgsqlConnection conn = new NpgsqlConnection("Server=myserv;User Id=postgres;" +
"Password=postgres;Database=mydb;");
conn.Open();
// Define a query
NpgsqlCommand cmd = new NpgsqlCommand("select name from mytb", conn);
// Execute a query
NpgsqlDataReader dr = cmd.ExecuteReader();
// Read all rows and output the first column in each row
while (dr.Read())
Console.Write("{0}\n", dr[0]);
// Close connection
conn.Close();
Console.ReadLine();
}
}
}
{
"version": "1.0.0-*",
"dependencies": {
"Npgsql": "2.2.4.3",
"System.Data.Common": "4.0.0-beta-22605"
},
"commands": {
"ConsoleApp3": "run"
},
"frameworks": {
"aspnet50": {
"frameworkAssemblies": {
"System.Data": "4.0.0.0"
}
}
}
}
Все работает отлично.
Затем я скопировал этот код на машине с ОС Mono и Debian.
mono --version
Mono JIT compiler version 3.12.1 (tarball Fri Mar 6 19:12:47 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono- project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
Тогда я сделал
kpm restore
и
k run
И я получил исключение:
Hello postgresql!
Npgsql.NpgsqlConnection doesn't implement interface System.Collections.IEnumerator
Stacktrace:
at <unknown> <0xffffffff>
at ConsoleApp3.Program.Main (string[]) <0x0004c>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>
at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0xffffffff>
at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x000d7>
at System.Reflection.MethodBase.Invoke (object,object[]) <0x0002a>
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly,string[],System.IServiceProvider) <0x0010b>
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain (Microsoft.Framework.Runtime.DefaultHost,string,string[]) <0x0026f>
at Microsoft.Framework.ApplicationHost.Program.Main (string[]) <0x0043f>
at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this___object (object,intptr,intptr,intptr) <0xffffffff>
at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0xffffffff>
at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x000d7>
at System.Reflection.MethodBase.Invoke (object,object[]) <0x0002a>
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly,string[],System.IServiceProvider) <0x0010b>
at kre.host.Bootstrapper.Main (string[]) <0x002f3>
at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this___object (object,intptr,intptr,intptr) <0xffffffff>
at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0xffffffff>
at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x000d7>
at System.Reflection.MethodBase.Invoke (object,object[]) <0x0002a>
at kre.hosting.RuntimeBootstrapper.ExecuteAsync (string[]) <0x01667>
at kre.hosting.RuntimeBootstrapper.Execute (string[]) <0x00053>
at EntryPoint.Main (string[]) <0x00167>
at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <0xffffffff>
Native stacktrace:
mono() [0x4accac]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xf0a0) [0x7f03a02c60a0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35) [0x7f039ff5e165]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x180) [0x7f039ff613e0]
mono() [0x6232f9]
mono() [0x623507]
mono() [0x6235b2]
mono() [0x4aebe7]
mono() [0x4af3c3]
[0x40ef3de6]
Debug info from gdb:
=================================================================
Got a SIGABRT while executing native code.
This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Aborted
Кто-нибудь имеет какие-либо идеи, как справиться с этим?