locked
expand problem with 5.0.1rc and silverlight RRS feed

  • Question

  • Using silverlight5 on the frontend and code first data service on the backend - my data objects look like this:

        public class Shelf
        {
            [Key, StringLength(20)]
            public string Name { get; set; }
            [Required, StringLength(20)]
            public string Vendor { get; set; }
            [Required, StringLength(20)]
            public string Model { get; set; }
            public int? Node { get; set; }  // only used for adtran currently
            [Required, StringLength(20)]
            public string IPAddress { get; set; }

            public ICollection<ShelfCard> ShelfCards { get; set; }
        }

        public class ShelfCard
        {
            [Key, StringLength(20), Column(Order = 0)]
            public string Name { get; set; }
            [Key, Column(Order = 1)]
            public int Slot { get; set; }
            [Required, StringLength(50)]
            public string Description { get; set; }
            [Required, StringLength(20)]
            public string Serial { get; set; }
            [Required, StringLength(20)]
            public string PartNumber { get; set; }
            [Required, StringLength(20)]
            public string SoftwareRevision { get; set; }
            [Required, StringLength(20)]
            public string HardwareRevision { get; set; }
        }

        public class OntDiscovery : IEquatable<OntDiscovery>
        {
            [Key, StringLength(20)]
            public string Serial { get; set; }
            [Required, StringLength(20)]
            public string ShelfName { get; set; }
            [Required]
            public int Slot { get; set; }
            [Required]
            public int Pon { get; set; }
            [Required]
            public int Index { get; set; }

            public virtual Shelf Shelf { get; set; }
        }

    The query on the client is:

    godc.LoadAsync(from o in ctx.OntDiscoverys.Expand("Shelf") where o.Serial.StartsWith(e.Parameter) select o);

    However, in 5.0.1rc, in the LoadCompleted event, Fiddler shows the proper data gets sent, but I get back an error that says:

    System.ArgumentException: Method 'Void set_Item(Int32, MolallaFM.OmniaCM.ShelfCard)' declared on type 'System.Collections.Generic.IDictionary`2[System.Int32,MolallaFM.OmniaCM.ShelfCard]' cannot be called with instance of type 'System.Collections.Generic.IDictionary`2[System.String,MolallaFM.OmniaCM.ShelfCard]'
       at System.Linq.Expressions.Expression.ValidateCallInstanceType(Type instanceType, MethodInfo method)
       at System.Linq.Expressions.Expression.ValidateStaticOrInstanceMethod(Expression instance, MethodInfo method)
       at System.Linq.Expressions.Expression.ValidateMethodAndGetParameters(Expression instance, MethodInfo method)
       at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, Expression arg0, Expression arg1)
       at System.Data.Services.Client.Metadata.ClientPropertyAnnotation..ctor(IEdmProperty edmProperty, PropertyInfo propertyInfo, DataServiceProtocolVersion maxProtocolVersion)
       at System.Data.Services.Client.ClientEdmModel.CreateEdmProperty(IEdmStructuredType declaringType, PropertyInfo propertyInfo)
       at System.Data.Services.Client.ClientEdmModel.<>c__DisplayClass18.<GetOrCreateEdmTypeInternal>b__11(MetadataProviderEdmEntityType entityType)
       at System.Data.Services.Client.Providers.MetadataProviderEdmEntityType.EnsurePropertyLoaded()
       at System.Data.Services.Client.Providers.MetadataProviderEdmEntityType.get_DeclaredProperties()
       at Microsoft.Data.OData.Metadata.EpmExtensionMethods.LoadEpmAnnotations(IEdmModel model, IEdmEntityType entityType)
       at Microsoft.Data.OData.Metadata.EpmExtensionMethods.HasOwnOrInheritedEpm(IEdmModel model, IEdmEntityType entityType)
       at Microsoft.Data.OData.Metadata.EpmExtensionMethods.EnsureEpmCacheInternal(IEdmModel model, IEdmEntityType entityType, Int32 maxMappingCount, Boolean& cacheModified)
       at Microsoft.Data.OData.Metadata.EpmExtensionMethods.EnsureEpmCache(IEdmModel model, IEdmEntityType entityType, Int32 maxMappingCount)
       at Microsoft.Data.OData.Atom.ODataAtomReader.ReadEntryStart()
       at Microsoft.Data.OData.Atom.ODataAtomReader.ReadAtNavigationLinkStartImplementation()
       at Microsoft.Data.OData.ODataReaderCore.ReadImplementation()
       at Microsoft.Data.OData.ODataReaderCore.ReadSynchronously()
       at Microsoft.Data.OData.ODataReaderCore.InterceptException[T](Func`1 action)
       at Microsoft.Data.OData.ODataReaderCore.Read()
       at System.Data.Services.Client.Materialization.ODataReaderEntityMaterializer.ODataFeedOrEntryReader.TryRead()
       at System.Data.Services.Client.Materialization.ODataReaderEntityMaterializer.ODataFeedOrEntryReader.TryStartReadFeedOrEntry()
       at System.Data.Services.Client.Materialization.ODataReaderEntityMaterializer.ODataFeedOrEntryReader.TryReadFeedOrEntry(Boolean lazy, ODataFeed& feed, MaterializerEntry& entry)
       at System.Data.Services.Client.Materialization.ODataReaderEntityMaterializer.ODataFeedOrEntryReader.ReadNavigationLink()
       at System.Data.Services.Client.Materialization.ODataReaderEntityMaterializer.ODataFeedOrEntryReader.ReadEntryCore()
       at System.Data.Services.Client.Materialization.ODataReaderEntityMaterializer.ODataFeedOrEntryReader.TryReadEntry(MaterializerEntry& entry)
       at System.Data.Services.Client.Materialization.ODataReaderEntityMaterializer.ODataFeedOrEntryReader.<LazyReadEntries>d__0.MoveNext()
       at System.Data.Services.Client.Materialization.ODataReaderEntityMaterializer.ODataFeedOrEntryReader.Read()
       at System.Data.Services.Client.Materialization.ODataReaderEntityMaterializer.ReadNextFeedOrEntry()
       at System.Data.Services.Client.Materialization.ODataEntityMaterializer.ReadImplementation()
       at System.Data.Services.Client.Materialization.ODataMaterializer.Read()
       at System.Data.Services.Client.MaterializeAtom.MoveNextInternal()
       at System.Data.Services.Client.MaterializeAtom.MoveNext()
       at System.Linq.Enumerable.<CastIterator>d__b1`1.MoveNext()
       at System.Data.Services.Client.DataServiceCollection`1.InternalLoadCollection(IEnumerable`1 items)
       at System.Data.Services.Client.DataServiceCollection`1.Load(IEnumerable`1 items)
       at System.Data.Services.Client.DataServiceCollection`1.<>c__DisplayClass2.<LoadAsync>b__1(IAsyncResult asyncResult)
       at System.Data.Services.Client.DataServiceCollection`1.EndLoadAsyncOperation(Func`2 endCall, IAsyncResult asyncResult)} System.Exception {System.ArgumentException}

    This same code worked fine prior to upgrading and works fine in EF queries on the server side.

    Also, one final comment- you guys seriously need to rethink the whole "Add Service Reference" and "Update Service Reference" gestures in VS with respect to future proofing, especially if you are going to do frequent updates and use NuGet as the preferred way to get the client libraries (both of which I like BTW).  I grabbed 5.0.1rc via NuGet only to find that I had to go back and grab 5.0.0 installer to get "Update Service Reference" to work (before I did this I was getting a COM E_FAIL error) - and I still have to manually go in and remove the reference to System.Data.Services.Client that gets added after every time I add do an update.  I can deal with this because it has been that way for a while, but I fear it isn't very user friendly for people new to WCF Data Services who expect it just to more or less work properly from VS.

    Friday, May 11, 2012 6:49 PM

All replies

  • Hi BullCreek,

    Welcome to MSDN Forum.

    We will do some more pending research  about your problem and come back as soon as possible, Thanks for understanding.

    Have a nice day.


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, May 14, 2012 2:10 AM
    Moderator
  • Hi Allen,

    I went to create a test solution that I could attach to this post so someone there could easily recreate and debug this problem, and alas now I am getting a different problem when I try to add the Test.svc WCF service endpoint to my new web project:

    Error: this template attempted to load component assembly 'Microsoft.VisualStudio.Data.ServicesWizard, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03rf5f7f11d50a3a'.

    Prior to install 5.0, I uninstalled all previous versions of WCF Data Service and EF CTP.  Oddly, the client side gestures for (Add Service Reference and Update Service Reference) work - but creating a new service using the WCF Data Service (for OData V3) template no longer works after upgrading to 5.0.  Hopefully someone there has a workaround so I can give you an example of how to reproduce the first problem.

    Thanks, BC

    Tuesday, May 15, 2012 5:19 PM
  • Hi,

    Have you made any progress on your issue? 

    Perhaps you should try posting the issue to http://connect.microsoft.com if you believe there is a bug involved. Otherwise, I suggest you have a support case created for a more in-depth level of support.  Please visit the below link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Thanks,

    Cathy Miller

    Friday, May 25, 2012 2:27 PM
    Moderator