Validation Application Block Windows Service Issue

Topics: Validation Application Block
Jan 12, 2010 at 3:10 PM


I am having trouble trying to get my validation call to work with my service as it is described in the examples provided online. But, before we get started I need to let you know I am VERY new to the VAB and services, so I apologize if I sound a bit lost or just plain dumb.

So I created a windows services, which is working just fine. I created a dummy form which calls into my windows service; which I eventually want to house my validation, without any issues. I then add everything I have read online that you will need for validation work in a windows service; Microsoft.Practices.EnterpriseLibrary.Validation, Microsoft.Practices.EnterpriseLibrary.Common, Microsoft.Practices.EnterpriseLibrary.Validation.Intergration.WCF.

I then make a call into my service as I have done before with other test I've run to a method call DoValidation; which is visible to client. Everything seems to run smoothly with out any problems; no errors are thrown. I get a ValidationResult back which is great, but I noticed that everytime that I get a ValidationResult back the result is always true; meaning that the value is valid, which can not be be right everytime since I am intentionally entering invalid data to my range validator contained in my config file. The range validator in config is pretty straightforward in its function, it merely checks to make sure the value entered for a field on my dummy form falls between 0 - 32250. I have been putting values in that far exceed that range and continue to get the same result. I thought to myself well, let me back up and try this same functionality again but not in a service and it works as I expected, the ValidationResults return from the Validate method show that the value entered is not valid.

I guess my question is then, is there something special I need to do to have validation work properly when its inside a windows service? The only other thing that I can think of is that config containing my range validator is never being used, but do know why. Is it because the windows service is only looking in its App.config file and not in the Validation.App.config file where the range validator is defined? Is there a way to make the service look at the Validation.App.config file I created for its validation needs?

Please help if you can, thanks! Again, I am sorry if I sound utterly confusing, please remember I am still learning about both the VAB and services at this time, so I am still newbie.


Jan 13, 2010 at 12:50 AM

Your guess is right, the windows service will look for the validation rules you defined in its app.config file.  You need a way to point it to look for the validation rules you defined in  I saw your other post regarding this and I'll just post the answer there.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.