银光5
.Net框架4
我正在尝试针对 RIA 代码生成器中最近的错误实施解决方法“找不到匹配超时毫秒”
https://connect.microsoft.com/VisualStudio/feedback/details/1988437/ generated-code-for-silverlight-references-matchtimeoutinmilliseconds-which-does-not-exist https://connect.microsoft.com/VisualStudio/feedback/details/1988437/generated-code-for-silverlight-references-matchtimeoutinmilliseconds-which-does-not-exist
我正在尝试使用解决方法Lazebnyy,但我似乎无法得到域服务客户端代码生成器解决。
拉泽布尼写道:
从 WebProejct 或类库中的 Nuget 安装 RIAServices.T4
它将包含代码生成类。 PM> 安装包
RIA服务.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(typeof(MyServicesEntityGenerator),"C#")]
- 我得到了 Nuget 包 RIAServices.T4 版本 4.2.0,
- 添加了服务器端服务项目中的引用Microsoft.ServiceModel.DomainServices.Tools.dll Microsoft.ServiceModel.DomainServices.Tools.TextTemplate.dll
-
我已经在代码中包含了命名空间
using Microsoft.ServiceModel.DomainServices.Tools;
using Microsoft.ServiceModel.DomainServices.Tools.TextTemplate.CSharpGenerators;
using Microsoft.ServiceModel.DomainServices.Tools.TextTemplate;
挖掘命名空间,我能找到的只是域服务客户端代码生成器属性 and IDomainServiceClientCodeGenerator
谁能告诉我如何解决我的失踪问题域服务客户端代码生成器 ?