问题描述
我的WCF方法,像这样:
I have WCF method like so:
public string GetSomething(MyObject obj)
{
return "Something";
}
当我把这个从我的Silverlight应用程序我得到一个错误:
System.Net.WebException:远程服务器返回错误:NOTFOUND .....
When I call this from my silverlight app I get an error:
System.Net.WebException: The remote server returned an error: NotFound.....
我调用该方法从我的Silverlight应用程序,像这样:
I call the method from my silverlight app like so:
mProxy.GetSomethingAsync(new MyObject());
现在,当我调用该方法是这样,它工作正常:
Now, when I call the method like this it works fine:
mProxy.GetSomethingAsync(null);
所以,似乎有一些问题,传入一个复杂的对象。
So there seems to be some problem with passing in a complex object.
请注意,我回到这个MyObject的其他方法,它工作得很好,所以它不是一个序列化的问题。我也改变了maxBufferSize和maxReceivedMessageSize到最大值,所以它不是这一点,我传递一个空的对象,反正所以它不应该是一个规模的问题。而为MyObject只包含简单的数据类型。
Note that I return this MyObject from other method and it works fine so it's not a serializable issue. I also changed the maxBufferSize and maxReceivedMessageSize to the max value so it's not that, and i pass in an empty object anyway so it shouldn't be a size issue. And MyObject only contains simple datatypes.
有没有人有什么建议?
推荐答案
这是未找到的错误,也许是Silverlight的WCF访问的一个最烦人的功能。
That "Not Found" error is perhaps the single most annoying feature of Silverlight WCF access.
您可能要考虑服务跟踪查看器工具(这里)。这并不总是有益的(我碰到的很多问题,这是不能够帮助),但大约10-20%的时候,它会指出我在正确的方向。
You may want to look into the Service Trace Viewer Tool (here). It's not always helpful (I've run into lots of problems that it wasn't able to help with), but about 10-20% of the time, it'll point me in the right direction.
您可能也想尝试加入 SilverlightFaultBehavior 为您服务。它可以将至少其中一些未找到的错误消息到真正的故障。
You may also want to try adding the SilverlightFaultBehavior to your service. It can turn at least some of those "Not Found" error messages into real faults.
这篇关于Silverlight和WCF:NOTFOUND错误!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!