Enterprise Library Validation Block with the SQLConfigurationSource under an ASP.Net web site

Topics: Validation Application Block
Jun 8, 2009 at 5:13 PM

I have googled, binged,  and even purchased the Definitive Guide To The Microsoft Enterprise Library.   Does anyone have any experience using the Enterprise Library Validation Block with the SQLConfigurationSource under an ASP.Net web site and/or with a web service?      I can use the Enterprise Library Configuration Console and it adds the required entries to my web.config.  But after that point I am at a loss with regards to getting rules into the database  an then running validations that utilize these rules.    I have found very little documentation covering this scenario looking for leads. 

Thanks,

Dylan

Jun 9, 2009 at 2:34 AM

If you're setting the SqlConfigurationSource as your default configuration source, everytime you make changes to your web.config, it gets saved in the database.  So if you add the Validation Application block section using the EntLib Configuration Console, add your validation rules to it, then it also gets saved in your database.  There's no code changes needed.  Your application automatically uses the validation rules defined in  your database.  If you're not using the SqlConfigurationSource as your default configuration source but want your validation rules defined in your database to apply, you can have something like this:

Validator validator = ValidationFactory.CreateValidator(typeof(Employee), "Rule Set", configSource);

where configSource is an instance of SqlConfigurationSource.

Let me know if this is not clear for you.

 

Sarah Urmeneta
Global Technology & Solutions
Avande, Inc.
entlib.support@avanade.com

 

Jun 9, 2009 at 4:30 AM
Sarah,
 
Thanks for the response.  What has me confused is that while I added a rule set as instructed in "The Guide"  , basically right clicked on my web.config and did an open with EntLib Configuration Console,  these configuration entries as well as the SQLConfigurationSource section made it into my web config but nothing was written to the database.  
 
I did not receive any errors.
 
Thanks again,
 
Dylan
 
Jun 9, 2009 at 4:34 AM

Make sure that in the ConfigurationSource node, the default configurationsource is the SQLConfigurationSource.

 

Sarah Urmeneta
Global Technology & Solutions
Avande, Inc.
entlib.support@avanade.com

Jun 9, 2009 at 10:04 PM
Yikes! 
 
I made this change and then received this:
 
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies
 
I have backed everything out, uninstalled, re-installed,  Now iIf I open the Enterprise Library Configuration console right click on Application Configuration and select Add New I get this:
 
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null'
   at System.ModuleHandle.ResolveType(Int32 typeToken, RuntimeTypeHandle* typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, Int32 methodInstCount)
   at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, RuntimeMethodHandle& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Assembly assembly, RuntimeType caType)
   at System.Reflection.Assembly.GetCustomAttributes(Type attributeType, Boolean inherit)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationDesignManagerDomain.Load(Assembly assembly)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationDesignManagerDomain.LoadFrom(String path)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationDesignManagerDomain.Load()
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationUIHierarchy.Load()
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.AddConfigurationApplicationNodeCommand.ExecuteCore(ConfigurationNode node)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationNodeCommand.Execute(ConfigurationNode node)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Console.MainForm.CreateNewApplication()
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Console.MainForm.OnNewAppMenuItemClick(Object sender, EventArgs e)
   at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.MenuItem.MenuItemData.Execute()
   at System.Windows.Forms.Command.Invoke()
   at System.Windows.Forms.Command.DispatchID(Int32 id)
   at System.Windows.Forms.Control.WmCommand(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.TreeView.WndProc(Message& m)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.UI.CustomTreeView.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].


On Mon, Jun 8, 2009 at 9:35 PM, AvanadeSupport <notifications@codeplex.com> wrote:

From: AvanadeSupport

Make sure that in the ConfigurationSource node, the default configurationsource is the SQLConfigurationSource.

 

Sarah Urmeneta
Global Technology & Solutions
Avande, Inc.
entlib.support@avanade.com

Read the full discussion online.

To add a post to this discussion, reply to this email (entlib@discussions.codeplex.com)

To start a new discussion for this project, email entlib@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jun 10, 2009 at 6:23 AM

Hi,

Did you just build the SqLconfigurationSource Source Code and copy the assemblies to your Ent Lib installation directory? Doing that so will result to the error that you've said. One way I found to get around through this is to update the references of the SqlConfiguration.Design and SQLConfigurationSource projects to the assemblies in your installation folder. That means instead of having the project reference, you would have now the assembly reference.

In the SqlConfiguration.Design project:

  • Common -> Microsoft.Practices.EnterpriseLibrary.Common.dll
  • Configuration.Design -> Microsoft.Practices.EnterpriseLibrary.Configuration.Design.dll

In the SQLConfigurationSource project:

  • Common -> Microsoft.Practices.EnterpriseLibrary.Common.dll
  • Data ->Microsoft.Practices.EnterpriseLibrary.Data.dll

Build and copy both assemblies in your ent lib installation folder and try again.

Valiant Dudan
Global Technology & Solutions
Avande, Inc.
entlib.support@avanade.com