【问题标题】:silverlight MatchTimeoutInMilliseconds bug : resolve DomainServiceClientCodeGeneratorsilverlight MatchTimeoutInMilliseconds 错误:解决 DomainServiceClientCodeGenerator
【发布时间】:2016-01-07 18:36:48
【问题描述】:

银光 5 .Net 框架 4

我正在尝试针对 RIA 代码生成器中最近出现的错误实施解决方法 “找不到 MatchTimeoutInMilliseconds” https://connect.microsoft.com/VisualStudio/feedback/details/1988437/generated-code-for-silverlight-references-matchtimeoutinmilliseconds-which-does-not-exist

我正在尝试使用 Lazebnyy 的解决方法,但我似乎无法让 DomainServiceClientCodeGenerator 解决。

Lazebnyy 写道:

从 WebProejct 或类库中的 Nuget 安装 RIAServices.T4 这将包含代码生成类。 PM> 安装包 RIAServices.T4

创建两个类

[DomainServiceClientCodeGenerator(typeof(MyServicesEntityGenerator),"C#")]
public class MyServicesClientCodeGenerator : CSharpClientCodeGenerator
{
    protected override EntityGenerator EntityGenerator
    {
        get
        {
            return new MyServicesEntityGenerator();
        }
    }
}

public class MyServicesEntityGenerator : CSharpEntityGenerator
{
    protected override void GenerateAttributes(IEnumerable<Attribute>attributes, bool forcePropagation)
    {
        List<Attribute> newAttributes = new List<Attribute>(attributes);
        List<Attribute> regularExpressionAttributes = (from c in attributes where c.GetType() == typeof(RegularExpressionAttribute) select c).ToList();

        newAttributes.RemoveAll(delegate(Attribute attr)
                {
                    return attr.GetType() == typeof(RegularExpressionAttribute);
                });

        base.GenerateAttributes(newAttributes, forcePropagation);

        foreach (RegularExpressionAttribute item in regularExpressionAttributes)
        {
            base.Write(string.Format("[System.ComponentModel.DataAnnotations.RegularExpressionAttribute(@\"{0}\",
            ErrorMessage=@\"{1}\")]\r\n",
            item.Pattern, item.ErrorMessage));
        }
    }
}

现在把它全部连接起来,在 Silverlight 项目文件中我们需要告诉 RIA 使用我们的生成器。我们必须编辑 Silverlight 项目并 在紧随其后的第一个 PropertyGroup 中添加以下元素 LinkedServerProject(顺序无所谓,我只是说作为一个 参考)。

<LinkedServerProject>..\RIAServicesLibrary.Web\RIAServicesLibrary.Web.csproj</LinkedServerProject>
<RiaClientCodeGeneratorName>RIAServicesLibrary.Web.Helpers.MyServicesEntityGenerator</RiaClientCodeGeneratorName>

.

无论我尝试什么,我似乎都无法解决 DomainServiceClientCodeGenerator

[DomainServiceClientCodeGenerator(typeof(MyServicesEntityGenerator),"C#")]
  1. 我得到了 Nuget 包 RIAServices.T4 版本 4.2.0,
  2. 将服务器端服务项目中的引用添加到 Microsoft.ServiceModel.DomainServices.Tools.dll Microsoft.ServiceModel.DomainServices.Tools.TextTemplate.dll
  3. 我已经在代码中包含了命名空间

    using Microsoft.ServiceModel.DomainServices.Tools;
    using Microsoft.ServiceModel.DomainServices.Tools.TextTemplate.CSharpGenerators;
    using Microsoft.ServiceModel.DomainServices.Tools.TextTemplate;
    

挖掘命名空间,我只能找到 DomainServiceClientCodeGeneratorAttribute 和 IDomainServiceClientCodeGenerator

谁能告诉我如何解决我丢失的DomainServiceClientCodeGenerator?

【问题讨论】:

    标签: c# .net silverlight ria


    【解决方案1】:

    我花了大约 4 个小时来开始在 Visual Studio 2012 + Windiws 7 + .NET Framework 4 中创建的 Silverlight 5 + Ria Services SP1 项目>Visual Studio 2015 + Windows 10 以修复此错误。

    最初我无法让它在 Visual Studio 2015 中运行。

    所以我安装了 Visual Studio 2013 (Complete Type Installation) + Service Pack 5,我得到的错误更少。

    在此之后,我安装了所有旧的 Silverlight 东西,例如 WPF Toolkit,之后我刚刚打开了解决方案,唯一的错误是关于

    silverlight MatchTimeoutInMilliseconds 错误:解决 DomainServiceClientCodeGenerator

    所以没有额外更改我安装的项目属性 .Net Framework 4.6.2 Preview

    这个错误消失了!!!

    我很好地编译了这个解决方案,之后我能够在 Visual Studio 2015 下编译它。

    我希望我所花费的时间对某人有所帮助。

    【讨论】:

      【解决方案2】:

      我终于让它工作了。该项目需要参考 System.ComponentModel.Composition

      这条关键信息来自http://jeffhandley.com/archive/2010/10/28/RiaServicesT4WalkUp.aspx

      您会注意到我需要添加对 Microsoft.ServiceModel.DomainServices.Tools 使其工作。那 程序集在我们的框架(不是工具包)中,它是 定义了 DomainServiceClientCodeGeneratorAttribute 类。此外,在 为了编译这个,我需要添加一个引用 System.ComponentModel.Composition (MEF) 因为该属性类 实际上派生自 ExportAttribute。

      ...

      (对于任何想知道的人,这并没有解决我的 MatchTimeoutInMilliseconds 错误)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多