NHibernate Validator throws a System.NotSupportedException after upgrading to 3.1

Has anyone come across this?

After upgrading to NHibernate 3.1, I get the following exception from NHibernate Validator when running NUnit test cases:

System.NotSupportedException: The called item is not supported in a dynamic assembly. in System.Reflection.Emit.InternalAssemblyBuilder.GetManifestResourceStream (String name) in NHibernate.Validator.Cfg.XmlMappingLoader.AddResource (Assembly Assembly, String resource) on NHibernate.Validator.Cfg.XmlMappingLMateLoader.ModeLoader.Ometer Engine.JITClassMappingFactory.GetExternalDefinitionFor (Type Type) with NHibernate.Validator.Engine.JITClassMappingFactory.GetClassMapping (Type clazz, ValidatorMode mode) with NHibernate.Validator.Engine.ClassValidator.InitVatelidalidator (type) ClidValidator. Engine.ClassValidator..ctor (type clazz, Constraint IConstraintValidatorFactoryValidatorFactory, IDictionary`2 childClassValidators, IClassValidatorFactory factory) in NHibernate.Validator.Engine.StateFullClassValidate. typeVididate.idatididate.idididate.idididator.idididator.idididalidator.idididator.idididator.idididalidator.idididalidator.idididalidator.idididalidator.idididator.idididalidator.idididalidator.idididalidator.idatididalidator.idatididalidator.idatididalidator.idatididalidator.tid NHibe rnate.Validator.Engine.ValidatorEngine.GetElementOrNew (EntityType type) in NHibernate.Validator.Engine.ValidatorEngine.InternalValidate (Object object, object [] activeTags) in NHibernate.Validator.Engine.Valator object, ActiveValid.Valator ) in NHibernate.Validator.Event.ValidateEventListener.Validate (Object object, EntityMode mode) when NHibernate.Validator.Event.ValidatePreUpdateEventListener.OnPreUpdate (PreUpdateEvent event) in NHibernate.Appdntnt NH \ NHibernate \ SRC \ NHibernate \ Action \ EntityUpdateAction.cs: line 200 in NHibernate.Action.EntityUpdateAction.Execute () in d: \ CSharp \ NH \ NH \ NHibernate \ SRC \ NHibernate \ Action \ EntityUpdateAction.cs: line 58 in NHibernate.Engine.ActionQueue.Execute (IExecutable executable) in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Engine \ ActionQueue.cs: line 136 in NHibernate.Engin e.ActionQueue.ExecuteActions (list IList) in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Engine \ ActionQueue.cs: line 126 in NHibernate.Engine.ActionQueue.ExecuteActions () in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Engine \ ActionQueue.cs: line 170 on NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions (IEventSource sessions) in d: \ CSharp \ NH \ NH \ NHibernate \ SRC \ NHibernate \ Event \ Default \ AbstractFlushingEventListener.cs: line 241 in NHibernate.Event.Default.DefaultFlushEventListener.OnFlush (FlushEvent event) in d: \ CSharp \ NH \ NH \ NHibernate \ SRC \ NHibernate \ Event \ Default \ DefaultFlushEventListener.cs: line 19 in NHibernate. Impl.SessionImpl.Flush () in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Impl \ SessionImpl.cs: line 1472 in TestDataAccess.FooTest.TestFoo () in FooTest.cs

As you can see from the stack trace, an error occurs when a session is cleared and the NHibernate Validator does its job.

Update . I tried to skip the NH Validator code, and it seems that at some point it is trying to check the proxy server of the castle of the object, and not the base object itself. This is causing problems. I donโ€™t know what to do with it ...

Update The problem disappears if I use LinFu ProxyFactoryFactory and not Castle. Unfortunately, LinFu gives me other problems , so I don't want to use it.

+6
source share
1 answer

NHibernate 3.2 eliminates the need for external proxy libraries.

They are still supported, but they are no longer distributed, and the default implementation is internal.

Have you tried to upgrade?


Update: To compile the NHibernate Validator for NH 3.2, you need to modify the NHibernateHelper as follows:

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

See NHV-116 for more details.

+1
source

Source: https://habr.com/ru/post/900907/


All Articles