当我向返回常规列表的wcf服务中添加方法时,为什么对wcf服务的silverlight引用会爆炸 [英] 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

查看:99
本文介绍了当我向返回常规列表的wcf服务中添加方法时,为什么对wcf服务的silverlight引用会爆炸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个Silverlight应用程序正在使用的WCF服务.最初,我创建了一个非常简单的方法:

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";
    }

没有问题.我的silverlight应用程序引用了我的服务,并在文本框中显示"SF测试".

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

现在,我将这样的方法添加到我的wcf服务中:

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;

    }

我在Silverlight应用程序中更新了对该服务的引用,并且在我的xaml cs页面中的using语句引发了一个错误,例如该服务甚至不存在.

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.

我假设问题与数据类型或序列化或类似问题有关,但它使我无所适从.为什么我不能通过WCF服务在Silverlight应用中使用一个简单的常规列表.

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.

推荐答案

查看由添加服务引用... 对话框生成的 Reference.cs 文件,并查看是否有适当的代理类/等.在这里生成.

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.

我以前遇到过这样的问题,其中添加服务参考... 对话框由于某种原因而无法创建代理.不幸的是,它没有为您提供关于为什么不能生成适当类的任何反馈.为了更好地进行故障排除,我的建议是放回 SLSvcUtil.exe 文件(通常位于 c:\ Program Files \ Microsoft SDKs \ Silverlight \ v4.0 \ Tools ),并尝试以这种方式生成代理.它很可能会失败,但至少会告诉您为什么失败.

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.

这篇关于当我向返回常规列表的wcf服务中添加方法时,为什么对wcf服务的silverlight引用会爆炸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆