0

问题


这个错误才刚刚开始出现在我的项目中,我不确定为什么。我有一个生成文件的“ Silverlight 5 ”项目文件。该文件包含MatchTimeoutInMilliseconds调用,它似乎不断出错:

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

我不知道如何解决这个问题,因为它与我编写的代码无关。

代码


/// <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
{

}

以上是包含错误的代码。

有谁知道我该如何解决这个问题?

4

2 回答 2

1

如果您查看 RegularExpressionAttribute 的MatchTimeoutInMilliseconds属性,版本信息部分,您将看到:

通用 Windows 平台
自 10 起可用

.NET Framework
自 4.6.1 起可用

而且您使用的是 Silverlight 5,所以那里不支持它。您可以修复该问题,但修复您使用的模板以不生成此属性。

于 2016-05-06T07:43:09.780 回答
0

我今天遇到了同样的问题,并且无法通过安装 4.6.1 来解决它,即使 Evk 命名的 Microsoft 网站说它必须在那里。我的解决方案是安装 4.6.2!

另一件要提的事情(因为这对我们来说并不明显,我们花了一些时间来考虑 .Net 版本作为问题)是即使您在项目中将框架设置为“.Net 4.0”,它也可以工作。

于 2017-08-10T16:27:22.700 回答