代码之家  ›  专栏  ›  技术社区  ›  Seth Spearman

尝试运行Fluent NHibernate教程示例时出现运行时错误

  •  1
  • Seth Spearman  · 技术社区  · 15 年前

    http://wiki.fluentnhibernate.org/Getting_started 这个项目编制得很好。

    然而,我得到一个运行时错误,我似乎无法解决它。错误发生在您可以在教程中看到的CreateSessionFactory方法中。在这里:

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

    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目录中,我认为所有引用都可以解析(这就是我对它工作原理的理解)。无论如何,这是我复制到垃圾箱的文件列表。

    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 装配到垃圾箱。

    救命啊!我在这上面浪费了好几个小时。


    我已经把这个项目的源文件放在 http://dl.dropbox.com/u/8824836/FluentNHibernateExample.zip . 请记住,要完全复制我的环境,您需要将 here 输入output/bin目录。

    4 回复  |  直到 15 年前
        1
  •  5
  •   Seth Spearman    15 年前

    visualstudio内部将程序集名称默认为FluentNHibernate,这导致了运行时错误。将程序集重命名为ConsoleApplication修复了它。

    塞思

        2
  •  2
  •   James Gregory    15 年前

    下载Fluent NHibernate源代码发行版,然后看看示例项目;然后,您可以将这些项目的引用与您的项目的引用进行比较。

        3
  •  0
  •   anthony    15 年前

    您可能还需要:

    • Castle.Core.dll
    • Castle.DynamicProxy2.dll
        4
  •  0
  •   Bevan    15 年前

    就因为你的项目 编译

    外部例外(与 FluentNHibernate 大会可能是一个红鲱鱼)。

    试着注释掉所有的nhibernate映射,除了最简单、最简单的部分,然后看看它是否有效。如果是这样,则逐渐取消注释,直到找到失败的部分。

    推荐文章