all groups > visual studio .net debugging > december 2004 >
You're in the

visual studio .net debugging

group:

Error: Cannot obtain value - SOLUTION


Error: Cannot obtain value - SOLUTION Fredrik Melin
12/14/2004 11:26:08 PM
visual studio .net debugging:
I finally found the solution for this problem (at least in my case), Thanks
to MS support.

There was _one_ function with too many parameters.

Stack pointer can only hold a so-so big value, so with all this parameters,
it got too big.

Now the tricky part, if you had a huge part of code, last line was a call to
this function, You did a breakpoint on the first row, you _STILL_ got the
error, you dont need to execute the line, it just needed to be there. Eg, in
a ASP.NET page, you got Error: Cannot obtain value everywhere, just for
addressing your function (that had too many parameter) later in the code.

Solution:

Change your function to take less parameters, or consolidate your parameters
into a class so the function takes the class as a parameter.

This is the function that didnt work.
Public Function Add(ByVal productID As String, ByVal quantity As Integer,
ByVal accountNumber As Short, Optional ByVal stockKeeping As Boolean = True,
Optional ByVal quantityBackordered As Integer = 0, Optional ByVal taxPercent
As Decimal = -999999, Optional ByVal productName As String = "", Optional
ByVal cost As Decimal = -999999, Optional ByVal price As Decimal = -999999,
Optional ByVal textComment As String = "", Optional ByVal rowComment As
String = "", Optional ByVal customerPoNo As String = "", Optional ByRef
dbTrans As Object = Nothing, Optional ByVal purchaseorderComment As String =
"", Optional ByVal performInventoryLock As Boolean = False, Optional ByVal
updateIfExists As Boolean = False, Optional ByVal
bAddCreditedLinesBackToStock As Boolean = False, Optional ByVal isKickback
As Boolean = False, Optional ByVal kickbackCost As Decimal = 0, Optional
ByVal ddLinkKey As Long = 0) As Boolean



Changed it to

Public Function Add(ByVal productID As String, ByVal quantity As Integer,
ByVal accountNumber As Short, ByVal inParam As myAddRowParam, Optional ByRef
dbTrans As SqlClient.SqlTransaction = Nothing) As Boolean



with a the inParam as

Public Class myAddRowParam
Public stockKeeping As Boolean = True
Public quantityBackordered As Integer = 0
Public taxPercent As Decimal = -999999
Public productName As String = ""
Public cost As Decimal = -999999
Public price As Decimal = -999999
Public textComment As String = ""
Public rowComment As String = ""
Public customerPoNo As String = ""
Public purchaseorderComment As String = ""
Public performInventoryLock As Boolean = False
Public updateIfExists As Boolean = False
Public bAddCreditedLinesBackToStock As Boolean = False
Public isKickback As Boolean = False
Public kickbackCost As Decimal = 0
Public ddLinkKey As Long = 0
End Class


And the whole solution works again.


Regards
Fredrik Melin
Dacsa AB

RE: Error: Cannot obtain value - SOLUTION Lee
12/15/2004 6:53:07 AM
I wish that was the solution to my problem. In my case the function does not
even taken any parameters, and on top of that the "watches" that I am trying
to set are on private module level variables, on is a data table, and the
Re: Error: Cannot obtain value - SOLUTION Fredrik Melin
12/15/2004 4:15:39 PM
Doensnt matter if your function takes parameters on not, its enough that you
later in the code call a function with too many parameters.


Eg:

Public Function MyFunc()
-> Breakpoint here
- 1000 lines of code
- Call to function with too many a parameter
End Function

This will still render error when breaking on the first row, even if the
call isnt made yet.


[quoted text, click to view]

Re: Error: Cannot obtain value - SOLUTION Lee
12/16/2004 8:27:11 AM
After poking around some more, It is a function call with my code that has a
number of parameters. I look at this as a total BUG and it should be fixed by
Microsoft ASAP. You cannot expect developers to go around counting the number
of parameters they use in their code just to satisfy a debugger. Perhaps
someone could supply a third party debugger, but what a pain that would be. I
am tempted to install VS.NET 2002 and see if the problem exists there with
Re: Error: Cannot obtain value - SOLUTION Fredrik Melin
12/17/2004 9:41:57 AM
Ive tested my code in VB2005, no error there.

[quoted text, click to view]

Re: Error: Cannot obtain value - SOLUTION Kurzweil
12/22/2004 10:05:57 AM
No solution for me. I have no functions with more than 6 parameters
anywhere. When removing those with 6 parameters it leaves me with functions
with only 4 parameters. I don't plan to rewrite those!

Thanks for the help, but do you have another idea?

[quoted text, click to view]

Re: Error: Cannot obtain value - SOLUTION Fredrik Melin
12/22/2004 10:45:34 AM
The error it self is because stack pointers get screwed, only way then is to
submit bug report (and pay $99) to microsoft.

(thats what I did to get my problem solved)

Can you replicate the error in a small application? its easier to get an
answer from ms then..

[quoted text, click to view]

AddThis Social Bookmark Button