NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException

I have the following code configured 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 get 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 reasons:

  • The NHibernate.Bytecode Provider Node has not been deployed.
  • The TypeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.

I read and read that I am rewriting all the assemblies in the list , and I am in complete loss, like what needs to be done 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 that the assembly is in the basket. Does anyone have any ideas?

+4
source share
2 answers

This problem occurs when NHibernate.ByteCode.Castle.dll was created with a different target platform as your project. To verify this, change the target platform of the program to one or more of the following:

  • x64 - x86
  • x86 - x64
  • Any processor on x86
  • Any processor for x64

If any of them solves your problem, then you know that you just need to synchronize the DLL and the target platform.

+5
source

I also had this problem, my solution was to add to the assembly that creates the following code session.

 private NHibernate.ByteCode.Castle.ProxyFactoryFactory requiredButNeverUsed; 
0
source

Source: https://habr.com/ru/post/1304630/


All Articles