2010-12-03 6 views
2

원인 : Unix 전송 오류?

PostgreSQL에서 단위 테스트 (NUnit 사용)를하고 있습니다. 불행히도 오류가 발생합니다.

Internal error 
    RemotingException: Unix transport error. 

참고 : Sqlite

를 사용하면 오류가 발생하지 않습니다. 코드 :

 using System; 
using ncfg = NHibernate.Cfg; 
using System.Collections.Generic; 
using System.Reflection; 
using NHibernate; 
using System.Data; 
using NHibernate.Tool.hbm2ddl; 
using NHibernate.Dialect; 
using NHibernate.Driver; 
using NHibernate.ByteCode.LinFu; 
using NUnit.Framework; 
using NHibernate.Mapping; 



namespace RuntimeNhibernate 
{ 
    class MainClass 
    { 
    public static void Main (string[] args) 
    { 


    using(var c = new BlogTestFixture()) 
    { 
    c.CanSaveAndLoadBlog(); 

    } 

    } 
    } 



    public class InMemoryDatabaseTest : IDisposable 
    { 
    private static ncfg.Configuration Configuration; 
    private static ISessionFactory SessionFactory; 
    protected ISession session; 

    public InMemoryDatabaseTest(Assembly assemblyContainingMapping) 
    { 
    if (Configuration == null) 
    { 

    Configuration = new ncfg.Configuration() 
     .SetProperty(ncfg.Environment.ReleaseConnections,"on_close") 
     .SetProperty(ncfg.Environment.Dialect, typeof (SQLiteDialect).AssemblyQualifiedName) 
     .SetProperty(ncfg.Environment.ConnectionDriver, typeof(SQLite20Driver).AssemblyQualifiedName) 
     .SetProperty(ncfg.Environment.ConnectionString, "data source=:memory:") 
     .SetProperty(ncfg.Environment.ProxyFactoryFactoryClass, typeof (ProxyFactoryFactory).AssemblyQualifiedName) 
     .AddAssembly(assemblyContainingMapping); 


    /*Configuration = new ncfg.Configuration() 
     .SetProperty(ncfg.Environment.ReleaseConnections,"on_close") 
     .SetProperty(ncfg.Environment.Dialect, typeof (PostgreSQLDialect).AssemblyQualifiedName) 
     .SetProperty(ncfg.Environment.ConnectionDriver, typeof(NpgsqlDriver).AssemblyQualifiedName) 
     .SetProperty(ncfg.Environment.ConnectionString, "Server=127.0.0.1;Database=memdb;User ID=postgres;Password=password;Pooling=false;") 
     .SetProperty(ncfg.Environment.ProxyFactoryFactoryClass, typeof (ProxyFactoryFactory).AssemblyQualifiedName) 
     .AddAssembly(assemblyContainingMapping);*/ 

    SessionFactory = Configuration.BuildSessionFactory(); 
    } 

    session = SessionFactory.OpenSession(); 

    new SchemaExport(Configuration).Execute(true, true, false, session.Connection, Console.Out); 
    } 

    public void Dispose() 
    { 
    session.Dispose(); 
    } 
    }//class InMemory 

    public class Blog 
    { 
    public virtual int BlogId { get; set; } 
    public virtual bool AllowsComments { set; get; } 
    public virtual DateTime CreatedAt { get; set; } 
    public virtual string Subtitle { get; set; } 
    public virtual string Title { get; set; } 
    } 

    [TestFixture] 
    public class BlogTestFixture : InMemoryDatabaseTest 
    { 
    public BlogTestFixture() : base(typeof(Blog).Assembly) 
    { 
    } 


    [Test] 
    public void IsOK() 
    { 
    Assert.AreEqual(true, true); 
    return; 
    } 

    [Test]  
    public void CanSaveAndLoadBlog() 
    { 


    object id; 




    using (var tx = session.BeginTransaction()) 
    { 
    id = session.Save(new Blog 
    { 
     AllowsComments = true, 
     CreatedAt = new DateTime(2000,1,1), 
     Subtitle = "Hello", 
     Title = "World", 
    }); 

    tx.Commit(); 
    } 

    session.Clear(); 

    Console.WriteLine("Hello {0}", id); 


    using (var tx = session.BeginTransaction()) 
    { 
    var blog = session.Get<Blog>(id); 




    Assert.AreEqual(new DateTime(2000, 1, 1), blog.CreatedAt); 
    Assert.AreEqual("Hello", blog.Subtitle); 
    Assert.AreEqual("World", blog.Title); 
    Assert.AreEqual(true, blog.AllowsComments); 

    tx.Commit(); 
    } 
    } 
    }//Test 


}//namespace 

단위 테스트 Postgresql, 결과 RemotingException : Unix 전송 오류가 발생할 수있는 이유가 될 수 있습니다.?

코드를 단위 테스트 (예 : Main)를 벗어나 실행하면 작동합니다. Btw, 만약 내가 단위 테스트 Sqlite, 어떤 오류도 발생하지 않습니다

+0

프로그램과 같은 소리가 포트가 아닌 소켓을 통해 연결을 시도하고 있습니다. Postgres TCP/IP 포트를 사용하도록 커넥터를 구성 할 수 있습니까? –

답변

0

이 발생하지 않을 경우, BTW, 내가 터미널 (/Applications/MonoDevelop.app/Contents/MacOS/monodevelop)에서 MonoDevelop을 시작했는데, 내가 본 단위 테스트를 실행했을 때 명령 줄에서 자세한 오류가 발생했습니다.

Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Npgsql.NpgsqlConnection ---> System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'Npgsql'. 
    at (wrapper managed-to-native) System.MonoCustomAttrs:GetCustomAttributesInternal (System.Reflection.ICustomAttributeProvider,System.Type,bool) 
    at System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider obj, System.Type attributeType) [0x00000] in <filename unknown>:0 
    at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0 
    at System.Reflection.Assembly.GetCustomAttributes (System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0 
    at System.Resources.ResourceManager.GetNeutralResourcesLanguage (System.Reflection.Assembly a) [0x00000] in <filename unknown>:0 
    at System.Resources.ResourceManager..ctor (System.Type resourceSource) [0x00000] in <filename unknown>:0 
    at Npgsql.NpgsqlConnection..cctor() [0x00000] in <filename unknown>:0 
    --- End of inner exception stack trace --- 
    at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod*,object,object[],System.Exception&) 
    at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 

가 그럼 난^_^

수업 배운 더 이상 유닉스 전송 오류가 없다는 Npgsql 버전 이후 http://pgfoundry.org/frs/download.php/2860/Npgsql2.0.11-bin-mono2.0.zip에 (에러가 http://pgfoundry.org/frs/download.php/2868/Npgsql2.0.11-bin-ms.net4.0.zip에서 온 원인 중 하나)을 변경 시도의를 사용 Mono 버전을 사용하는 경우 사용중인 구성 요소의 Mono 버전

0

이 예외는 MonoDevelop의 단위 테스트에서 테스트 러너가 발견 할 수없는 예외가 발생할 때 발생합니다 (예 : 테스트에서 일부 스레드가 시작될 때). 그리고 그들은 추락한다). 당신이 회색 같은 시험이있는 경우

not executable test

및 단위 테스트 패드를 실행 한 후

enter image description here

당신의 테스트를 실행해야하는 내부 오류를 보여줍니다 콘솔 nunit-console (mono의 출처 인 배포판의 레포에 있어야 함) 예외가 누출됩니다.

내 경우에는 테스트의 하위 스레드에서 간단한 여러 열거 예외가 발생했습니다.

Unhandled exceptions: 
1) Residata.Platform.Server.Message.Test.MemoryBrokerTest.AssertThatReceiveMethodWaitsUntilPublish : System.InvalidOperationException: Collection was modified; enumeration operation may not execute. 
    at System.Collections.Generic.List`1+Enumerator[Residata.Platform.Contract.Message.IPackage].MoveNext() [0x00000] in <filename unknown>:0 
관련 문제