C# silverlight MatchTimeOutlineBug:解析DomainServiceClientCodeGenerator

C# silverlight MatchTimeOutlineBug:解析DomainServiceClientCodeGenerator,c#,.net,silverlight,ria,C#,.net,Silverlight,Ria,银光5号 .Net框架4 我正试图为RIA代码生成器中最近的bug实现一种变通方法 “找不到MatchTimeoutInMilleds” 我试图使用Lazebnyy的解决方法,但似乎无法解决DomainServiceClientCodeGenerator的问题 Lazebny写道: 在WebProejct或类库中从Nuget安装RIAServices.T4 它将包含代码生成类。PM>安装软件包 表4.T4 创建两个类 [DomainServiceClientCodeGenerator(type

银光5号 .Net框架4

我正试图为RIA代码生成器中最近的bug实现一种变通方法 “找不到MatchTimeoutInMilleds”

我试图使用Lazebnyy的解决方法,但似乎无法解决DomainServiceClientCodeGenerator的问题

Lazebny写道:

在WebProejct或类库中从Nuget安装RIAServices.T4 它将包含代码生成类。PM>安装软件包 表4.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));
        }
    }
}
  • 我得到了Nuget软件包RIAServices.T4版本4.2.0
  • 将服务器端服务项目中的引用添加到 Microsoft.ServiceModel.DomainServices.Tools.dllMicrosoft.ServiceModel.DomainServices.Tools.TextTemplate.dll
  • 我已经在代码中包含了名称空间

    using Microsoft.ServiceModel.DomainServices.Tools;
    using Microsoft.ServiceModel.DomainServices.Tools.TextTemplate.CSharpGenerators;
    using Microsoft.ServiceModel.DomainServices.Tools.TextTemplate;
    
  • 翻阅名称空间,我只能找到DomainServiceClientCodeGeneratorAttributeIDomainServiceClientCodeGenerator


    有人能告诉我如何解决我丢失的域服务客户端代码生成器吗?

    我终于让它工作了。这个项目需要参考 系统.组件模型.组件

    这条关键信息来自

    您会注意到,我需要添加对的引用 Microsoft.ServiceModel.DomainServices.Tools使其正常工作。那个 汇编在我们的框架(而不是工具箱)中,它是 定义了DomainServiceClientCodeGeneratorAttribute类。还有,在 为了进行编译,我需要添加对 System.ComponentModel.Composition(MEF),因为该属性类 实际上派生自ExportAttribute


    (对于任何想知道的人来说,这并没有为我解决MatchTimeOuting bug)为了修复此错误,我花了大约4个小时来开始工作Silverlight 5+Ria Services SP1项目,该项目是在Visual Studio 2012+Windiws 7+.NET Framework 4Visual Studio 2015+Windows 10中创建的

    起初,我根本无法在Visual Studio 2015中运行它

    因此,我安装了Visual Studio 2013(完整类型安装)+Service Pack 5,错误更少

    在这之后,我安装了所有旧的Silverlight东西,比如WPF Toolkit,然后我打开了解决方案,唯一的错误是

    silverlight MatchTimeOutline错误:解决 DomainServiceClientCodeGenerator

    因此,在不额外更改我安装的项目属性的情况下,.Net Framework 4.6.2预览版

    这个错误消失了

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

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

    [DomainServiceClientCodeGenerator(typeof(MyServicesEntityGenerator),"C#")]
    
    using Microsoft.ServiceModel.DomainServices.Tools;
    using Microsoft.ServiceModel.DomainServices.Tools.TextTemplate.CSharpGenerators;
    using Microsoft.ServiceModel.DomainServices.Tools.TextTemplate;