|
-
Sep 28th, 2009, 01:10 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Error: cannot obtain value in Watch
Hi all,
I'm facing a strange problem in VS.Net 2003 Debugger mode.
I'm testing a window application which was written in VB.Net 2003.
I set a few BreakPoints and Debug the project.
When the debugger hit one of the breakpoints, it stops at there. Its correct.
But when I try to add one of the variables to "Watch", it said "error: cannot obtain value".
I tried to search the Net and found that some said "its because of structures", some said "its because of passing too many parameters." and some said "its because of too many line of codes (LOCs)".
but my problem is not in passing parameters or too many line of code.
the function i set breakpoint has only around 300 LOCs (including around 100 line of comments)
And the value I tried to get is from my TreeView which is on my Win Forms.
its very strange that I can't even get the value from Forms.
I assign this TreeView value to another TreeView (this one is declare in code.)
And this second TreeView also can't view Watch.
What can I do for that?
Any suggestions or any fixes?
I'm using Visual Studio 2003 in VB.Net with SQL Server 2000 for the above project.
Thanks.
-
Sep 28th, 2009, 01:27 AM
#2
Re: Error: cannot obtain value in Watch
If you are having a problem with some specific code, would it not be a good idea to show us that code?
-
Sep 28th, 2009, 02:02 AM
#3
Thread Starter
Addicted Member
Re: Error: cannot obtain value in Watch
Hi jmcilhinney,
Sorry, I thought it didn't related to my code. So, I didn't put it here.
Here is some of my code.
VB.Net Code:
Private Sub PrintIDCard(ByVal dtCard As DataTable, ByVal LabelType As String, ByVal Category As String)
Dim iCount As Integer : Dim LabelSize As String : Dim LoopTree As Int16 : Dim LabelID As Integer
For iCount = 0 To dtCard.Rows.Count - 1
'If CStr(dtCard.Rows(iCount).Item("Label_Type")).ToUpper = LabelType.ToUpper And _
'CStr(dtCard.Rows(iCount).Item("Category")).ToUpper = Category.ToUpper Then
Dim PrintData As String : Dim StuID As String : Dim CardID As String
Dim Status As Char
If dtCard.Rows(iCount).Item("LABEL_TYPE").ToString.Equals(LabelType) And dtCard.Rows(iCount).Item("Category").ToString.Equals(Category) Then
Dim Qty As Integer = 0
If StuID Is Nothing Then
StuID = dtCard.Rows(iCount).Item("StuID").ToString
End If
CardID = dtCard.Rows(iCount).Item("CardID").ToString
Dim getSelected As Boolean = False
If (LabelType.Equals("StuLabel1") Or LabelType.Equals("StuLabel2")) Then
Dim SelectedTreeView As TreeView
Dim SelectedTreeView2 As TreeView
If LabelType.Equals("StuLabel1") And Category.Equals("C") Then
SelectedTreeView = TreeStu1
ElseIf LabelType.Equals("StuLabel2") And Category.Equals("C") Then
SelectedTreeView = TreeStu2
ElseIf LabelType.Equals("StuLabel1") And Category.Equals("P") Then
SelectedTreeView = TreePStu1
SelectedTreeView2 = TreePStu2
ElseIf LabelType.Equals("StuLabel2") And Category.Equals("P") Then
SelectedTreeView = TreePStu3
SelectedTreeView2 = TreePStu4
End If
getSelected = getPrintData(SelectedTreeView, CardID, StuID, dtCard.Rows(iCount).Item("SEQ").ToString, Category, SelectedTreeView2)
If getSelected = True Then
PrintData = ""
End If
Else
getSelected = True
End If
If getSelected = True Then
Dim LType As String = ""
If LabelType.Equals("LibrLabel") Then
LType = "H"
ElseIf LabelType.Equals("StuLabel1") Or LabelType.Equals("StuLabel2") Then
LType = "C"
Else
LType = ""
End If
If Format(CDate(dtCard.Rows(iCount).Item("Printed_date")), "yyyy/MM/dd").Equals("1900/01/01") Then
'is a new card
Status = "N"
Else
' this is a reprint card
Status = "R"
End If
'..... and so on. sorry I can't show up all the code here. Please understand me.
Next iCount
End Sub
First call from btnPrint_Click to PrintJob Function.
In PrintJob function it will check input data and Load the necessary data.
From PrintJob, it will go to PrintIDCard function by passing the DataTable to it.
I can't get the dataTable value also. It said the same error.
And for same for below two code, it always said can't obtain value error.
SelectedTreeView = TreePStu1
SelectedTreeView2 = TreePStu2
This TreePStu1 and TreePStu2 are my TreeViews. I put these 2 TreeView in Designer. By right, I can get the value of each view.
So strange is I can get the value of each TreeView while I'm in btnPrint_Click and PrintJob functions.
But when I arrived PrintIDCard function it said:
TreePStu1.nodes.count - Expression cannot be evaluated at this time.
TreePStu1 - error: cannot obtain value.
Hope the code I provided is OK with you.
Here is my Print Click function
vb.net Code:
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Cursor.Current = Cursors.WaitCursor
PrintJob()
Cursor.Current = Cursors.Default
Me.Close()
End Sub
Here is the another function (PrintJob)
vb.net Code:
Private Sub PrintJob()
Dim StuDS As DataSet
Dim StuDT As DataTable
StuDS = GetReprintStudentList(txtStuStart.Text, txtStuEnd.Text)
StuDT = StuDS.Tables(0)
With DGridList
.DataSource = StuDS.Tables(1)
.Refresh()
End With
If Me.chkPStu1.Checked And chkPStu1.Visible = True Then PrintIDCard(StuDT, "StuLabel1", "P")
If Me.chkPStu2.Checked And chkPStu2.Visible = True Then PrintIDCard(StuDT, "StuLabel2", "P")
End Sub
-
Sep 28th, 2009, 02:16 AM
#4
Thread Starter
Addicted Member
Re: Error: cannot obtain value in Watch
Currently, should I say "I'm blind trace and debugging the program!" 
Although I can't get the value directly, I can get Nodes Count in-directly.
Dim iNodeCount As Integer = TreePStu1.Nodes.Count
I can get the Nodes count from PrintIDCard function from above code but actually I need is what inside the TreeView's Nodes.
so, now, I just assume this time - value A, next time - value B in TreeNode loop etc.
Although it seems to work now, I'm not sure when the data accuracy will raise issue/error.
So, I'm trying to find a way to get the value in Watch.
I hope i don't need to change the code logic too much. (Since I took over this project, lots of errors to fix and very short time frame to deliver )
If I need to change the way passing parameters or change some array, class or something, etc, I sure gonna have sleepless nights
-
Sep 28th, 2009, 02:27 AM
#5
Re: Error: cannot obtain value in Watch
It looks like that may be a bug in VS that was never actually fixed in VS.NET 2003.
http://connect.microsoft.com/VisualS...dbackID=237556
-
Sep 28th, 2009, 03:09 AM
#6
Thread Starter
Addicted Member
Re: Error: cannot obtain value in Watch
-
Sep 28th, 2009, 04:21 AM
#7
Re: [RESOLVED] Error: cannot obtain value in Watch
Note that I simply Googled your error message, i.e. error: cannot obtain value, and that page was near the top of the results. I'm guessing that you could have done that.
-
Sep 28th, 2009, 04:56 AM
#8
Thread Starter
Addicted Member
Re: [RESOLVED] Error: cannot obtain value in Watch
 Originally Posted by jmcilhinney
Note that I simply Googled your error message, i.e. error: cannot obtain value, and that page was near the top of the results. I'm guessing that you could have done that.
Really???
So strange!
I only found these data
http://www.google.com/search?rlz=1C1...t+obtain+value
Error: Cannot obtain value - SOLUTION
Error: Cannot obtain Metadata
and channel9.msdn.com, forums.asp.net, tech-archive.net, pcreview.co.uk, syncfusion.com, bytes.com, and also this thread too!!! 
but not ur link. I think google return the result based on region or based on user activity. I checked up to Page no 1, 2, 3 and 4 in Google and still no such site listed 
anyway, i got a new useful link from you!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|