NHibernate 1.2在.NET 4.0解决方案中

时间:2010-07-21 15:45:03

标签: nhibernate .net-4.0

我有一些基于NHibernate 1.2的项目,我想将它们添加到.NET 4.0解决方案中,但我得到一个AmbiguousMatchException。
无论这些项目是针对2.0还是4.0框架 如果我将它们添加到.NET 3.5解决方案中,它就可以工作。

有没有人有这方面的经验?

以下是例外:

[AmbiguousMatchException: Ambiguous match found.]
   System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) +9607924
   System.Type.GetMethod(String name) +29
   Castle.DynamicProxy.Builder.CodeBuilder.SimpleAST.LockBlockExpression.Emit(IEasyMember member, ILGenerator gen) +192
   Castle.DynamicProxy.Builder.CodeBuilder.SimpleAST.ExpressionStatement.Emit(IEasyMember member, ILGenerator gen) +52
   Castle.DynamicProxy.Builder.CodeBuilder.AbstractCodeBuilder.Generate(IEasyMember member, ILGenerator il) +370
   Castle.DynamicProxy.Builder.CodeBuilder.EasyMethod.Generate() +71
   Castle.DynamicProxy.Builder.CodeBuilder.AbstractEasyType.EnsureBuildersAreInAValidState() +706
   Castle.DynamicProxy.Builder.CodeBuilder.AbstractEasyType.BuildType() +90
   Castle.DynamicProxy.Builder.CodeGenerators.BaseCodeGenerator.CreateType() +55
   Castle.DynamicProxy.Builder.CodeGenerators.ClassProxyGenerator.GenerateCode(Type baseClass, Type[] interfaces) +573
   Castle.DynamicProxy.Builder.DefaultProxyBuilder.CreateClassProxy(Type theClass, Type[] interfaces) +87
   Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type baseClass, Type[] interfaces, IInterceptor interceptor, Boolean checkAbstract, Object[] argumentsForConstructor) +116
   NHibernate.Proxy.CastleProxyFactory.GetProxy(Object id, ISessionImplementor session) +136

[HibernateException: Creating a proxy instance failed]
   NHibernate.Proxy.CastleProxyFactory.GetProxy(Object id, ISessionImplementor session) +270
   NHibernate.Persister.Entity.AbstractEntityPersister.CreateProxy(Object id, ISessionImplementor session) +17
   NHibernate.Impl.SessionImpl.DoLoadByClass(Type clazz, Object id, Boolean checkDeleted, Boolean allowProxyCreation) +354
   NHibernate.Impl.SessionImpl.InternalLoad(Type clazz, Object id, Boolean eager, Boolean isNullable) +52
   NHibernate.Type.EntityType.ResolveIdentifier(Object id, ISessionImplementor session) +37
   NHibernate.Type.EntityType.ResolveIdentifier(Object id, ISessionImplementor session, Object owner) +55
   NHibernate.Impl.SessionImpl.InitializeEntity(Object obj) +187
   NHibernate.Loader.Loader.InitializeEntitiesAndCollections(IList hydratedObjects, Object resultSetId, ISessionImplementor session) +229
   NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +702
   NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +62
   NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +51
   NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) +18
   NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes) +81
   NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session) +36
   NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results) +315
   NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria) +66
   NHibernate.Impl.CriteriaImpl.List() +54  
   [my code calling Criteria.List()]

2 个答案:

答案 0 :(得分:14)

答案 1 :(得分:3)

此时NHibernate 1.x完全不受支持。您应该至少升级到2.1.2。

在任何情况下,从错误消息中可以清楚地看出问题不在NHibernate本身,而是在Castle DynamicProxy中。