views:

81

answers:

1

I don't have much experience on the web services / database abstraction layer side of things for Silverlight, and am caught on an aspect of my porting effort. There was a core C# developer on the project that is no longer involved, and I'm working with code that he wrote.

I'm updating code on a SL3 project with the RIA Services preview version to SL4 with RIA Services 1.0. I'm referencing the RIA_Services_Breaking_Changes.doc file for my code conversion effort from this URL: http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=3570

My hangup is with what I think is a potentially auto-generated file, and errors involving RIA Services EntityCollection / EntityState stuff.

HerculesModel.metadata.cs (Before beginning conversion)

namespace Everest.Domain.Hercules
{
    using System;
    using System.ComponentModel.DataAnnotations;
    using System.Web.Ria;
    using System.Web.Ria.Data;
    using System.Web.DomainServices;
    using System.Data;
    using System.Data.Objects.DataClasses;

    // The MetadataTypeAttribute identifies AuthenticationTypesMetadata as the class
    // that carries additional metadata for the AuthenticationTypes class.
    [MetadataTypeAttribute(typeof(AuthenticationTypes.AuthenticationTypesMetadata))]
    public partial class AuthenticationTypes
    {
        // This class allows you to attach custom attributes to properties
        // of the AuthenticationTypes class.
        //
        // For example, the following marks the Xyz property as a
        // required field and specifies the format for valid values:
        //  [Required]
        //  [RegularExpression("[A-Z][A-Za-z0-9]*")]
        //  [StringLength(32)]
        //  public string Xyz;
        internal sealed class AuthenticationTypesMetadata
        {
            // Metadata classes are not meant to be instantiated.
            private AuthenticationTypesMetadata()
            {
            }
            public EntityState EntityState;
            public EntityCollection<LoginAccounts> LoginAccounts;
            public int TypeId;
            public string TypeName;
        }
    }
    ...
}

I updated the using references to the new namespaces listed in the breaking changes doc above, and tested the build. Visual Studio then listed the following errors 274 times in the document:

Error 53 'EntityCollection' is an ambiguous reference between 'System.ServiceModel.DomainServices.Client.EntityCollection<Everest.Domain.Hercules.BookmarkedProfiles>' and 'System.Data.Objects.DataClasses.EntityCollection<Everest.Domain.Hercules.BookmarkedProfiles>'   C:\...\Everest.Domain.Hercules\HerculesModel.metadata.cs    872 11  Everest.Domain.Hercules
Error 189 'EntityState' is an ambiguous reference between 'System.ServiceModel.DomainServices.Client.EntityState' and 'System.Data.EntityState' C:\...\Everest.Domain.Hercules\HerculesModel.metadata.cs    3501    11  Everest.Domain.Hercules

So I updated the code, adding the qualifier to eliminate the ambiguity:

namespace Everest.Domain.Hercules
{
    using System;
    using System.ComponentModel.DataAnnotations;
    using System.ServiceModel.DomainServices.Server;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Client;
    using System.ServiceModel.DomainServices;
    using System.Data;
    using System.Data.Objects.DataClasses;  
    [MetadataTypeAttribute(typeof(AuthenticationTypes.AuthenticationTypesMetadata))]
    public partial class AuthenticationTypes
    {
        internal sealed class AuthenticationTypesMetadata
        {
            private AuthenticationTypesMetadata()
            {
            }
            public System.ServiceModel.DomainServices.Client.EntityState EntityState;
            public System.ServiceModel.DomainServices.Client.EntityCollection<LoginAccounts> LoginAccounts;
            public int TypeId;
            public string TypeName;
        }
    }
    ...
}

After attempting to build the code I receive the following general error 160 times, and I'm totally stuck on these TEntity errors:

Error 28 The type 'Everest.Domain.Hercules.Authentication.LoginAccounts' cannot be used as type parameter 'TEntity' in the generic type or method 'System.ServiceModel.DomainServices.Client.EntityCollection<TEntity>'. There is no implicit reference conversion from 'Everest.Domain.Hercules.Authentication.LoginAccounts' to 'System.ServiceModel.DomainServices.Client.Entity'.   C:\...\Everest.Domain.Hercules\Authentication\AuthenticationModel.metadata.cs   358 85  Everest.Domain.Hercules

I have Resharper installed for Visual Studio 2010, and it states that the only using directives that are used by the document are System and System.ComponentModel.DataAnnotations. As I understand *.metadata.cs files are auto-generated, but how do I regenerate the metadata file with support for this new version of RIA Services? This project utilizes an open-source MVVM framework.

Thanks a million for any help that you can provide me!!!

A: 

You should not be including S.SM.DS.Client in your using statements. The Client assembly should only be linked into Silverlight projects.

Kyle

Kyle McClellan