ValidationElement Does Not Implement IServiceBehavior

Topics: Validation Application Block
Jan 23, 2008 at 6:44 PM
I'm trying to configure validation for a WCF service. I am using EL3.1, VS2008, .Net3.5 as my target framework.

I'm receiving the following error when I try to hit my service.


Parser Error Message: Cannot add the behavior extension 'validation' to the service behavior named 'MyServiceBehavior' because the underlying behavior type does not implement the IServiceBehavior interface.

Source Error:


Line 237: <serviceBehaviors>
Line 238: <behavior name="MyServiceBehavior">
Line 239: <validation enabled="true" ruleset="" />
Line 240: <serviceDebug includeExceptionDetailInFaults="false" />
Line 241: <serviceMetadata httpGetEnabled="true" />


The relevant sections of my config file are:


<system.serviceModel>
...
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<validation enabled="true" ruleset="" />
...
</behavior>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="validation"
type="Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.ValidationElement, Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</behaviorExtensions>
</extensions>
</system.serviceModel>


Any help would be greatly appreciated.

Regards,
Josh
Jan 24, 2008 at 2:05 PM
Ok, upon further review, it looks like the actual issue is that ValidationBehavior does not implement IServiceBehavior.

Is this something that changed with .Net 3.5? Will this be addressed in the upcoming EL 4.0 release?

Thanks,
Josh
Jan 24, 2008 at 2:20 PM
Hi Josh,

Let me find out and I'll get back to you.

Fernando
Jan 24, 2008 at 5:12 PM


joshhawthorne wrote:
I'm trying to configure validation for a WCF service. I am using EL3.1, VS2008, .Net3.5 as my target framework.

I'm receiving the following error when I try to hit my service.


Parser Error Message: Cannot add the behavior extension 'validation' to the service behavior named 'MyServiceBehavior' because the underlying behavior type does not implement the IServiceBehavior interface.
[...SNIP...]


The ValidationBehavior is a contract and endpoint behavior, not a service behavior. Have you tried adding it to your endpoint instead of directly to the service?
Jan 24, 2008 at 9:14 PM

ctavares wrote:

The ValidationBehavior is a contract and endpoint behavior, not a service behavior. Have you tried adding it to your endpoint instead of directly to the service?



This was my problem. I added it as suggested and I am validating as expected.

Thank you all so much!
Josh
Jun 15, 2011 at 11:37 AM

think the documentation needs changing, i fell into the same trap, this is from the EL5 documentation:

Defining a Behavior

After you include the application block, you can define a behavior that uses it. You can use either a service behavior or an endpoint behavior. The following code example defines an endpoint behavior.