Debugger/Program Issue with Storage of Structures?

Raven65

Well-known member
Joined
Oct 4, 2006
Messages
305
Programming Experience
3-5
Ok, this one thrown me for a loop, though I am sure I'm simply doing something wrong.

Trying to keep this simple, but accurate:

I have some Structures setup:

VB.NET:
Public Structure Contract
 Dim myName as String
 Dim myCharges as List(of Generic_Charge)
End Structure

Public Structure Generic_Charge
 Dim amount as String
End Structure


At a point my my code, I do the following:

VB.NET:
Dim myContract as new Contract
 myContract.myName="TEST"
 myContract.myCharges = new List(of Generic_Charge)


Dim myCharge as new Generic_Charge
myCharge.amount = "100"

myContract.myCharges.Add(myCharge)
STOP

So, in the debugger, I can see that myContract.myName="Test", but my Contract.myCharges cannot be evaluated, I only get: "In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user."

Im here debugging because the property is evaluated later in the program and it crashes, since there is nothing there..but for the life of me I cannot figure out what I am overlooking, I know it has to be some simple rule about Structures or what not....I hope that's clear enough that someone's able to help, thanks in advance!

I suspect its around the "myContracts.myCharges = new List(of Generic_Charge)" part?
 
write this in Immediate window when you Stop:
?myContract.myCharges(0).amount
and you get this reply:
btw, I can also hover the objects of your sample and read the collection, and don't get that error.
 
Yea, that is the weird thing, I built a small similiar app, and it works fine. I was hoping someone might have experienced similar and could alert me to any potential compilier setting I might have screwed up?
 
Ok, back @ the code this morning, trying to see the same thing you did, in the program while debugging I tried the immediate output again and get the following:

"
?CONTRACT.VOICE_CALLS(0).DEST_MDN
Cannot evaluate expression because we are stopped in a place where garbage collection is impossible, since the code of the current method may be optimized.
"

Researching now, but wanted you to know what I'm getting incase it helps w/ assisting.

Also, exact code section here:


VB.NET:
Dim CONTRACT As New CONTRACT
CONTRACT.VOICE_CALLS = New List(Of CONTRACT_GENERIC_CALL)

Dim myTest As New CONTRACT_GENERIC_CALL
myTest.DEST_MDN = "12345"
CONTRACT.VOICE_CALLS.Add(myTest)

'At this point I cannot see the content of Contract.Voice_Calls, and Immediate investigation gives the above error.

CONTRACT is defined in another module as:
VB.NET:
Structure CONTRACT
        Dim VOICE_CALLS As List(Of CONTRACT_GENERIC_CALL)
        'Plus Many Other Fields
End Structure
Public Structure CONTRACT_GENERIC_CALL
        Dim DEST_MDN As String
        'Plus Many Other Fields
End Structure
 
Last edited:
This just in, changed Contract to a Class, instead of a structure and all works fine.

I apparently need to brush up on the diffreence as I am not sure, in this case, why it worked...
 
Your posts 1 & 4 looks identical to me, I still don't see the problem. Is there something you're not telling us? :)
 
No, they should. Post 1 was made from home from memory, then 4 was the next morning cut and paste from studio to ensure I hadn't typo'ed anything.

Currently, the whole thing is working having changed that type from Structure to Class. I look forward to finding out -why- that worked in this case, but for now I just have to finish the project.
 
Back
Top