NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException
I have the following code set up in my Startup
IDictionary<string, string> properties = new Dictionary<string, string>();
properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
properties.Add("dialect", "NHibernate.Dialect.MsSql2005Dialect");
properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
properties.Add("connection.connection_string", "Data Source=ZEUS;Initial Catalog=mydb;Persist Security Info=True;User ID=sa;Password=xxxxxxxx");
InPlaceConfigurationSource source = new InPlaceConfigurationSource();
source.Add(typeof(ActiveRecordBase), (IDictionary<string, string>) properties);
Assembly asm = Assembly.Load("Repository");
Castle.ActiveRecord.ActiveRecordStarter.Initialize(asm, source);
I am getting the following error:
failed: NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException : Unable to load type 'NNHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class.
Possible causes are:
- The NHibernate.Bytecode provider assembly was not deployed.
- T开发者_JAVA技巧he typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.
I have read and read I am referecning the All the assemblies listed and I am at a total loss as what to try next.
Castle.ActiveRecord.dll
Castle.DynamicProxy2.dll Iesi.Collections.dll log4net.dll NHibernate.dll NHibernate.ByteCode.Castle.dll Castle.Core.dll.I am 100% sure the assembly is in the bin. Anyone have any ideas?
This problem occurs when NHibernate.ByteCode.Castle.dll was built with a different target platform as your project. To test this, change your program target platform from one or more of the following:
- x64 to x86
- x86 to x64
- "Any CPU" to x86
- "Any CPU" to x64
If any of those solve your problem, then you know that you just need to synchronize the DLL and your target platform.
I had this problem also, my solution was to add in the Assembly that creates session following code.
private NHibernate.ByteCode.Castle.ProxyFactoryFactory requiredButNeverUsed;
精彩评论