试图运行功能NHibernate教程例如,当运行时错误 [英] Runtime error when trying to run Fluent NHibernate tutorial example

查看:705
本文介绍了试图运行功能NHibernate教程例如,当运行时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过功能NHibernate教程曾在 http://wiki.fluentnhibernate.org/Getting_started 并该项目编译罚款。

I worked through the Fluent NHibernate tutorial at http://wiki.fluentnhibernate.org/Getting_started and the project compiles fine.

不过,我得到一个运行时错误,我似乎无法来解决它。错误发生在CreateSessionFactory方法,你可以在本教程中看到的。在这里,它是:

However, I am getting a runtime error and I can't seem to resolve it. The error is happening in the CreateSessionFactory method you can see in the tutorial. Here it is:

private static ISessionFactory CreateSessionFactory()
{
    return Fluently.Configure()
        .Database
        (
            SQLiteConfiguration.Standard
                .UsingFile(DbFile)
        )
        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<FluentNHibernateSample.Program>())
        .ExposeConfiguration(BuildSchema)
        .BuildSessionFactory();

}



我觉得最helpfule做的事情就是给你异常链(是一个真正的字)从最外层例外,最内层异常:

I think the most helpfule thing to do is to give you the Exception chain (is that a real word) from the Outermost exception to the inner most exception:

An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
    An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
        Could not compile the mapping document: (XmlDocument)
            persistent class FluentNHibernateSample.Entities.Employee, FluentNHibernate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null not found
                Could not load file or assembly 'FluentNHibernate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

本教程并不明确如何设置参考值(或至少不全似乎基于最内部异常的),所以我得到了来自 HTTP编译的程序集:// fluentnhibernate.org/downloads/releases/fluentnhibernate-1.1.zip 并复制它们放入一个libs文件夹。根据谷歌搜索错误我设置为FluentNHibernate,NHibernate的,和NHibernate.ByteCode.Castle组件的引用。我复制了所有从下载页面中的DLL到bin目录,我还以为所有的引用会解决。 (这是我的它是如何工作的理解)。在这里无论如何是我复制到Bin文件列表。

The tutorial was not clear on how to setup the reference (or at least seems incomplete based on the most inner exception) so I got the compiled assemblies from http://fluentnhibernate.org/downloads/releases/fluentnhibernate-1.1.zip and copied them into a libs folder. Based on googling the error I set a references to the FluentNHibernate, NHibernate, and NHibernate.ByteCode.Castle assemblies. I copied ALL of the dlls from the downloads page into the bin directory and I thought that all of the references would resolve. (That is my understanding of how it works). In any case here is the list of files I copied into bin.

Antlr3.Runtime.dll
FluentNHibernate.dll
FluentNHibernate.exe
FluentNHibernate.pdb
FluentNHibernate.vshost.exe
FluentNHibernate.vshost.exe.manifest
FluentNHibernate.xml
Iesi.Collections.dll
Iesi.Collections.xml
log4net.dll
log4net.xml
NHibernate.ByteCode.Castle.dll
NHibernate.dll
NHibernate.xml

我也复制System.Data.Sqlite装配到bin。

I also copied System.Data.Sqlite assembly to the bin.

有关我的生活,我不能找出问题是什么。我已经试过所有我能想到的一派多个错误消息,但一切都没有为我工作。

For the life of me I cannot figure out what the problem is. I have tried everything I can think of and googled multiple error messages but nothing has worked for me.

帮助!我已经浪费了这个时间。

Help! I have wasted hours on this.

修改结果
我已经把源文件的项目在的 http://dl.dropbox.com/u/8824836/FluentNHibernateExample.zip 。请记住,完全复制我的环境中,你需要在这里一>到您的输出/ bin目录。

EDIT
I have put the source files for the project at http://dl.dropbox.com/u/8824836/FluentNHibernateExample.zip. Keep in mind that to fully replicate my environment you need to put all of the files from here into your output/bin directory.

赛斯

推荐答案

我觉得这个白痴,但在一天结束的映射问题的事实,我已经命名的项目FluentNHibernate(在我自己的防守它是在一个样本文件夹)引起的,但认为是导致映射失败。

I feel like an idiot for this but at the end of the day the mapping problem was caused by the fact that I had named the project FluentNHibernate (in my own defense it was in a SAMPLES folder) but that was causing the mapping to fail.

在内部的Visual Studio默认大会名称FluentNHibernate以及导致运行时错误。重命名大会ConsoleApplication固定它。

Internally Visual Studio defaulted the Assembly name to FluentNHibernate and that was causing the runtime error. Renaming the assembly to ConsoleApplication fixed it.

赛斯

这篇关于试图运行功能NHibernate教程例如,当运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆