Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Object variable or With block variable not set
Message
From
22/01/2011 15:09:29
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Object variable or With block variable not set
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01497018
Message ID:
01497018
Views:
108
This page details some possibiltiies of obtaining the famous "Object variable or With block variable not set " error:

http://msdn.microsoft.com/en-us/library/5szkzs17(v=vs.80).aspx

In my code, one of the standard is to always initialize everything to a default value. So, here is an example:
        Dim lcHtml As String = ""
        Dim ldAddDate As Date = Nothing
        Dim llBlankDate As Boolean = False
        Dim llForceGive As Boolean = False
        Dim llHelpGive As Boolean = False
        Dim llHelpRemove As Boolean = False
        Dim llIn As Boolean = False
        Dim llPrevious As Boolean = False
        Dim llReply As Boolean = False
        Dim llSolution As Boolean = False
        Dim llSolutionGive As Boolean = False
        Dim llSolutionRemove As Boolean = False
        Dim llSolutionSysop As Boolean = False
        Dim llUnmarkSysop As Boolean = False
        Dim lnCounter As Integer = 0
        Dim lnLocation As Integer = 0
        Dim lnNoReply As Integer = 0
        Dim lnOriginalMember As Integer = 0
        Dim lnPoint As Integer = 0
        Dim lnUnmarkSysop As Integer = 0
        Dim lnUserHeadNoReply As Integer = 0
        Dim loControlLabel As System.Web.UI.WebControls.Label = New System.Web.UI.WebControls.Label
        Dim loControlLiteral As System.Web.UI.WebControls.Literal = New System.Web.UI.WebControls.Literal
        Dim loControlTable As System.Web.UI.WebControls.Table = New System.Web.UI.WebControls.Table
        Dim loDataProvider As Framework.Framework.Data = New Framework.Framework.Data(oProcess)
        Dim loRow As DataRow = Nothing
        Dim loUpdate As Framework.Framework.Update = New Framework.Framework.Update(oProcess)
But, referring to that page, point #2 says to make sure to not use an object variable set to Nothing.

I have a situation that happens once every one hundred thousand this approximately. So, it is very difficult to simulate. So, I cannot locate exactly where it happens. But, this error reported is within the biggest transaction being executed on this site. Basically, it is being done between 5000 to 10000 times a day. So, in regards to Nothing, could it be that the following line could cause this from time to time:
        Dim loRow As DataRow = Nothing
As I said, this hit works ok but once every hundred thousand hits approximately, it will generate an error. But, executing the page as is, will work at 99.99% of the time.

If this could be related to this line, then it is a bad bug, already reported by Microsoft, which should be fixed soon. Because, when not doing so, assuming just like this:
        Dim loRow As DataRow
This creates some green warning which is irritating me if I have defined a variable which is not being used.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform