none
WCF Service goes crazy RRS feed

  • Question

  • Hello!

    I'm working with Silverlight only for a few months and now tried to set up a new project with Silverlight 5.

    99% of the program ist working as expected, but my silverlight-enabled WCF Service has some really strange behaviour:

    1) When I define a List<object> as parameter or return type, it is an ObservableCollection (or Array) at the other end (in my reference.cs of the client part). Here is my service contract:

    namespace Auswertungen.Web.services
    {
        [ServiceBehavior(Namespace = "http://LIMS_R.service")]
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    
        public class Service1 : IService1
        {
    ...
        }
    
    
        [DataContract]
        public class resultTable
        {
            [DataMember]
            public List<List<object>> myResults;
    ...
        }
    }
    


    namespace Auswertungen.Web.services
    {
        [ServiceContract(Namespace = "http://Service1.service")]
        public interface IService1
        {
        ...
            [OperationContract]
            resultTable getTable(customType struc, Dictionary<string, string> myCriterias);
        }
    }

    Now I add a service reference to the client part of the silverlight project and reference.cs contains this:

     public partial class resultTable : object, System.ComponentModel.INotifyPropertyChanged {
            
           ...
            private System.Collections.ObjectModel.ObservableCollection<System.Collections.ObjectModel.ObservableCollection<object>> myResultsField;
    }        

    Why isn't it the same type?

    Some parameters even changed after some compilations without changing the interface! It was working with ObservableCollection<string> and in the next moment the service wanted a string[], but it was still List<string> in the interface!

    2) When I execute it, the automatically created procedure "public Auswertungen.MyWCFService.resultTable EndgetTable(System.IAsyncResult result)" in reference.cs gives an CommunicationException (NotFound), although the procedure in my WCF Service finishes without exceptions.

    I found out that it's because of the field in Point 1. If I fill the object-Fields ONLY with strings everything is fine and my program runs. But if I store numbers and DateTimes, the program will give this exception.

    Has anybody a suggestion what could be the reason for this behaviour of my program? Is it some missing or wrong reference? A wrong configured web.config?

    I hope my english was good enough so you can understand my problem. If not, feel free to ask.

    Thanks!

    • Moved by Weiwei Cai Monday, September 12, 2016 7:57 AM more related to WCF
    Friday, September 9, 2016 2:35 PM

Answers

  • Hi Quidnunc,

    >>Why isn't it the same type?

    This is depends on how you added the service reference. By default, if you add service reference with default settings, the collection type would be ObservableCollection. To get the list type, you could Right Click Service Reference-> Configure Service Reference-> Data Type-> Collection Type-> Select System.Collections.Generic.List.

    >>If I fill the object-Fields ONLY with strings everything is fine and my program runs. But if I store numbers and DateTimes, the program will give this exception.

    For this issue, if it still exists after you change the Collection Type, I would suggest you post a new thread, and then share us how you implement getTable method, and how you call service from client.

    Best Regards,

    Edward


    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.


    • Proposed as answer by Tony---- Tuesday, September 13, 2016 11:03 AM
    • Marked as answer by Quidnunc1987 Tuesday, September 13, 2016 1:05 PM
    Tuesday, September 13, 2016 2:34 AM

All replies

  • Hi Quidnunc1987,

    According to your description, your issue is more related to WCF Service. I help you move this thread to WCF forum to get a better help. Thanks for your understanding.

    Best Regards,
    Weiwei


    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.

    Monday, September 12, 2016 7:56 AM
  • Hi Quidnunc,

    >>Why isn't it the same type?

    This is depends on how you added the service reference. By default, if you add service reference with default settings, the collection type would be ObservableCollection. To get the list type, you could Right Click Service Reference-> Configure Service Reference-> Data Type-> Collection Type-> Select System.Collections.Generic.List.

    >>If I fill the object-Fields ONLY with strings everything is fine and my program runs. But if I store numbers and DateTimes, the program will give this exception.

    For this issue, if it still exists after you change the Collection Type, I would suggest you post a new thread, and then share us how you implement getTable method, and how you call service from client.

    Best Regards,

    Edward


    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.


    • Proposed as answer by Tony---- Tuesday, September 13, 2016 11:03 AM
    • Marked as answer by Quidnunc1987 Tuesday, September 13, 2016 1:05 PM
    Tuesday, September 13, 2016 2:34 AM
  • Thanks! That was, what I was searching for!

    The reason why the types were changing from time to time was my attempt to give back a DataTable. Silverlight didn't like it ;)


    • Edited by Quidnunc1987 Tuesday, September 13, 2016 1:14 PM new knowledge
    Tuesday, September 13, 2016 10:05 AM