M
mcateer77
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/2004/05/08/128394.aspx)
Using System.Net;
Using System.Reflection;
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
PropertyInfo requestPropertyInfo = null;
WebRequest request = base.GetWebRequest(uri);
if (requestPropertyInfo==null)
requestPropertyInfo = request.GetType().GetProperty("Request");
// Retrieve underlying web request
HttpWebRequest webRequest =
(HttpWebRequest)requestPropertyInfo.GetValue(request, null);
webRequest.KeepAlive = false;
return request;
}
I've done this so far:
Imports System.Net
Imports System.Reflection
Protected Overloads Overrides Function GetWebRequest(ByVal uri As Uri)
As System.Net.WebRequest
Dim requestPropertyInfo As PropertyInfo = Nothing
Dim request As WebRequest = MyBase.GetWebRequest(uri)
If requestPropertyInfo Is Nothing Then
requestPropertyInfo =
request.GetType.GetProperty("Request")
End If
Dim webRequest As HttpWebRequest =
CType(requestPropertyInfo.GetValue(request, Nothing), HttpWebRequest)
webRequest.KeepAlive = False
Return request
End Function
When I run this i get the following error:
"System.NullReferenceException: Object reference not set to an instance
of an object."
This occurs on the following line:
Dim webRequest As HttpWebRequest =
CType(requestPropertyInfo.GetValue(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/2004/05/08/128394.aspx)
Using System.Net;
Using System.Reflection;
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
PropertyInfo requestPropertyInfo = null;
WebRequest request = base.GetWebRequest(uri);
if (requestPropertyInfo==null)
requestPropertyInfo = request.GetType().GetProperty("Request");
// Retrieve underlying web request
HttpWebRequest webRequest =
(HttpWebRequest)requestPropertyInfo.GetValue(request, null);
webRequest.KeepAlive = false;
return request;
}
I've done this so far:
Imports System.Net
Imports System.Reflection
Protected Overloads Overrides Function GetWebRequest(ByVal uri As Uri)
As System.Net.WebRequest
Dim requestPropertyInfo As PropertyInfo = Nothing
Dim request As WebRequest = MyBase.GetWebRequest(uri)
If requestPropertyInfo Is Nothing Then
requestPropertyInfo =
request.GetType.GetProperty("Request")
End If
Dim webRequest As HttpWebRequest =
CType(requestPropertyInfo.GetValue(request, Nothing), HttpWebRequest)
webRequest.KeepAlive = False
Return request
End Function
When I run this i get the following error:
"System.NullReferenceException: Object reference not set to an instance
of an object."
This occurs on the following line:
Dim webRequest As HttpWebRequest =
CType(requestPropertyInfo.GetValue(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!!!