Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

silverlight MatchTimeoutInMilliseconds bug : resolve DomainServiceClientCodeGenerator

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 ?

like image 411
Shaboboo Avatar asked Jan 07 '16 18:01

Shaboboo


2 Answers

I spent about 4 hours in order to get working Silverlight 5 + Ria Services SP1 project created in Visual Studio 2012 + Windiws 7 + .NET Framework 4 in Visual Studio 2015 + Windows 10 in order to fix this error.

Initially I could not get it working in Visual Studio 2015 at all.

So I installed Visual Studio 2013 (Complete Type Installation) + Service Pack 5 and I get less errores.

After this I installed all old Silverlight stuff like WPF Toolkit and after this I just opened solution and unique error was about

silverlight MatchTimeoutInMilliseconds bug : resolve DomainServiceClientCodeGenerator

So without extra changes of the project properties I installed .Net Framework 4.6.2 Preview

AND THIS ERROR GONE!!!

I compiled fine this solution and after this I was able to compile it under Visual Studio 2015.

I hope the time I spent will help to someone.

like image 153
Friend Avatar answered Sep 19 '22 03:09

Friend


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)

like image 28
Shaboboo Avatar answered Sep 21 '22 03:09

Shaboboo