silverlight MatchTimeoutInMilliseconds bug:解析DomainServiceClientCodeGenerator

Sha*_*boo 5 .net c# silverlight ria

Silverlight 5 .Net Framework 4

我正在尝试为RIA代码生成器中最近的错误实现一种解决方法 "无法找到MatchTimeoutInMilliseconds" https://connect.microsoft.com/VisualStudio/feedback/details/1988437/generated-code-for-silverlight-references -matchtimeoutinmilliseconds -这-不-不存在

我正在尝试使用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));
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

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

<LinkedServerProject>..\RIAServicesLibrary.Web\RIAServicesLibrary.Web.csproj</LinkedServerProject>
<RiaClientCodeGeneratorName>RIAServicesLibrary.Web.Helpers.MyServicesEntityGenerator</RiaClientCodeGeneratorName>
Run Code Online (Sandbox Code Playgroud)

.

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

[DomainServiceClientCodeGenerator(typeof(MyServicesEntityGenerator),"C#")]
Run Code Online (Sandbox Code Playgroud)
  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;
    
    Run Code Online (Sandbox Code Playgroud)

挖掘名称空间,我能找到的是DomainServiceClientCodeGeneratorAttributeIDomainServiceClientCodeGenerator

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

Dev*_*per 5

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

最初我根本无法在Visual Studio 2015中使用它.

所以我安装了Visual Studio 2013(完整类型安装)+ Service Pack 5,我得到的错误更少.

在此之后,我安装了所有旧的Silverlight之类的东西,比如WPF Toolkit,之后我就打开了解决方案并且出现了独特的错误

silverlight MatchTimeoutInMilliseconds bug:解析DomainServiceClientCodeGenerator

因此,如果没有对项目属性进行额外更改,我安装了.Net Framework 4.6.2 Preview

而这个错误已经消失!

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

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


Sha*_*boo 1

我终于让它工作了。该项目需要引用\n System.ComponentModel.Composition

\n\n

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

\n\n
\n

您\xe2\x80\x99 会注意到我需要添加对\n Microsoft.ServiceModel.DomainServices.Tools 的引用才能使其正常工作。该程序集位于我们的框架(而不是 Toolkit)中,并且定义了 DomainServiceClientCodeGeneratorAttribute 类。另外,为了进行编译,我需要添加对 System.ComponentModel.Composition (MEF) 的引用,因为该属性类实际上派生自 ExportAttribute。

\n
\n\n

...

\n\n

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

\n