gpt4 book ai didi

NHibernate Validator 在升级到 3.1 后抛出 System.NotSupportedException

转载 作者:行者123 更新时间:2023-12-03 17:18:17 24 4
gpt4 key购买 nike

有没有人遇到过这个?

升级到 NHibernate 3.1 后,我在运行 NUnit 测试用例时从 NHibernate Validator 收到以下异常:

System.NotSupportedException : The invoked member is not supported in a dynamic assembly. at System.Reflection.Emit.InternalAssemblyBuilder.GetManifestResourceStream(String name) at NHibernate.Validator.Cfg.XmlMappingLoader.AddResource(Assembly assembly, String resource) at NHibernate.Validator.Cfg.XmlMappingLoader.GetXmlMappingFor(Type type) at NHibernate.Validator.Engine.JITClassMappingFactory.GetExternalDefinitionFor(Type type) at NHibernate.Validator.Engine.JITClassMappingFactory.GetClassMapping(Type clazz, ValidatorMode mode) at NHibernate.Validator.Engine.ClassValidator.InitValidator(Type clazz, IDictionary`2 nestedClassValidators) at NHibernate.Validator.Engine.ClassValidator..ctor(Type clazz, IConstraintValidatorFactory constraintValidatorFactory, IDictionary`2 childClassValidators, IClassValidatorFactory factory) at NHibernate.Validator.Engine.StateFullClassValidatorFactory.GetRootValidator(Type type) at NHibernate.Validator.Engine.ValidatorEngine.GetClassValidator(Type entityType) at NHibernate.Validator.Engine.ValidatorEngine.GetElementOrNew(Type entityType) at NHibernate.Validator.Engine.ValidatorEngine.InternalValidate(Object entity, Object[] activeTags) at NHibernate.Validator.Engine.ValidatorEngine.Validate(Object entity, Object[] activeTags) at NHibernate.Validator.Event.ValidateEventListener.Validate(Object entity, EntityMode mode) at NHibernate.Validator.Event.ValidatePreUpdateEventListener.OnPreUpdate(PreUpdateEvent event) at NHibernate.Action.EntityUpdateAction.PreUpdate() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Action\EntityUpdateAction.cs: line 200 at NHibernate.Action.EntityUpdateAction.Execute() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Action\EntityUpdateAction.cs: line 58 at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\ActionQueue.cs: line 136 at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\ActionQueue.cs: line 126 at NHibernate.Engine.ActionQueue.ExecuteActions() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\ActionQueue.cs: line 170 at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Event\Default\AbstractFlushingEventListener.cs: line 241 at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Event\Default\DefaultFlushEventListener.cs: line 19 at NHibernate.Impl.SessionImpl.Flush() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs: line 1472 at TestDataAccess.FooTest.TestFoo() in FooTest.cs



正如您从堆栈跟踪中看到的那样,当 session 被刷新并且 NHibernate Validator 执行其操作时会发生错误。

更新 我曾尝试单步执行 NH Validator 代码,似乎在某些时候它正在尝试验证实体的 CaSTLe 代理,而不是底层实体本身。这会导致麻烦。不知道该怎么办这个...

更新 如果我使用 LinFu ProxyFactoryFactory 而不是 CaSTLe,问题就会消失。不幸的是,LinFu 给了我 other problems所以我不想使用它。

最佳答案

NHibernate 3.2 不再需要外部代理库。

它们仍然受支持,但不再分发,并且默认使用内部实现。

你试过升级吗?

更新:为了编译NHibernate Validator for NH 3.2,需要修改NHibernateHelper如下:

public static bool IsProxyFactoryConfigurated()
{
var f = NHibernate.Cfg.Environment.BytecodeProvider.ProxyFactoryFactory;
return f != null;
}

详情请阅读 NHV-116

关于NHibernate Validator 在升级到 3.1 后抛出 System.NotSupportedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8032843/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com