Failed to load type 'NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu'

I'm trying to work through your first NHibernate-based application to get the look of other ORM types (I'm used for DevExpress XPO), and I understand that there is a difference between the version that tut uses and the newest available version.

When I try to run the can_add_new_product test, I get an error message that asks this question.

  • I added a link to NHibernate.ByteCode.LinFu (CopyLocal = true)
  • I added a property to my hibernate.cfg.xml, for example (spaced a few lines for readability):

      NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu

And I made sure that I run build in x86.

What else can I do to solve this problem?

+3
source share
4 answers

The full syntax in node should look like this:

<property name="proxyfactory.factory_class">
   NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu
</property>

Can you verify that this is all text? Also make sure that with your DLL you have the following:

LinFu.DynamicProxy.dll
NHibernate.ByteCode.LinFu.dll

Hope this helps. I use this for lazy loading and it works successfully with 2.1.0GA branch (even if our branch has some fixes from the outside (SqlServerCE problems)

Update 1

Well, in my projects, I refer to the following assemblies:

  • Antlr3.Runtime.dll
  • Iesi.Collections.dll
  • LinFu.DynamicProxy.dll
  • log4net.dll
  • NHibernate.byteCode.LinFu.dll
  • NHibernate.dll

You can also publish the full hibernate.cfg.xml file, NHibernate configuration file?

Update 2

log4net? , - . - , :

FileAppender appender = new FileAppender();

appender.File = "nhibernate.log";
appender.LockingModel = new FileAppender.MinimalLock();
appender.ImmediateFlush = true;

pattern = "%timestamp, %thread, %level, %logger, %ndc,%message %newline";
PatternLayout pl = new PatternLayout(pattern);

appender.Layout = pl;
appender.ActivateOptions();
appender.Threshold = log4net.Core.Level.Verbose;

log4net.Config.BasicConfigurator.Configure(appender);

, , .

, .

3

, , , :

  • FirstSolution/Domain/Product.cs
  • LinFu.DynamicProxy NHibernate.ByteCode.LinFu FirstSolution.
  • NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu
  • SchemaExport (cfg).Execute(false, true, false, false); SchemaExport (cfg).Execute(false, true, false);
+7

App.Config( ) TEST :

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>

    <property name="connection.connection_string">ADD CON STRING</property>

    <property name="connection.isolation">ReadCommitted</property>
    <property name="default_schema">dbo</property>
    <property name="show_sql">true</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>



    <property name="cache.use_second_level_cache">false</property>
    <property name="cache.use_query_cache">false</property>
    <!-- HBM Mapping Files -->
    <mapping assembly="Namespace.Assembly"/>
  </session-factory>
</hibernate-configuration>

. App.Config Running, .. , .

, NHibernate, - .

LinFu.DynamicProxy Castle.DynamicProxy?

+1
0
source

I used Castle proxy and not linfu, but even I got a similar error. The problem is that since the proxy class is loaded dynamically, Visual Studio does not properly copy all the dependencies to the bin or bin \ debug directory. Check your build output directory; if there are no further files, copy them and then check

LinFu.DynamicProxy.dll NHibernate.ByteCode.LinFu.dll

0
source

All Articles