Enterprise Library 5.0 / Validation: "CustomAttributeFormatException" during validation since upgrade from 4.1 to 5.0 01-04-2011, 9:09 AM

Topics: Validation Application Block
Jan 13, 2011 at 11:00 AM

Hi Folks,

I'm using Enterprise Library 4.1 for validation for a long time, worked fine.

But since upgrade to Enterprise Library 5.0 I got an Exception during validation

 

Code: Validation.Validate(item);

Exception: System.Reflection.CustomAttributeFormatException : Die angegebene "MessageTemplateResourceName"-Eigenschaft konnte nicht gefunden werden. // The property "MessageTemplateResourceName" could not be found

 

Stacktrace:

System.Reflection.CustomAttributeFormatException : Die angegebene "MessageTemplateResourceName"-Eigenschaft konnte nicht gefunden werden.
  ----> System.Reflection.TargetInvocationException : Ein Aufrufziel hat einen Ausnahmefehler verursacht.
  ----> System.InvalidOperationException : A message template has been set already, resource based message templates are not allowed.

bei System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType)
bei System.Attribute.InternalGetCustomAttributes(PropertyInfo element, Type type, Boolean inherit)
bei

Microsoft.Practices.EnterpriseLibrary.Validation.MetadataValidatedElement.<Microsoft.Practices.EnterpriseLibrary.Validation.IValidatedElement.GetValidatorDescriptors>d__0.MoveNext() in e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\MetadataValidatedElement.cs: line 160.
bei

Microsoft.Practices.EnterpriseLibrary.Validation.ValidatorBuilderBase.CollectValidatorsForProperties(IEnumerable`1 validatedElements, List`1 validators, Type ownerType) in

e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidatorBuilderBase.cs: line 87.
bei

Microsoft.Practices.EnterpriseLibrary.Validation.ValidatorBuilderBase.CreateValidator(IValidatedType validatedType) in e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidatorBuilderBase.cs: line 57.
bei

Microsoft.Practices.EnterpriseLibrary.Validation.AttributeValidatorFactory.InnerCreateValidator(Type targetType, String ruleset, ValidatorFactory mainValidatorFactory) in e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\AttributeValidatorFactory.cs: line 43.
bei

System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
bei System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
bei System.Linq.Enumerable.Count(IEnumerable`1 source)
bei Microsoft.Practices.EnterpriseLibrary.Validation.CompositeValidatorFactory.GetValidator(IEnumerable`1 validators) in e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\CompositeValidatorFactory.cs: line 99.
bei

Microsoft.Practices.EnterpriseLibrary.Validation.CompositeValidatorFactory.InnerCreateValidator(Type targetType, String ruleset, ValidatorFactory mainValidatorFactory) in e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\CompositeValidatorFactory.cs: line 80.
bei

Microsoft.Practices.EnterpriseLibrary.Validation.ValidatorFactory.FindOrCreateValidator(ValidatorCacheKey cacheKey, Func`3 wrapAndInstrument) in e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidatorFactory.cs: line 107.
bei

Microsoft.Practices.EnterpriseLibrary.Validation.ValidatorFactory.CreateValidator(Type targetType, String ruleset) in

e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidatorFactory.cs: line 157.
bei

Microsoft.Practices.EnterpriseLibrary.Validation.ValidationFactory.CreateValidator(Type targetType, ValidationSpecificationSource source) in e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\ValidationFactory.cs: line 196.
bei

Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate(T target, ValidationSpecificationSource source) in e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\Validation.cs: line 61.
bei

Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate(T target) in e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\Validation.cs: line 30.
bei

de.bdo.layer.services.ServicesManager.Update(T item, IDataContext context) in ServicesManager.cs: line 29.
bei

de.bdo.layer.services.ArtikelServices.Update(Artikel artikel)

in ArtikelServices.cs: line 27.
bei

test.Services.Test_ArtikelService.test_Update() in Test_ArtikelService.cs: line 66.
--TargetInvocationException
bei

System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, ref SignatureStruct sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
bei System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
--InvalidOperationException
bei

Microsoft.Practices.EnterpriseLibrary.Validation.Validators.BaseValidationAttribute.set_MessageTemplateResourceName(String value) in

e:\Builds\EntLib\Latest\Source\Blocks\Validation\Src\Validation\Validators\BaseValidationAttribute.cs: line 125.

 

Any glue what it could be?

 

Thanks in advance, rgds

Burgerman

Jan 14, 2011 at 1:44 AM

I have no idea yet what could be the possible problem.  Do you have any custom validators?  Do you know what exactly I need to have on a simple visual studio project so I could repro this?

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com