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#")]
- I got the Nuget package RIAServices.T4 Version 4.2.0,
- Added the references in the server side service project to Microsoft.ServiceModel.DomainServices.Tools.dll Microsoft.ServiceModel.DomainServices.Tools.TextTemplate.dll
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 ?