简体   繁体   English

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

[英]Error when trying to run Fluent NHibernate tutorial example

I have downloaded the Fluent NHibernate source distribution, compiled all projects in solution and then run Examples.FirstProject.我已经下载了 Fluent NHibernate 源代码分发版,在解决方案中编译了所有项目,然后运行 Examples.FirstProject。 Exception occur in FluentConfiguration.cs in method BuildSessionFactory(): An invalid or incomplete configuration was used while creating a SessionFactory. FluentConfiguration.cs 方法 BuildSessionFactory() 中发生异常:创建 SessionFactory 时使用了无效或不完整的配置。 What shall I do to avoid this exception?我应该怎么做才能避免这个异常?

PS I saw this post but its not help me PS我看到了这篇文章,但它对我没有帮助

Edit: Exception Message "The following types may not be used as proxies:\nExamples.FirstProject.Entities.Employee: method set_Id should be 'public/protected virtual' or 'protected internal virtual'\nExamples.FirstProject.Entities.Product: method set_Id should be 'public/protected virtual' or 'protected internal virtual'\nExamples.FirstProject.Entities.Store: method set_Id should be 'public/protected virtual' or 'protected internal virtual'" string编辑:异常消息“以下类型不能用作代理:\nExamples.FirstProject.Entities.Employee:方法 set_Id 应该是 'public/protected virtual' 或 'protected internal virtual'\nExamples.FirstProject.Entities.Product:方法set_Id 应该是 'public/protected virtual' 或 'protected internal virtual'\nExamples.FirstProject.Entities.Store: 方法 set_Id 应该是 'public/protected virtual' 或 'protected internal virtual'" 字符串

Exception Source: "NHibernate"异常来源: “NHibernate”

Exception StackTrace: StackTrace " at NHibernate.Cfg.Configuration.ValidateEntities() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1051\r\n at NHibernate.Cfg.Configuration.Validate() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 958\r\n at NHibernate.Cfg.Configuration.BuildSessionFactory() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1250\r\n at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in C:\_WorkProjects\_nHibernate\jagregory-fluent-nhibernate-c24de5a\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 231" string异常 StackTrace: StackTrace " 在 NHibernate.Cfg.Configuration.ValidateEntities() 在 d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1051\r\n 在 Z111BBE34492093E9894EF9E8BB.E3. d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 958\r\n 中的 Validate() 在 d:\CSharp\NH\NH 中的 NHibernate.Cfg.Configuration.BuildSessionFactory() \nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1250\r\n 在 FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() 在 C:\_WorkProjects\_nHibernate\jagregory-fluent-nhibernate-c24de5a\src\Fluent \FluentConfiguration.cs:第 231 行" 字符串

Go to (Examples.FirstProject -> Entities -> and in (Employee.cs, Product.cs, and Store.cs) Go 到(Examples.FirstProject -> Entities -> 并在(Employee.cs、Product.cs 和 Store.cs)中

Change the Id property from:更改 Id 属性:

public virtual int Id { get; private set; }

To:至:

public virtual int Id { get; set; }

Your type, Examples.FirstProject.Entities.Employee should have the ID property set to您的类型 Examples.FirstProject.Entities.Employee 应将 ID 属性设置为

public virtual int ID { get; set; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM