简体   繁体   中英

why does my silverlight reference to my wcf service blow up when I add a method to the wcf service that returns a generic list

I have built a WCF Service that is being consumed by a Silverlight app. At first I created one method that was very simple:

        public String SfTest()
    {
        return "SF Test";
    }

No poblem. My silverlight app references my service and displays "SF Test" in a textbox.

Now I add a method to my wcf service like this:

        public List<String> GetTest()
    {
        List<String> list = new List<string>();
        String a = "a";
        list.Add(a);
        String b = "b";
        list.Add(b);

         return list;

    }

I update the reference to the service in my Silverlight app and the using statement in my xaml cs page throws an error like the service doesn't even exist although it is there.

I am assuming the problem has to do with datatypes or serialization or something like that but it is driving me up the wall. Why can't I consume a simple generic list in my Silverlight app through the WCF service.

Look at the Reference.cs file generated by the Add Service Reference... dialog box, and see if the appropriate proxy classes/etc. are being generated there.

I've run into issues like this before, where the Add Service Reference... dialog box isn't able to create the proxies for one reason or another. Unfortunately, it doesn't give you any feedback on why it can't generate the appropriate classes. To troubleshoot it better, my recommendation is to drop back to the SLSvcUtil.exe file (usually located in c:\\Program Files\\Microsoft SDKs\\Silverlight\\v4.0\\Tools ), and try to generate your proxies that way. It will quite possibly fail, but it will at least tell you why it's failing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM