Validating Model generates Exception: ServiceElementCollectionValidator does not contain the ConfigurationElementTypeAttribute.

Topics: General Discussion Forum, Service Factory Modeling Edition Forum
Jan 24, 2008 at 9:59 PM
I am using:
- Dev Studio 2005 Team Edition for Software Develpors
- Service Factory - Modeling Binary Install
- Entlib 3.1 (Binary Intsall)
- GAX/GAT July Release

I followed the Hands-on doc and re-created the all the steps with no problems. but when it comes to model validation (clicking on "Validata Model" for the Material MgmtProxy) I get the following Exception (attached see the rules.config file):

System.Configuration.ConfigurationErrorsException: The type ServiceElementCollectionValidator does not contain the ConfigurationElementTypeAttribute. (C:\Program Files\Microsoft Service Factory V3\Guidance Package\ruleset.config line 20)
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
at System.Configuration.Configuration.GetSection(String sectionName)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSourceImplementation.GetSection(String sectionName)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource.GetSection(String sectionName)
at Microsoft.Practices.EnterpriseLibrary.Validation.ConfigurationValidatorBuilder.GetTypeReference(Type type)
at Microsoft.Practices.EnterpriseLibrary.Validation.ValidationFactory.CreateValidatorFromConfiguration(Type targetType, String ruleset, IConfigurationSource configurationSource, Boolean cacheValidator)
at Microsoft.Practices.EnterpriseLibrary.Validation.ValidationFactory.CreateValidatorFromConfiguration(Type targetType, String ruleset, IConfigurationSource configurationSource)
at Microsoft.Practices.Modeling.CodeGeneration.ValidationEngine.Validate(ValidationElementState state, ValidationContext context, ModelElement currentElement, String ruleSet)
Developer
Jan 25, 2008 at 3:14 PM
Edited Jan 25, 2008 at 3:15 PM
Check that your "ServiceElementCollectionValidator" is something like this (in particular the attr).

[ConfigurationElementType(typeof(CustomValidatorData))]
public class ServiceElementCollectionValidator : UniqueNamedElementCollectionValidator<Service>
{
	public ServiceElementCollectionValidator(NameValueCollection attributes)
		: base(attributes)
	{
	}
}
Or if you derive from that class, your custom validator has that attribute.
Jan 25, 2008 at 4:01 PM
charlyfriend, Thanks bro for the suggestion.

And I will try and derive a custom validator from "Microsoft.Practices.ServiceFactory.Validation.ServiceElementCollectionValidator " using the signiture u suggested above.

The only thing is I do not know yet, is how would my drived custom validator will play with the signed (binary install) version of "Microsoft Service Factory V3" DLLs.

Thanks again.
Developer
Jan 25, 2008 at 4:13 PM
The Extensibility HoL should show how to add your own custom validator and you can simply derive from the included ones in the binary version or from the EntLib validator library as well. As I mentioned above, remember to add the ConfigurationElementTypeAttribute to your validator class.
Jan 25, 2008 at 5:09 PM
charlyfriend, Just One more question before I finish adding my custom Validator.

Do think driving my own custome validator (with ConfigurationElementTypeAttribute) is a workaround to a potential bug in the "Microsoft.Practices.ServiceFactory.Validation.ServiceElementCollectionValidator" implementation? specially since the ServiceElementCollectionValidator is used by most of the built in Model Validators in the Service Factory (Modeling Edition) package.

Thanks,
Developer
Jan 25, 2008 at 5:56 PM
The 'ServiceElementCollectionValidator' already have that attribute so you should not add any other validator unless you need some other validation scenario where you can add your own custom validator that in turns may derive from 'ServiceElementCollectionValidator'. If that's the case, then you should remember to add that attribute to your custom validator.
Mar 9, 2009 at 9:57 AM
I know more than a year has gone but did you manage to solve this, Keyse?  I have no problems on one machine but have the exact message you had on the other.  Clearly something to do with my local environment but I can't work out what!

Thanks
Developer
Mar 9, 2009 at 1:32 PM
CVF, did you check if you have in your failing env, Entlib 3.1 installed? (and not a newer version).
If so, try putting into GAC the validation Entlib assemblies, in particular "Microsoft.Practices.EnterpriseLibrary.Validation".
Mar 9, 2009 at 1:58 PM
Thanks for your quick reply.  Yes, I do have EntLib 3.1 installed.  However, I did have 4.1 installed in the past but have since uninstalled it. 

In fact, because I thought it might have something to do with this, I've uninstalled everything including VS2008 then re-installed everything (VS, Guidance Automation, EntLib 3.1, WSSF:Modeling Edition) but still the same.

Same with binary install and within source code install.  I don't understand why I see the attribute in the source but I still get the exception.  The other recipes work - it only seems to be validating the models that fail.

You think a hangover from my previous installation of EntLib 4.1 might have something to do with it?
Developer
Mar 9, 2009 at 6:32 PM
It migth be something like that. You can cross check that you don't have any 4.1 asm GACed or any folder in program files with 4.1 files in it. I will also take a look in the registry key where Entlib set VS to look for binaries like: 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\Enterprise Library v4.1
or
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\Enterprise Library v4.1

If that your case, then remove it and leave only the Key for 3.1
Mar 9, 2009 at 9:03 PM
hernandelahitte, many thanks!  Your first suggestion of putting the Ent Lib assemblies into GAC did the trick. That was starting to really do my head in so thanks again!