SgDotNet
Singapore Professional .NET User Group -For Cool Developers

IndexOutOfRange exception from within ServerProtocolFactory

rated by 0 users
This post has 3 Replies | 0 Followers

Top 25 Contributor
Posts 240
hannes Posted: 05-11-2007 7:16 PM

I've recreated this error by creating a webservice containing only 2 types of webmethods: One with a return type and out parameter, and one with no return type.

If I try to invoke "voidmethod()" from the test page, I get the following exception:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
   at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
The exception occurs even before the webmethod is called. Adding another type of webmethod to the webservice - one with a return type but no out parameter - fixes the issue so that voidmethod() can be called.I could not determine whether this bug has been fixed. Can anyone determine the cause?

public class WebService : System.Web.Services.WebService
{
  public WebService () { }

[WebMethod]
public string outwithretmethod(out string outvar)
{
  outvar = "sdfsdf";
  return outvar;
}

[WebMethod]
public void voidmethod()
{
  string a = "should work but will be broken";
}

/*
[WebMethod]
public string magicfixer()
{
  return "adding any non-void + non-out-parameter method will fix it";
}
*/

Top 25 Contributor
Posts 240

Today's just a day for quirks (ive had about 10 now)... the pasted code repeated 11 times and I can't edit it... the code is:

 

public class WebService : System.Web.Services.WebService {

    public WebService () {     }

    [WebMethod]
    public string outwithretmethod(out string outvar)
    {
        outvar = "sdfsdf";
        return outvar;
    }


    [WebMethod]
    public void voidmethod()
    {
        string a = "should work but will be broken";
    }


//    [WebMethod]
//    public string magicfixer()
//    {
//        return "adding any non-void + non-out-parameter method will fix it";
//    }   

}

 

Top 150 Contributor
Posts 15

hi,

void method is not the problem here, the problem is with out parametered method. as far as i know we cant use out parameters in WebMethods.

i dint found the reason but just found text on microsoft site saying we cant specify in/out in webmethods.

http://www.microsoft.com/mspress/books/sampchap/5242b.aspx

thanks,

satish,

Top 25 Contributor
Posts 240

Ok, I'm not too sure what binding I'm using when running the test page...

 But, why does it work when I add the dummy method? It is a bit worrying.

Page 1 of 1 (4 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems