【问题标题】:Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle'无法加载类型“NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle”
【发布时间】:2011-04-27 15:48:02
【问题描述】:

嗯,

当我阅读并尝试了所有类似的主题但没有成功时,我决定发布我自己的问题。 我的解决方案有一个控制台应用程序和一个用于数据访问的类库。 Nhibernate 配置位于控制台应用程序的 appconfig 中(我目前正在使用它进行调试,因为我将在制作 Web 应用程序并将所有配置迁移到 web.config 之后)。

例外是众所周知的:

NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException: Unable to load type NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle.dll' 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 ---> System.IO.FileNotFoundException: Could not load file or assembly 'NHibernate.ByteCode.Castle.dll' or one of its dependencies. The system cannot find the file specified.

我尝试解决的步骤:

1) 部署文件夹中的 dll - 我的 bin 中有以下 dll:
Antlr3.Runtime.dll - v. 3.1.3.42154
Castle.Core.dll - v. 2.5.1.2121
Castle.DynamicProxy2.dll - v. 2.2.0.6628
Iesi.Collections.dll - v.3.0.0.1002
log4net.dll - v. 1.2.10.0
NHibernate.ByteCode.Castle.dll - v.3.0.0.2001 NHibernate.dll - v.3.0.0.1002
Oracle.DataAccess.dll - v.4.112.1.2
Remotion.Data.Linq.dll - v.1.13.41.2

2) 配置块中的配置

 <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
  <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
  <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
  <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
  <property name="connection.connection_string_name">MetaManager</property>
  <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle</property>
  <mapping assembly="MetaManager.Data"/>
</session-factory>

3) 我将 MetaManager.Data 项目设置为部署在 x86 CPU
4)我的bin文件夹中的所有dll都在项目中被引用。

我想这就是它。我不知道还有什么要走的:(

佩德罗·杜索

更新以粗体

【问题讨论】:

标签: c# oracle nhibernate hibernate


【解决方案1】:

我认为您的 Castle 版本有误。您应该拥有 Castle.Core.dll。 NHibernate.ByteCode.Castle.dll 可能没有加载,因为它找不到 Castle.Core.dll。

http://sourceforge.net/projects/nhibernate/files/NHibernate/3.0.0Beta1/ 的下载中,\Required_For_LazyLoading\Castle 中的文件就是您需要的文件。

【讨论】:

  • 非常感谢,但没有成功。我还在使用 alpha 版本,现在我更新到 beta 但错误仍然存​​在。我会继续寻找。再次感谢。
  • 尝试以下步骤:1) 删除所有 nhibernate dll 2) 清理然后重建您的项目 3) 从 beta zip 中复制 \Required_Bin 和 \Required_For_LazyLoading\Castle 中的所有 dll 并引用它们 4) 重建您的项目并验证所有 dll 是否在 bin\Debug 中。这通常对我有用。
  • 你不会相信... VS 在我的 MetaManaget.Data 项目中寻找控制台应用程序的 bin 文件夹中的 DLL(也不好命名为“Debug”...) :( 当我把 dll 我得到了一个不同的 (oracle) 错误.. 不一样的旧 **#$%#$ 字!感谢您的设想!
  • @Pmdusso:这是因为 VS 在编译后并不总是更新其引用路径,因此 DLL 的路径由 VS IDE 自动设置到您的 bin 文件夹。建议在您的项目属性中设置Reference Paths 以避免此类行为。 =)
  • 根据this answer,Castle 不再是必需的依赖项,根据this even newer answer,您甚至根本不需要配置代理。
猜你喜欢
  • 1970-01-01
  • 2011-04-05
  • 1970-01-01
  • 2012-08-14
  • 2015-08-28
  • 2016-03-05
  • 2014-08-09
  • 2015-04-16
  • 2010-09-08
相关资源
最近更新 更多