This is driving me insane!
I'm trying to solve "The underlying connection was closed" issue when
using WSE 3.0 in VS2005.
I'm trying to convert the following c# code to vb.net:
(This is from:
http://weblogs.asp.net/jan/archive/2...08/128394.aspx)
Using System.Net;
Using System.Reflecti on;
protected override System.Net.WebR equest GetWebRequest(U ri uri)
{
PropertyInfo requestProperty Info = null;
WebRequest request = base.GetWebRequ est(uri);
if (requestPropert yInfo==null)
requestProperty Info = request.GetType ().GetProperty( "Request");
// Retrieve underlying web request
HttpWebRequest webRequest =
(HttpWebRequest )requestPropert yInfo.GetValue( request, null);
webRequest.Keep Alive = false;
return request;
}
I've done this so far:
Imports System.Net
Imports System.Reflecti on
Protected Overloads Overrides Function GetWebRequest(B yVal uri As Uri)
As System.Net.WebR equest
Dim requestProperty Info As PropertyInfo = Nothing
Dim request As WebRequest = MyBase.GetWebRe quest(uri)
If requestProperty Info Is Nothing Then
requestProperty Info =
request.GetType .GetProperty("R equest")
End If
Dim webRequest As HttpWebRequest =
CType(requestPr opertyInfo.GetV alue(request, Nothing), HttpWebRequest)
webRequest.Keep Alive = False
Return request
End Function
When I run this i get the following error:
"System.NullRef erenceException : Object reference not set to an instance
of an object."
This occurs on the following line:
Dim webRequest As HttpWebRequest =
CType(requestPr opertyInfo.GetV alue(request, Nothing), HttpWebRequest)
I think this is due to the "Nothing" being passed???
Does anyone know how to convert this? I've tried everything!
The parameter details are "index() As Object".
Any help would be much appreciated!!!
I'm trying to solve "The underlying connection was closed" issue when
using WSE 3.0 in VS2005.
I'm trying to convert the following c# code to vb.net:
(This is from:
http://weblogs.asp.net/jan/archive/2...08/128394.aspx)
Using System.Net;
Using System.Reflecti on;
protected override System.Net.WebR equest GetWebRequest(U ri uri)
{
PropertyInfo requestProperty Info = null;
WebRequest request = base.GetWebRequ est(uri);
if (requestPropert yInfo==null)
requestProperty Info = request.GetType ().GetProperty( "Request");
// Retrieve underlying web request
HttpWebRequest webRequest =
(HttpWebRequest )requestPropert yInfo.GetValue( request, null);
webRequest.Keep Alive = false;
return request;
}
I've done this so far:
Imports System.Net
Imports System.Reflecti on
Protected Overloads Overrides Function GetWebRequest(B yVal uri As Uri)
As System.Net.WebR equest
Dim requestProperty Info As PropertyInfo = Nothing
Dim request As WebRequest = MyBase.GetWebRe quest(uri)
If requestProperty Info Is Nothing Then
requestProperty Info =
request.GetType .GetProperty("R equest")
End If
Dim webRequest As HttpWebRequest =
CType(requestPr opertyInfo.GetV alue(request, Nothing), HttpWebRequest)
webRequest.Keep Alive = False
Return request
End Function
When I run this i get the following error:
"System.NullRef erenceException : Object reference not set to an instance
of an object."
This occurs on the following line:
Dim webRequest As HttpWebRequest =
CType(requestPr opertyInfo.GetV alue(request, Nothing), HttpWebRequest)
I think this is due to the "Nothing" being passed???
Does anyone know how to convert this? I've tried everything!
The parameter details are "index() As Object".
Any help would be much appreciated!!!
Comment