Error when starting Web Client in DEBUG

Discussion in 'ASP .Net Web Services' started by bixbarton, Dec 8, 2006.

  1. bixbarton

    bixbarton Guest

    Running C# .NET 1.1

    I'm experiencing a weird oddity.

    We have a client app which access the webservice at
    http://www.test.planningportal.gov.uk/soap/servlet/messagerouter

    If I start the client with no debugging it's fine.

    But if I start the client with debuggin on, when it Invokes a method on
    the webservice you get an exception saying "The underlying connection
    was closed: An unexpected error occurred on a send."

    I've searched online and all the results so far talk about how you need
    to override the WebRequest method and stick a KeepAlive = false in
    there.

    protected override WebRequest GetWebRequest(Uri uri)
    {
    HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
    request.KeepAlive = false;
    return request;
    }

    I've tried this, even accounting for the fact that the webservice is
    using SOAP. But still no joy.

    I also found another variation on the concept shown below;

    protected override WebRequest GetWebRequest(Uri uri)
    {
    WebRequest request = base.GetWebRequest(uri);

    if (requestPropertyInfo == null)
    {
    System.Type sType = request.GetType();
    requestPropertyInfo = sType.GetProperty("WebRequest");
    }

    if (requestPropertyInfo != null)
    {
    HttpWebRequest webRequest =
    (HttpWebRequest)requestPropertyInfo.GetValue(request, null);
    webRequest.KeepAlive = false;
    }
    return request;
    }

    But also this doesn't help. requestPropertyInfo ends up containing a
    null and so the GetValue never gets called.

    Does anyone have an idea?

    Krs
    Chris
    bixbarton, Dec 8, 2006
    #1
    1. Advertising

  2. bixbarton

    bixbarton Guest

    Figured out the solution to it myself.

    When running in DEBUG, ASP.NET sticks a VsDebuggerCausalityData section
    into the request.

    This isn't always handled by the web service.

    To turn off this section you need to add the following to your
    applications CONFIG file.

    <system.diagnostics>
    <switches>
    <!-- <add name="SwitchName" value="4"/> -->
    <add name="Remote.Disable" value="1" />
    </switches>
    <trace autoflush="false" indentsize="4"/>
    <!-- <assert assertuienabled="true" logfilename=".\TraceLog.txt"/>
    -->
    </system.diagnostics>


    On Dec 8, 10:39 am, "bixbarton" <> wrote:
    > Running C# .NET 1.1
    >
    > I'm experiencing a weird oddity.
    >
    > We have a client app which access the webservice athttp://www.test.planningportal.gov.uk/soap/servlet/messagerouter
    >
    > If I start the client with no debugging it's fine.
    >
    > But if I start the client with debuggin on, when it Invokes a method on
    > the webservice you get an exception saying "The underlying connection
    > was closed: An unexpected error occurred on a send."
    >
    > I've searched online and all the results so far talk about how you need
    > to override the WebRequest method and stick a KeepAlive = false in
    > there.
    >
    > protected override WebRequest GetWebRequest(Uri uri)
    > {
    > HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
    > request.KeepAlive = false;
    > return request;
    > }
    >
    > I've tried this, even accounting for the fact that the webservice is
    > using SOAP. But still no joy.
    >
    > I also found another variation on the concept shown below;
    >
    > protected override WebRequest GetWebRequest(Uri uri)
    > {
    > WebRequest request = base.GetWebRequest(uri);
    >
    > if (requestPropertyInfo == null)
    > {
    > System.Type sType = request.GetType();
    > requestPropertyInfo = sType.GetProperty("WebRequest");
    > }
    >
    > if (requestPropertyInfo != null)
    > {
    > HttpWebRequest webRequest =
    > (HttpWebRequest)requestPropertyInfo.GetValue(request, null);
    > webRequest.KeepAlive = false;
    > }
    > return request;
    > }
    >
    > But also this doesn't help. requestPropertyInfo ends up containing a
    > null and so the GetValue never gets called.
    >
    > Does anyone have an idea?
    >
    > Krs
    > Chris
    bixbarton, Dec 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RonL
    Replies:
    0
    Views:
    731
  2. ringos75
    Replies:
    0
    Views:
    943
    ringos75
    Apr 14, 2005
  3. Mike C. Fletcher
    Replies:
    3
    Views:
    970
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Oct 12, 2003
  4. André
    Replies:
    3
    Views:
    1,562
  5. jack

    Starting VS2005 in debug mode

    jack, Sep 11, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    361
Loading...

Share This Page