Last post Jan 26, 2009 01:59 PM by AceCorban
Jan 23, 2009 01:57 PM|dotnetjunkie52|LINK
I am using the IndexOf function of the string class to find a specific instance of a string. And based on that I have a logic to do something. Below is the example of what I am doing. The code is in production and is working fine. But for some instance I
am getting an "Object reference not set error". Yeah its intermittent.
The requestXML is a string of xml data passed in as a paramter to a subroutine. I am fetching the xml string as a form post in a request object.
The only thing I could think of getting this kind of error is when the requestXML string varia
Object reference IndexOf VB.Net
Jan 23, 2009 02:46 PM|AceCorban|LINK
your requestXml object is null in some cases (the reason why depends on what is going on in the "Request" function). Check for null (or "Nothing" in vb) before "doing something":
If requestXml IS NOT Nothing AND requestXml.IndexOf("HostRequest") > 0 Then
It should "short circuit" out before trying the .IndexOf method if it is null.
You might wanna check my VB syntax, I'm a C# guy.
Jan 23, 2009 03:14 PM|stratboogie|LINK
If requestXml IS NOT
Nothing AND requestXml.IndexOf("HostRequest") > 0
It should read:
If NOT requestXml IS NOTHING AndAlso request.Xml.IndexOf("HostRequest") > 0 then
Jan 26, 2009 01:17 PM|dotnetjunkie52|LINK
Thanks for the response guys. The weired thing is that this happens only for some requests and not all and this intermittent issue is killing me....I am submitting to this page using XMLHTTP object passing thie xml as a request parameter. But I dont seem
to understand why would it happen only for a specific user and not everyone. Any guesses?
Jan 26, 2009 01:33 PM|stratboogie|LINK
Have you stepped through your code both when it succeeds and also when it fails? If so have you noticed the difference in values in your watch windows? If not try that and watch the values that are being passed to the page.
Jan 26, 2009 01:59 PM|AceCorban|LINK
We might need some more information about what else is going on. What we do know is that the Request function is returning null in some cases (or setting its returned value into the XMLHttp object is interpreted as null) , but we do not know why. We need
to see what Request("requestXML") is doing before we can figure out much more.