variable problems - Help

  • Thread starter Thread starter AMP
  • Start date Start date
A

AMP

Hello,
I have been working on a project with no problems for a few months
now.
All of a sudden I am getting errors when trying to declare a
variable.
I Have the following code:
string DataToParse = "";
string Ra = "";
DataToParse = File.ReadAllText(UploadedFileName);
Ra = File.ReadAllText(UploadedFileName);

The first variable "DataToParse" I have been using for months now.No
problem
The second one, Ra, I get "The name 'Ra' does not exist in the
current
context"
I have tried to rename it, I tried just setting it to a random
string.
(many times)
I even tried shutting down the computer.
When I put my curser over it when not debugging it shows as a local
variable, but during debugging it doesnt show anything when i put the
cursor over it.
This is freaking me out.
What can be the problem?
Thanks
Mike
 
All of a sudden I am getting errors when trying to declare a
variable.

This statement implies a compiler error.

But this statement:
[...]
When I put my curser over it when not debugging it shows as a local
variable, but during debugging it doesnt show anything when i put the
cursor over it.

Implies that you can in fact compile the code.

So, the first thing is for you to be more clear in your question.

Now, assuming the first implication is incorrect and all you're really
seeing is a problem while debugging, my first thought is that you may be
debugging an optimized build (i.e. "Release" version), in which the
variable has been optimized away. I've never run into this with C#, so I
can't say for sure that this is a real possibility. But I've seen it in
other environments, and it seems like the most likely explanation for what
I _think_ you're describing.

If that doesn't address your question, I suggest doing both of two things:
try to state your issue more clearly, and create a concise-but-complete
sample of code that reliably demonstrates the problem (including, of
course, clear instructions as to what to do with the sample).

"Concise-but-complete" means we can compile the code without any
addditional effort ("complete") and there's nothing in the code that's not
absolutely required for demonstrating the issue ("concise").

Pete
 
On Mar 10, 1:21 pm, "Peter Duniho" <[email protected]>
wrote:

Pete,
Thanks,
It was because I was in a Release version. I changed it to Debug and
it works.
Thanks Again,
Mike
All of a sudden I am getting errors when trying to declare a
variable.

This statement implies a compiler error.

But this statement:
[...]
When I put my curser over it when not debugging it shows as a local
variable, but during debugging it doesnt show anything when i put the
cursor over it.

Implies that you can in fact compile the code.

So, the first thing is for you to be more clear in your question.

Now, assuming the first implication is incorrect and all you're really  
seeing is a problem while debugging, my first thought is that you may be  
debugging an optimized build (i.e. "Release" version), in which the  
variable has been optimized away.  I've never run into this with C#, so I  
can't say for sure that this is a real possibility.  But I've seen it in 
other environments, and it seems like the most likely explanation for what 
I _think_ you're describing.

If that doesn't address your question, I suggest doing both of two things: 
try to state your issue more clearly, and create a concise-but-complete  
sample of code that reliably demonstrates the problem (including, of  
course, clear instructions as to what to do with the sample).

"Concise-but-complete" means we can compile the code without any  
addditional effort ("complete") and there's nothing in the code that's not 
absolutely required for demonstrating the issue ("concise").

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top