C# – Silverlight and WCF: NotFound error!

cnetsilverlightwcf

I have WCF method like so:

    public string GetSomething(MyObject obj)
    {
        return "Something";
    }

When I call this from my silverlight app I get an error:
System.Net.WebException: The remote server returned an error: NotFound…..

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.

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.

Has anyone any suggestions?

Best Answer

That "Not Found" error is perhaps the single most annoying feature of Silverlight WCF access.

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.

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.