0

I have WebService1. Class "MapObject" declared in WebService1's solution.

    [WebMethod]
    public void GetRoute(MapObject from, MapObject to)
    {
        // Something here
        return;
    }

WebService2 is using methods of WebService1. Also, WebService2 has method

    [WebMethod]
    public void TestMethod(MapObject obj)
    {
        /// something here
    }

But when I try to call TestMethod I recieve

System.IndexOutOfRangeException: Индекс находился вне границ массива. в System.Web.Services.Protocols.HttpServerType..ctor(Type type) в System.Web.Services.Protocols.HttpServerProtocol.Initialize() в System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

This is because MapObject can not be serialized, but I can not understand why. I would like to know how I can solve this problem, if I need to use types of WebService1 in methods of WebService2.

KolobOKs
  • 26
  • 3
  • 1
    MapObject can't be serialized. Why? –  Mar 29 '15 at 18:17
  • I found a similar question here: [link](http://stackoverflow.com/questions/4449398/asp-net-web-service-returns-indexoutofrangeexception-with-arguments) I suggested that I have a problem of the same kind. – KolobOKs Mar 29 '15 at 18:23
  • Does MapObject have a Dictionary in it? –  Mar 29 '15 at 18:34
  • Nope, just 2 string propreties – KolobOKs Mar 29 '15 at 18:50
  • Do you know what kind of serializer is being used? Not sure what the default is for web methods. See if you can find out, then try serializing/deserializing an example MapObject to see if anything throws. Also, specify the full path of MapObject in case you are actually referring to a different type. Pull MapObject into its own assembly. Reference it from both services so you are using the same exact type. These are all guesses, as it is not clear from the error or your details why this is happening :/ –  Mar 29 '15 at 19:06

0 Answers0