FluentNHibernate CreateSessionFactory错误
我无法解决问题:尝试执行 http://wiki. Fluentnhibernate.org/Getting_started#Your_first_project< 中的教程/a> 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。)
I cant solve the problem: Try to execute tutorial from http://wiki.fluentnhibernate.org/Getting_started#Your_first_project
error occur in CreateSessionFactory() method:
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
I use Windows 7, Visual Studio 29010, FluentNHibernate 1.2.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
in C:\_Learning\ORM\ FluentNHibernate\Program.cs:line 120
问题在于您已将项目命名为
fluenceNhibernate
。将其命名为其他名称(TestProject)。实际上,我在 SO 上的许多帖子中都看到了同样的问题。in C:\_Learning\ORM\fluentNHibernate\Program.cs:line 120
The problem is the fact that you've named your project
fluentNhibernate
. Name it something else (TestProject). I've actually seen this same problem in numerous posts on SO.