Connecting Tech Pros Worldwide Forums | Help | Site Map

Trouble with Identically-Named Variables

Robert Thompson
Guest
 
Posts: n/a
#1: Feb 27 '06
Hello,

I'm running into a strange problem involving identically-named
variables in multiple projects. I'm using Visual Studio 2005, and have
a solution with three projects under it. Two of the three projects
have variables with the same name. These variables are both global to
their class. The problem is that when variable "foo" in Project 1 is
set to "bar," variable foo in Project 2 also immediately takes on value
bar. This occurs regardless of whether foo is references simply as
foo, or as this.foo.

I can't figure out how this is occuring, as the projects do not contain
references to each other (they are completely independent projects),
but the debugger shows that this is the case and when running without
debugging I get strange behavior that I suspect is caused by this.
It's a simple matter to rename one project's variable for now, but I
would like a more permanent solution.

Thanks for your help!


Michael C
Guest
 
Posts: n/a
#2: Feb 27 '06

re: Trouble with Identically-Named Variables


"Robert Thompson" <rthomp268902@hotmail.com> wrote in message[color=blue]
> I can't figure out how this is occuring, as the projects do not contain
> references to each other (they are completely independent projects),
> but the debugger shows that this is the case and when running without
> debugging I get strange behavior that I suspect is caused by this.
> It's a simple matter to rename one project's variable for now, but I
> would like a more permanent solution.[/color]

Does renaming help? Are you using any of the variables in API calls? Are
these 2 projects running in the same process?

Michael


Mark R. Dawson
Guest
 
Posts: n/a
#3: Feb 27 '06

re: Trouble with Identically-Named Variables


Hi Robert,
can you post a small code example which exhibits the problem, there could
be many reasons for what you are seeing and an example would make it clearer.

Thanks
Mark
http://www.markdawson.org


"Robert Thompson" wrote:
[color=blue]
> Hello,
>
> I'm running into a strange problem involving identically-named
> variables in multiple projects. I'm using Visual Studio 2005, and have
> a solution with three projects under it. Two of the three projects
> have variables with the same name. These variables are both global to
> their class. The problem is that when variable "foo" in Project 1 is
> set to "bar," variable foo in Project 2 also immediately takes on value
> bar. This occurs regardless of whether foo is references simply as
> foo, or as this.foo.
>
> I can't figure out how this is occuring, as the projects do not contain
> references to each other (they are completely independent projects),
> but the debugger shows that this is the case and when running without
> debugging I get strange behavior that I suspect is caused by this.
> It's a simple matter to rename one project's variable for now, but I
> would like a more permanent solution.
>
> Thanks for your help!
>
>[/color]
Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#4: Feb 27 '06

re: Trouble with Identically-Named Variables


Robert Thompson wrote:[color=blue]
> I'm running into a strange problem involving identically-named
> variables in multiple projects. I'm using Visual Studio 2005, and have
> a solution with three projects under it. Two of the three projects
> have variables with the same name. These variables are both global to
> their class. The problem is that when variable "foo" in Project 1 is
> set to "bar," variable foo in Project 2 also immediately takes on value
> bar. This occurs regardless of whether foo is references simply as
> foo, or as this.foo.
>
> I can't figure out how this is occuring, as the projects do not contain
> references to each other (they are completely independent projects),
> but the debugger shows that this is the case and when running without
> debugging I get strange behavior that I suspect is caused by this.
> It's a simple matter to rename one project's variable for now, but I
> would like a more permanent solution.[/color]

It sounds unlikely to be happening as you have described - I suspect
you have debugger issues.

As Mark said, if you could post a short but complete program which
demonstrates the problem, that would help enormously.

Jon

Closed Thread


Similar C# / C Sharp bytes