- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 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 transport error. 的可能原因是什么?
如果我在单元测试之外运行代码(例如 Main),它会起作用。顺便说一句,如果我对 Sqlite 进行单元测试,它也不会导致任何错误
最佳答案
找到答案,我尝试从终端 (/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/2868/Npgsql2.0.11-bin-ms.net4.0.zip )更改为 http://pgfoundry.org/frs/download.php/2860/Npgsql2.0.11-bin-mono2.0.zip在此之后,就没有更多的 Unix 传输错误 ^_^
经验教训,如果您在 Mono 上运行,请使用您正在使用的组件的 Mono 版本
关于nhibernate - 是什么导致: Unix transport error?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4344225/
我有一个带有Post模型和 Controller 的Rails应用,并且正在使用ActiveAdmin for CMS。我已经实现了ElasticSearch和SearchKick,现在正尝试使用Se
我在Rails应用中使用了elasticsearch gem。我正在尝试执行基本搜索,并按与当前位置的距离对结果进行排序。但是尝试搜索时出现以下错误: [400] {"error":{"root_ca
在我的 Rails 应用程序中,安装了“elasticsearch-model”和“elasticsearch-rails”gems,elasticsearch (v5.1.1) 在默认端口上运行,模
有时批量发布时会出现暂时失败的项目错误 Transport service unable to transport 多次刷新发布队列将导致返回成功。为什么会发生这种情况? 最佳答案 我认为一旦发布事务
当我尝试使用 elasticsearch 进行索引时收到此消息。我已经尝试过 elasticsearch-rails gem 和 searchkick gem。我们正在在线创建和编辑电子类(class
错误:未找到传输方式,或所选传输方式尚不支持! 当我调用网络服务时会发生此错误。 这是我的代码: include("lib/bankmellat/nusoap.php"); $client = new
在本地环境中工作时不确定 elasticsearch我收到这个奇怪的错误,任何帮助我都会很感激。谢谢 Elasticsearch::Transport::Transport::Errors::NotF
RoundTripper 界面是这样的 type RoundTripper interface { RoundTrip(*Request) (*Response, error) } 内部net
我正在尝试使用以下程序来显示从端口 8888 收到的消息。我编译了以下代码,没有任何错误和警告。 运行后,我用浏览器打开127.0.0.1:8888 然后,控制台显示: read: Transport
使用 socket.io v1.2.1(仅使用“轮询”传输),有时我的客户会遇到断开连接。 大约 50% 的时间我在断开连接事件回调函数中得到 ping timeout,这是合理的。 其他时候,我得到
我使用嵌入式代理 ActiveMq 并从 JavaScript 应用程序连接到它。使用的协议(protocol)是 STOMP over WebSocket。 Spring 的 XML 配置:
看来我已经根据http://dev.apollodata.com/tools/apollo-server/setup.html上的Apollo文档设置了服务器。在我的server/main.js文件中
我已经将Xcode升级到Xcode 7,并在pList中包括了App Transport Security(ATS)功能。目前,我已通过将YES分配给NSAllowsArbitraryLoads来禁用
我是Elasticsearch的新手,试图连接到运行1.5.2版的远程集群。我已将相同版本的Maven依赖项添加到我的项目中。我正在使用以下Scala代码初始化Transport客户端: val se
import matplotlib.pyplot as plt import numpy as np from sklearn import datasets, linear_model # Crea
我正在尝试制作这个简单的服务器脚本,其中多个客户端连接到它并存储在 factory.connected_clients 字典中。然后我想显示一个菜单,以便执行服务器的用户可以选择他想要使用的客户端以及
大家好, 我们正在设计一个电视模块。在当前的架构中,我们有两个独立的设备,每个设备都在 Atom 处理器上运行 Linux。我们需要通过网络将实时传输流从一台设备传输到另一台设备。我尝试寻找在Linu
我正在尝试测试 Android auto backup .我在 7.1 设备上,应用程序 list 包含:android:fullBackupOnly="true" .当我发出 adb shell b
该方法是静态的,但我找不到它是否是线程安全的。我计划同时使用多个线程执行此方法,并且我想尽可能避免使用同步块(synchronized block)。 javax.mail.Transport.sen
我正在尝试将 Meek 集成到 Android 应用程序中。这里有一个示例展示了如何实例化传输: https://github.com/guardianproject/AndroidPluggable
我是一名优秀的程序员,十分优秀!