473,382 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

{length=error: cannot obtain value}

Hi,

I have a strange problem.

during the developement of my program, while progressively writing more and
more code, the callstack of my program gets deeper and deeper (7 levels).
Then, all of a sudden, when calling a Sub with 2 parameters, a Hashtable(19
items) and a ArrayList(9 items), the value of these variables is gone, the
debugger reports the value as {length=error: cannot obtain value}.

Passing them ByRef does not seem to solve the problem. IMHO, this seems to
be a problem with the stacksize.

Could somebody please help me with this?
TIA
Dominiek
Nov 20 '05 #1
5 3870
"Dominiek" <sc******@realsoftware.be> schrieb
during the developement of my program, while progressively writing
more and more code, the callstack of my program gets deeper and
deeper (7 levels). Then, all of a sudden, when calling a Sub with 2
parameters, a Hashtable(19 items) and a ArrayList(9 items), the value
of these variables is gone, the debugger reports the value as
{length=error: cannot obtain value}.

Passing them ByRef does not seem to solve the problem. IMHO, this
seems to be a problem with the stacksize.


7 levels is for sure not a problem with the stack size - unless you've got
really many local variables. Apart from this, you should get a
StackOverflowException.

I also had this problem, but *only* when using certain functions in the
managed DirectX assemblies. It's been forwarded as a bug to the dev team. I
guess you are not using managed DirectX? If you don't use it, sorry, I don't
have an explanation. You could narrow the problem down to as few lines as
possible and post it to microsoft.public.vsnet.ide or
microsoft.public.vsnet.debugging
--
Armin

Nov 20 '05 #2
Hey Armin,

Thanx for your reply

No, I'm not working with managed DirectX
No, I also didn't receive a StackOverflowException

I'm working with a lot of Structure's, which I pass ByVal from the upper
layer of my program. I just now changed all the passes ByVal to ByRef, and
now it seems to be working (for the moment). However, I think this issue
will resurface when the program increases in size.

I will follow your suggestion and forward this to the proposed newsgroups
Thnax
Dominiek

"Armin Zingler" <az*******@freenet.de> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl...
"Dominiek" <sc******@realsoftware.be> schrieb
during the developement of my program, while progressively writing
more and more code, the callstack of my program gets deeper and
deeper (7 levels). Then, all of a sudden, when calling a Sub with 2
parameters, a Hashtable(19 items) and a ArrayList(9 items), the value
of these variables is gone, the debugger reports the value as
{length=error: cannot obtain value}.

Passing them ByRef does not seem to solve the problem. IMHO, this
seems to be a problem with the stacksize.
7 levels is for sure not a problem with the stack size - unless you've got
really many local variables. Apart from this, you should get a
StackOverflowException.

I also had this problem, but *only* when using certain functions in the
managed DirectX assemblies. It's been forwarded as a bug to the dev team.

I guess you are not using managed DirectX? If you don't use it, sorry, I don't have an explanation. You could narrow the problem down to as few lines as
possible and post it to microsoft.public.vsnet.ide or
microsoft.public.vsnet.debugging
--
Armin

Nov 20 '05 #3
Hi Dominek,

Structures, when passed ByVal, are stored on the stack. When passed ByRef
they are 'boxed' on the heap and a reference passed on the stack instead. This
is why your program now works. Keep it ByRef and you will probably stay clear
of trouble.

Another option would be to reduce those structures by putting some chunks
of their contents into independant classes. This might be useful from a
conceptual point of view too.

Another option, perhaps the best, is simply to change Structure to Class
for some of the bigger Structures. This has a performance advantage when done
with Structures that are passed in and out of methods - whether you use ByVal
<or> ByRef..

As I mentioned, with ByRef, the Structure is 'boxed' and the reference
passed . Each time this happens, a block of memory must be allocated and the
Structure copied into it. With ByVal, the Structure is again copied, but this
time directly to the stack. Similarly, when a Structure is passed back from a
Function, another copy takes place. So Structuures are being copied around all
the time.

In contrast, Objects stay where they are and only the reference is
shuffled around.

Is there any particular reason/advantage in having these large objects as
Structures?

Regards,
Fergus
Nov 20 '05 #4
Dominiek,
In addition to Fergus's comments

Unless you specifically need structures, convert them to Classes!

Per the .NET Design Guidelines for Class Library Developers.

http://msdn.microsoft.com/library/de...guidelines.asp

Structures should:
- act like primitive types
- have an instance size under 16 bytes
- are immutable
- value semantics are desirable

Basically if your structure has more than 4 fields, you should seriously
consider using a class instead of a structure. As classes exist on the heap
and a reference to the class is passed as the ByVal parameter, where as
structures exist on the stack and a copy of the structure is passed as a
ByVal parameter.

You should reserve ByRef parameters for when you actually need to modify the
caller's variable, not as an optimization technique.

Hope this helps
Jay

"Dominiek" <sc******@realsoftware.be> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
Hey Armin,

Thanx for your reply

No, I'm not working with managed DirectX
No, I also didn't receive a StackOverflowException

I'm working with a lot of Structure's, which I pass ByVal from the upper
layer of my program. I just now changed all the passes ByVal to ByRef, and
now it seems to be working (for the moment). However, I think this issue
will resurface when the program increases in size.

I will follow your suggestion and forward this to the proposed newsgroups
Thnax
Dominiek

"Armin Zingler" <az*******@freenet.de> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl...
"Dominiek" <sc******@realsoftware.be> schrieb
during the developement of my program, while progressively writing
more and more code, the callstack of my program gets deeper and
deeper (7 levels). Then, all of a sudden, when calling a Sub with 2
parameters, a Hashtable(19 items) and a ArrayList(9 items), the value
of these variables is gone, the debugger reports the value as
{length=error: cannot obtain value}.

Passing them ByRef does not seem to solve the problem. IMHO, this
seems to be a problem with the stacksize.
7 levels is for sure not a problem with the stack size - unless you've got really many local variables. Apart from this, you should get a
StackOverflowException.

I also had this problem, but *only* when using certain functions in the
managed DirectX assemblies. It's been forwarded as a bug to the dev team. I
guess you are not using managed DirectX? If you don't use it, sorry, I

don't
have an explanation. You could narrow the problem down to as few lines

as possible and post it to microsoft.public.vsnet.ide or
microsoft.public.vsnet.debugging
--
Armin


Nov 20 '05 #5
Thanx to All

Will start to convert my structs into Classes


"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:eM**************@TK2MSFTNGP10.phx.gbl...
Dominiek,
In addition to Fergus's comments

Unless you specifically need structures, convert them to Classes!

Per the .NET Design Guidelines for Class Library Developers.

http://msdn.microsoft.com/library/de...guidelines.asp
Structures should:
- act like primitive types
- have an instance size under 16 bytes
- are immutable
- value semantics are desirable

Basically if your structure has more than 4 fields, you should seriously
consider using a class instead of a structure. As classes exist on the heap and a reference to the class is passed as the ByVal parameter, where as
structures exist on the stack and a copy of the structure is passed as a
ByVal parameter.

You should reserve ByRef parameters for when you actually need to modify the caller's variable, not as an optimization technique.

Hope this helps
Jay

"Dominiek" <sc******@realsoftware.be> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
Hey Armin,

Thanx for your reply

No, I'm not working with managed DirectX
No, I also didn't receive a StackOverflowException

I'm working with a lot of Structure's, which I pass ByVal from the upper
layer of my program. I just now changed all the passes ByVal to ByRef, and
now it seems to be working (for the moment). However, I think this issue
will resurface when the program increases in size.

I will follow your suggestion and forward this to the proposed newsgroups

Thnax
Dominiek

"Armin Zingler" <az*******@freenet.de> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl...
"Dominiek" <sc******@realsoftware.be> schrieb
> during the developement of my program, while progressively writing
> more and more code, the callstack of my program gets deeper and
> deeper (7 levels). Then, all of a sudden, when calling a Sub with 2
> parameters, a Hashtable(19 items) and a ArrayList(9 items), the value > of these variables is gone, the debugger reports the value as
> {length=error: cannot obtain value}.
>
> Passing them ByRef does not seem to solve the problem. IMHO, this
> seems to be a problem with the stacksize.

7 levels is for sure not a problem with the stack size - unless you've

got really many local variables. Apart from this, you should get a
StackOverflowException.

I also had this problem, but *only* when using certain functions in the managed DirectX assemblies. It's been forwarded as a bug to the dev team.
I
guess you are not using managed DirectX? If you don't use it, sorry, I

don't
have an explanation. You could narrow the problem down to as few lines

as possible and post it to microsoft.public.vsnet.ide or
microsoft.public.vsnet.debugging
--
Armin



Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brian Rivet | last post by:
------=_NextPart_000_0006_01C346FF.008E0CA0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi I'm new to MySql and I'm trying to set up a database table, and I...
0
by: Brian Rivet | last post by:
------=_NextPart_000_000E_01C34700.FE251100 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sorry, I'm a little new at this, here's the statement: CREATE TABLE...
1
by: John Mason | last post by:
Hi, I have developed an asp.net application that uses forms authentication. I have a local install and a remotely hosted install of the application. Intermittently the remote application falls...
2
by: manmit.walia | last post by:
Hello All and Thank You for your time, I am stuck on this exception handleing error. The problem is that when I run my application the application works perfect but sometimes, I get this error. I...
0
by: mcskf | last post by:
Hi, We develop a web based app in VB.Net 1.1. We use an conrol class for holding user's variables. The control process is created when the session created. In the control class we have many...
0
by: SYED HANIF | last post by:
A couple of days ago, my hosting provider upgraded the .Net framework to .Net 1.1 SP1. Since then I am experincing strange errors: some of the aspx pages suddenly an exception on the initial...
4
by: Garimella | last post by:
Hi When I'm trying to write data to a file from a custom variable(contains group of string items) it is giving me Runtime Error 59: bad record length. Put #1, , ee_rec20 --this is the line...
1
by: sanghamitra das | last post by:
We have developed a web application in which we are using login user(as a array structure) in session variable using HttpContext for some purpose. The session is availabe in the same project...
2
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
How do I validate that there are xx number of bytes data after a given spot. Here is an example; 2008/04/24 19:16:50 ARES_EINDICATION 010.050.082.108 117.3.01 (1d61) RX 68 bytes 1D 61...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.