Silverlight的MatchTimeoutInMilliseconds错误:解决DomainServiceClientCodeGenerator [英] silverlight MatchTimeoutInMilliseconds bug : resolve DomainServiceClientCodeGenerator

查看:1708
本文介绍了Silverlight的MatchTimeoutInMilliseconds错误:解决DomainServiceClientCodeGenerator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Silverlight的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写道:




这的NuGet在WebProejct安装RIAServices.T4或一个类库
将包含代码生成的类。 PM>安装封装
RIAServices.T4



创建两个班

  [DomainServiceClientCodeGenerator(typeof运算(MyServicesEntityGenerator),C#)] 
公共类MyServicesClientCodeGenerator:CSharpClientCodeGenerator
{
保护覆盖EntityGenerator EntityGenerator
{
得到
{
返回新MyServicesEntityGenerator();
}
}
}

公共类MyServicesEntityGenerator:CSharpEntityGenerator
{
保护覆盖无效GenerateAttributes(IEnumerable的<属性>属性,布尔forcePropagation )
{
名单,LT;属性> newAttributes =新的List<属性与GT;(属性);
名单,LT;属性> regularExpressionAttributes =(从C在哪里属性c.GetType()== typeof运算(RegularExpressionAttribute)选择C).ToList();

newAttributes.RemoveAll(委托(属性attr)使用
{
返回attr.GetType()== typeof运算(RegularExpressionAttribute);
});

base.GenerateAttributes(newAttributes,forcePropagation);

的foreach(在regularExpressionAttributes RegularExpressionAttribute项)
{
base.Write(的String.Format([System.ComponentModel.DataAnnotations.RegularExpressionAttribute(@ \{0} \\ \\,
的ErrorMessage = @ \{1} \)\r\\\

item.Pattern,item.ErrorMessage));
}
}
}

现在挂钩这一切在Silverlight项目文件中,我们需要告诉
RIA使用我们的发电机。我们要编辑的Silverlight项目和
只是
LinkedServerProject后添加的第一个内部的PropertyGroup以下元素(顺序不重要,我只想说,作为
参考)。

 < 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. 我已经包含在代码中的命名空间。

     使用Microsoft.ServiceModel.DomainServices.Tools;使用Microsoft.ServiceModel.DomainServices.Tools.TextTemplate.CSharpGenerators 
    ;
    使用Microsoft.ServiceModel.DomainServices.Tools.TextTemplate;




通过命名空间挖,所有我能找到是的 DomainServiceClientCodeGeneratorAttribute IDomainServiceClientCodeGenerator



谁能告诉我如何解决我的思念 DomainServiceClientCodeGenerator


解决方案

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



这种信息的关键部分来自的 http://jeffhandley.com/archive/2010/10/28/RiaServicesT4WalkUp.aspx




您会发现,我需要添加这个工作到
Microsoft.ServiceModel.DomainServices.Tools的参考。这
组件在我们的框架(而不是工具包)和它的
DomainServiceClientCodeGeneratorAttribute类中定义的位置。此外,在
为了这个编译,我需要添加到
System.ComponentModel.Composition(MEF)因为属性类
实际上是从ExportAttribute派生的。参照




...



(任何人都知道,这并没有解决MatchTimeoutInMilliseconds错误我)


Silverlight 5 .Net Framework 4

I am trying to implement a workaround for the recent bug in the RIA code generator "MatchTimeoutInMilliseconds could not be found" https://connect.microsoft.com/VisualStudio/feedback/details/1988437/generated-code-for-silverlight-references-matchtimeoutinmilliseconds-which-does-not-exist

I'm trying to use the workaround by Lazebnyy, But I can't seem to get DomainServiceClientCodeGenerator to resolve.

Lazebnyy writes:

Install RIAServices.T4 from Nuget in the WebProejct or a Class Library that will contain the the code generation classes. PM> Install-Package RIAServices.T4

Create two classes

[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));
        }
    }
}

Now to hook it all up, in the Silverlight project file we need to tell RIA to use our generator. We have to edit the Silverlight project and add the following element inside the first PropertyGroup just after LinkedServerProject (the order doesn't matter, I just say that as a reference).

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

.

No matter what I try, I can't seem to resolve DomainServiceClientCodeGenerator

[DomainServiceClientCodeGenerator(typeof(MyServicesEntityGenerator),"C#")]

  1. I got the Nuget package RIAServices.T4 Version 4.2.0,
  2. Added the references in the server side service project to Microsoft.ServiceModel.DomainServices.Tools.dll Microsoft.ServiceModel.DomainServices.Tools.TextTemplate.dll
  3. I've included the namespaces in the code

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

Digging through the namespaces, all I can find is DomainServiceClientCodeGeneratorAttribute and IDomainServiceClientCodeGenerator

Can anyone tell me how to resolve my missing DomainServiceClientCodeGenerator ?

解决方案

I finally got it working. The project needed reference to System.ComponentModel.Composition

This key piece of information came from http://jeffhandley.com/archive/2010/10/28/RiaServicesT4WalkUp.aspx

You’ll notice that I needed to add a reference to Microsoft.ServiceModel.DomainServices.Tools for this to work. That assembly is in our framework (not the Toolkit) and it’s where the DomainServiceClientCodeGeneratorAttribute class is defined. Also, in order for this to compile, I needed to add a reference to System.ComponentModel.Composition (MEF) because that attribute class actually derives from ExportAttribute.

...

(for anyone wondering, this did not solve the MatchTimeoutInMilliseconds bug for me)

这篇关于Silverlight的MatchTimeoutInMilliseconds错误:解决DomainServiceClientCodeGenerator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆