Results 1 to 8 of 8

Thread: [RESOLVED] Error: cannot obtain value in Watch

  1. #1

    Thread Starter
    Addicted Member scsfdev's Avatar
    Join Date
    Feb 2008
    Location
    Singapore
    Posts
    224

    Resolved [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.
    I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.

    My hobby beside programming: http://dslrstranger.wordpress.com

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member scsfdev's Avatar
    Join Date
    Feb 2008
    Location
    Singapore
    Posts
    224

    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:
    1. Private Sub PrintIDCard(ByVal dtCard As DataTable, ByVal LabelType As String, ByVal Category As String)
    2.         Dim iCount As Integer : Dim LabelSize As String : Dim LoopTree As Int16 : Dim LabelID As Integer
    3.  
    4.         For iCount = 0 To dtCard.Rows.Count - 1
    5.             'If CStr(dtCard.Rows(iCount).Item("Label_Type")).ToUpper = LabelType.ToUpper And _
    6.             'CStr(dtCard.Rows(iCount).Item("Category")).ToUpper = Category.ToUpper Then
    7.  
    8.             Dim PrintData As String : Dim StuID As String : Dim CardID As String
    9.             Dim Status As Char
    10.  
    11.             If dtCard.Rows(iCount).Item("LABEL_TYPE").ToString.Equals(LabelType) And dtCard.Rows(iCount).Item("Category").ToString.Equals(Category) Then
    12.                 Dim Qty As Integer = 0
    13.          
    14.                 If StuID Is Nothing Then
    15.                     StuID = dtCard.Rows(iCount).Item("StuID").ToString
    16.                 End If
    17.  
    18.                 CardID = dtCard.Rows(iCount).Item("CardID").ToString
    19.  
    20.                 Dim getSelected As Boolean = False
    21.  
    22.                 If (LabelType.Equals("StuLabel1") Or LabelType.Equals("StuLabel2")) Then
    23.                     Dim SelectedTreeView As TreeView
    24.                     Dim SelectedTreeView2 As TreeView
    25.  
    26.                     If LabelType.Equals("StuLabel1") And Category.Equals("C") Then
    27.                         SelectedTreeView = TreeStu1
    28.                     ElseIf LabelType.Equals("StuLabel2") And Category.Equals("C") Then
    29.                         SelectedTreeView = TreeStu2
    30.                     ElseIf LabelType.Equals("StuLabel1") And Category.Equals("P") Then
    31.                         SelectedTreeView = TreePStu1
    32.                         SelectedTreeView2 = TreePStu2
    33.                     ElseIf LabelType.Equals("StuLabel2") And Category.Equals("P") Then
    34.                         SelectedTreeView = TreePStu3
    35.                         SelectedTreeView2 = TreePStu4
    36.                     End If
    37.  
    38.                     getSelected = getPrintData(SelectedTreeView, CardID, StuID, dtCard.Rows(iCount).Item("SEQ").ToString, Category, SelectedTreeView2)
    39.                     If getSelected = True Then
    40.                         PrintData = ""
    41.                     End If
    42.                 Else
    43.                     getSelected = True
    44.                 End If
    45.  
    46.                 If getSelected = True Then
    47.                     Dim LType As String = ""
    48.                     If LabelType.Equals("LibrLabel") Then
    49.                         LType = "H"
    50.                     ElseIf LabelType.Equals("StuLabel1") Or LabelType.Equals("StuLabel2") Then
    51.                         LType = "C"
    52.                     Else
    53.                         LType = ""
    54.                     End If
    55.  
    56.                     If Format(CDate(dtCard.Rows(iCount).Item("Printed_date")), "yyyy/MM/dd").Equals("1900/01/01") Then
    57.                         'is a new card
    58.                         Status = "N"
    59.                     Else
    60.                         ' this is a reprint card
    61.                         Status = "R"
    62.                     End If
    63.  
    64.                '..... and so on. sorry I can't show up all the code here. Please understand me.
    65.  
    66.         Next iCount
    67.     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:
    1. Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
    2.         Cursor.Current = Cursors.WaitCursor
    3.         PrintJob()
    4.         Cursor.Current = Cursors.Default
    5.         Me.Close()
    6.     End Sub

    Here is the another function (PrintJob)
    vb.net Code:
    1. Private Sub PrintJob()
    2.         Dim StuDS As DataSet
    3.         Dim StuDT As DataTable
    4.         StuDS = GetReprintStudentList(txtStuStart.Text, txtStuEnd.Text)
    5.  
    6.         StuDT = StuDS.Tables(0)
    7.         With DGridList
    8.             .DataSource = StuDS.Tables(1)
    9.             .Refresh()
    10.         End With
    11.  
    12.         If Me.chkPStu1.Checked And chkPStu1.Visible = True Then PrintIDCard(StuDT, "StuLabel1", "P")
    13.         If Me.chkPStu2.Checked And chkPStu2.Visible = True Then PrintIDCard(StuDT, "StuLabel2", "P")
    14.     End Sub
    I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.

    My hobby beside programming: http://dslrstranger.wordpress.com

  4. #4

    Thread Starter
    Addicted Member scsfdev's Avatar
    Join Date
    Feb 2008
    Location
    Singapore
    Posts
    224

    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
    I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.

    My hobby beside programming: http://dslrstranger.wordpress.com

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Addicted Member scsfdev's Avatar
    Join Date
    Feb 2008
    Location
    Singapore
    Posts
    224

    Re: Error: cannot obtain value in Watch

    Quote Originally Posted by jmcilhinney View Post
    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
    Hi jmcilhinney,

    Thanks for your precious information.
    This is my first time I surf that web site. May be later it will surely useful for me.
    If not because of ur link, I may digging the Net and my time will tick, tick

    So, I only have a chance of blind debug.
    Anyway, I may need to put a little extra effort while debugging.
    Thanks again.
    I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.

    My hobby beside programming: http://dslrstranger.wordpress.com

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Addicted Member scsfdev's Avatar
    Join Date
    Feb 2008
    Location
    Singapore
    Posts
    224

    Re: [RESOLVED] Error: cannot obtain value in Watch

    Quote Originally Posted by jmcilhinney View Post
    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!!
    I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.

    My hobby beside programming: http://dslrstranger.wordpress.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width