【发布时间】:2011-04-05 15:47:21
【问题描述】:
我在整个互联网上都在寻找我的这个特殊问题。我找到了一些建议的解决方案,但它们不起作用。
设置如下:
我正在使用 ActiveRecord/NHibernate。我创建了一个包装 ActiveRecord 的程序集,称为 BusinessLogic。我的想法是我所有的项目都应该使用 BusinessLogic 而不是直接引用 ActiveRecord/NHibernate。
我在 GAC(.NET 的全局程序集缓存)中安装了以下文件:
- Antlr3.Runtime.dll BusinessLogic.dll
- BusinessLogic.dll
- Castle.ActiveRecord.dll
- Castle.Components.Validator.dll
- Castle.Core.dll
- Castle.DynamicProxy2.dll
- Iesi.Collections.dll log4net.dll
- NHibernate.ByteCode.Castle.dll
- NHibernate.dll
问题如下:当我执行从数据库读取产品信息的 ASP.NET 应用程序时,我收到以下错误消息:
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.
如果我将 NHibernate.ByteCode.Castle.dll 的本地副本放入 ASP.NET 应用程序的 bin 文件夹中,错误就消失了。但是出现了一个新的错误。它说 NHibernate 在 BusinessLogic.dll 中找不到类(例如 Product 等)。
如果我将 BusinessLogic.dll 的本地副本放入 ASP.NET 应用程序的 bin 文件夹中,即使此错误已修复并且应用程序运行良好。
但这并不是我们所希望的,因为我不想在更新 BusinessLogic 时使用 BusinessLogic 重新编译每个应用程序。
我发现这篇文章承诺会有所帮助:http://markmail.org/message/o22r2x5fng7i6jn5#query:activerecord%20gac+page:1+mid:4rlqoicqyxjh3ypb+state:results
很遗憾,这并不能解决问题。
我将以下内容放入 machine.config 文件中:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="NHibernate.ByteCode.Castle" fullName="NHibernate.ByteCode.Castle,version=2.1.2.4000,publicKeyToken=aa95f207798dfdb4,culture=neutral" />
</assemblyBinding>
</runtime>
错误还是一样。 NHibernate 找不到类 NHibernate.ByteCode.Castle.ProxyFactoryFactory
非常感谢任何帮助。
【问题讨论】:
-
为什么一开始就将它们放在 GAC 中...
-
因为它几乎被我们所有的应用程序使用。这似乎是一个很好的解决方案。经验教训:只有在 GAC 完成后才将其放入 GAC。在 GAC 中跟踪不同版本简直是天方夜谭。
标签: c# asp.net nhibernate business-logic