FluentNHibernate CreateSessionFactory错误

时间:2011-09-01 09:33:04

标签: c# .net exception-handling fluent-nhibernate

我无法解决问题:尝试从http://wiki.fluentnhibernate.org/Getting_started#Your_first_project执行教程 CreateSessionFactory()方法中出现错误:

 FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete conf
iguration was used while creating a SessionFactory. Check PotentialReasons colle
ction, and InnerException for more detail.

 ---> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplet
e configuration was used while creating a SessionFactory. Check PotentialReasons
 collection, and InnerException for more detail.

 ---> NHibernate.MappingException: Could not compile the mapping document: (XmlD
ocument) ---> NHibernate.MappingException: persistent class fluentNHibernateexam
ple.Entities.Employee, fluentNHibernate, Version=1.0.0.0, Culture=neutral, Publi
cKeyToken=null not found ---> System.IO.FileLoadException: Could not load file o
r assembly 'fluentNHibernate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=n
ull' or one of its dependencies. The located assembly's manifest definition does
 not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError,
Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, Bool
ean loadTypeFromPartialName, ObjectHandleOnStack type)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError,
Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean l
oadTypeFromPartialName)
   at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean
ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
   at System.Type.GetType(String typeName)
   at NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName n
ame, Boolean throwOnError) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Util\Ref
lectHelper.cs:line 291
   at NHibernate.Cfg.XmlHbmBinding.Binder.ClassForFullNameChecked(String fullNam
e, String errorMessage) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\XmlHbmB
inding\Binder.cs:line 99
   --- End of inner exception stack trace ---
   at NHibernate.Cfg.XmlHbmBinding.Binder.ClassForFullNameChecked(String fullNam
e, String errorMessage) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\XmlHbmB
inding\Binder.cs:line 103
   at NHibernate.Cfg.XmlHbmBinding.ClassBinder.BindClass(IEntityMapping classMap
ping, PersistentClass model, IDictionary`2 inheritedMetas) in d:\CSharp\NH\NH\nh
ibernate\src\NHibernate\Cfg\XmlHbmBinding\ClassBinder.cs:line 35
   at NHibernate.Cfg.XmlHbmBinding.RootClassBinder.Bind(HbmClass classSchema, ID
ictionary`2 inheritedMetas) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Xml
HbmBinding\RootClassBinder.cs:line 19
   at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.AddEntitiesMappings(HbmMapp
ing mappingSchema, IDictionary`2 inheritedMetas) in d:\CSharp\NH\NH\nhibernate\s
rc\NHibernate\Cfg\XmlHbmBinding\MappingRootBinder.cs:line 42
   at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.Bind(HbmMapping mappingSche
ma) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\XmlHbmBinding\MappingRootBi
nder.cs:line 29
   at NHibernate.Cfg.Configuration.AddDeserializedMapping(HbmMapping mappingDocu
ment, String documentFileName) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\
Configuration.cs:line 522
   --- End of inner exception stack trace ---
   at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception) in d:\CSharp
\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 342
   at NHibernate.Cfg.Configuration.AddDeserializedMapping(HbmMapping mappingDocu
ment, String documentFileName) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\
Configuration.cs:line 530
   at NHibernate.Cfg.Configuration.ProcessMappingsQueue() in d:\CSharp\NH\NH\nhi
bernate\src\NHibernate\Cfg\Configuration.cs:line 1832
   at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String
name) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 630

   at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc, String name) in
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 481
   at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc) in d:\CSharp\NH\
NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 455
   at FluentNHibernate.PersistenceModel.Configure(Configuration cfg)
   at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
   at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
   --- End of inner exception stack trace ---
   at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
   at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
   --- End of inner exception stack trace ---
   at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
   at Examples.FirstProject.Program.CreateSessionFactory() in C:\_Learning\ORM\f
luentNHibernate\Program.cs:line 120

我使用Windows 7,Visual Studio 29010,FluentNHibernate 1.2。)

1 个答案:

答案 0 :(得分:1)

in C:\_Learning\ORM\fluentNHibernate\Program.cs:line 120

问题在于您已将项目命名为fluentNhibernate。将其命名为其他(TestProject)。我在SO上的很多帖子中都看到了同样的问题。