none
Error on base class but not inherited in request RRS feed

  • Question

  • Have these classes:

        [DataContract]
        public class BaseRequest
    
        {
    ...
    
            
        [DataContract]
        public class PagedDataRequest : BaseRequest
    
        {
      [DataMember]
            public int PageSize { get; set; }
    
            [DataMember]
            public int PageNumber { get; set; }
    
        
    
    
        [DataContract]
        public class CustomListRequest : PagedDataRequest
        {
            [DataMember] 
            public int[] StatusFilter { get; set; }


    when calling operations with "CustomListRequest" all is well...

    When calling operations that use "PagedDataRequest" I get this:

    Exception: Type 'Contracts.Messages.PagedDataRequest' with data contract name 'PagedDataRequest:http://schemas.datacontract.org/2004/07/Contracts.Messages' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

    What gives?

    aside from the "int[]" they are just "booring base types in these objects" and if anything I would have though if the most derived type works then I can't see why the other wouldn't...?!?


    - sure I'm noJedi but that's no reason to stop trying to make stuff levitate! -

    Thursday, June 11, 2015 4:32 PM

Answers

  • ah... never mind...

    Issue was this the operations calling the "paged" request were actually SUPPOSED to be "BaseRequest" (in the operation contract)... the clue was "was not expected".

    so because of the inheritance and that PagedDataRequest IS actually a BaseRequest, there was no compiler warning or intelli-sense that this was wrong... but obviously the Serializer didn't like it...


    - sure I'm noJedi but that's no reason to stop trying to make stuff levitate! -

    • Marked as answer by noJedi Thursday, June 11, 2015 4:45 PM
    Thursday, June 11, 2015 4:45 PM

All replies

  • ah... never mind...

    Issue was this the operations calling the "paged" request were actually SUPPOSED to be "BaseRequest" (in the operation contract)... the clue was "was not expected".

    so because of the inheritance and that PagedDataRequest IS actually a BaseRequest, there was no compiler warning or intelli-sense that this was wrong... but obviously the Serializer didn't like it...


    - sure I'm noJedi but that's no reason to stop trying to make stuff levitate! -

    • Marked as answer by noJedi Thursday, June 11, 2015 4:45 PM
    Thursday, June 11, 2015 4:45 PM
  • Hi noJedi,

    Well Done!
    Thank you very much for sharing the solution to us.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 12, 2015 6:06 AM
    Moderator