0

Issue


This error has only just started appearing in my project and I am unsure on why. I have a 'Silverlight 5' Project file which generates a file. This file contains MatchTimeoutInMilliseconds call which seems to keep erroring:

 'System.ComponentModel.DataAnnotations.RegularExpressionAttribute' does not contain a definition for 'MatchTimeoutInMilliseconds'

I do not have a clue of how i can resolve this issue as it is nothing to do with the code that i have written.

Code


/// <summary>
/// Gets or sets the 'uEmail' value.
/// </summary>
[DataMember()]
[DataType(DataType.EmailAddress)]
[Display(Name="Email address")]
[RegularExpression("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\." +
        ")+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$", ErrorMessage="Please enter a valid e-mail adress", MatchTimeoutInMilliseconds=-1)]
[Required()]
[StringLength(256)]
public string uEmail
{

}

Above is the code that contains the error.

Does anyone know how i can fix this issue?

Ben Clarke
  • 1,051
  • 4
  • 21
  • 47
  • 1
    The [MatchTimeoutInMilliseconds](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.regularexpressionattribute.matchtimeoutinmilliseconds%28v=vs.110%29.aspx) property is only available from .NET 4.6.1 onwards. It appears you're using an older version of the framework. – Frédéric Hamidi May 06 '16 at 07:42

2 Answers2

1

If you look at MatchTimeoutInMilliseconds property of RegularExpressionAttribute, Version information section, you will see:

Universal Windows Platform
Available since 10

.NET Framework
Available since 4.6.1

And you use Silverlight 5 as you said, so it's not supported there. You can fix that but fixing the template you use to not generate this property.

Evk
  • 98,527
  • 8
  • 141
  • 191
0

I had the same problem today and could not solve it by installing 4.6.1 even the Microsoft site named by Evk says it has to be in there. The SOLUTION to me was to install 4.6.2!

Another thing to mention (as it was not obvious to us and took us some time to consider the .Net Version as the problem) is that this works even if you have set the framework to ".Net 4.0" in your project.

Mike
  • 36
  • 3