2015-04-01 62 views
0

在Visual Studio中,我创建简单的vNext的控制台应用程序,并安装与Npgsql的Npgsql.NpgsqlConnection没有实现接口System.Collections.IEnumerator

​​

命令。

下面是代码,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 OS的机器上。

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 

任何人有任何想法,如何处理呢?

回答

0

问题出在旧版本Npgsql.dll中,存储在Mono GAC中。 Bootloader使用这个旧的二进制文件替代NuGet包中的全新Npgsql.dll。