NHibernate under SharePoint 2010
I am having trouble getting NHibernate up and running under SharePoint 2010.
My config code works as I have an integration test project running fine.
The problem is to do with gac assemblies and NHibernate references resulting in this error:
[FileNotFoundException: Could not load file or assembly 'NHibernate.ByteCode.Castle' or one of its dependencies. The system cannot find the file specified.]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +416
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166
System.Reflection.Assembly.Load(String assemblyString) +35
NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName name, Boolean throwOnError) +641
NHibernate.Bytecode.AbstractBytecodeProvider.SetProxyFactoryFactory(String typeName) +67
[UnableToLoadProxyFactoryFactoryException: Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class.
Possible causes are:
- The NHibernate.Bytecode provider assembly was not deployed.
- The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.
Solution:
Confirm that your deployment folder contains one of the following assemblies:
NHibernate.ByteCode.LinFu.dll
NHibernate.ByteCode.Castle.dll]
NHibernate.Bytecode.AbstractBytecodeProvider.SetProxyFactoryFactory(String typeName) +336
NHibernate.Cfg.Configuration.ConfigureProxyFactoryFactory() +179
NHibernate.Cfg.Configuration.BuildSessionFactory() +23
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +50
FYI, NHibernate.ByteCode.Castle is registe开发者_如何学Cred in the gac. I also have these two item in web.config:
<compilation batch="false" debug="true">
<assemblies>
<add assembly="NHibernate.ByteCode.Castle, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4" />
....
&
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="NHibernate.ByteCode.Castle, Version=3.1.0.4000, Culture=neutral" fullName="NHibernate.ByteCode.Castle, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4" />
...
Any clues as to the extra wiring required?
The "or one of its dependencies" remark might be worth further investigation. Get Dependency Walker and check whether NHibernate.ByteCode.Castle.dll depends on anything else, and if it does, whether it's in the GAC or not.
this was the key bit, not specifying culture or version in the partialName:
<qualifyAssembly partialName="NHibernate.ByteCode.Castle" fullName="NHibernate.ByteCode.Castle, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4" />
did the trick
精彩评论