473,386 Members | 1,799 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,386 software developers and data experts.

Static Crossover


I wrote two windows services that are slight variations on each other.

I changed the assembly name ( .exe ) and the namespace within each other.

Both have some static methods that share the same name.
I am seeing some evidence that there may be memory crossover -- where
one assembly is accesing resources defined in a same named method of the
other.
Is that possible? Are static members shared across namespaces?

Nov 9 '05 #1
2 1714
John,

Short form, no, it is not possible.

When you have a static member in two different namespaces, that means
that they are each attached to two different types. Even if the types are
the same name, code, etc, etc, if the namespaces are different, then they
are two different types. The static fields for one are not going to be the
same as the static fields for another.

Additionally, the CLR makes sure that the scope of static fields is the
app domain you are running in, of which there can be multiple ones in a
process. That leads us to the fact that static field values are not shared
among the same type in separate processes.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John A. Bailo" <ja*****@texeme.com> wrote in message
news:8u********************@speakeasy.net...

I wrote two windows services that are slight variations on each other.

I changed the assembly name ( .exe ) and the namespace within each other.

Both have some static methods that share the same name.
I am seeing some evidence that there may be memory crossover -- where one
assembly is accesing resources defined in a same named method of the
other.
Is that possible? Are static members shared across namespaces?

Nov 9 '05 #2

Thanks!

False alarm anyway, I was referencing the same filename for logging in
two of the supporting classes so it looked like crossover, but it wasn't.
Nicholas Paldino [.NET/C# MVP] wrote:
John,

Short form, no, it is not possible.

When you have a static member in two different namespaces, that means
that they are each attached to two different types. Even if the types are
the same name, code, etc, etc, if the namespaces are different, then they
are two different types. The static fields for one are not going to be the
same as the static fields for another.

Additionally, the CLR makes sure that the scope of static fields is the
app domain you are running in, of which there can be multiple ones in a
process. That leads us to the fact that static field values are not shared
among the same type in separate processes.

Hope this helps.

Nov 10 '05 #3

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

Similar topics

8
by: Scott J. McCaughrin | last post by:
The following program compiles fine but elicits this message from the linker: "undefined reference to VarArray::funct" and thus fails. It seems to behave as if the static data-member:...
15
by: Samee Zahur | last post by:
Question: How do friend functions and static member functions differ in terms of functionality? I mean, neither necessarily needs an object of the class to be created before they are called and...
5
by: Mountain Bikn' Guy | last post by:
How would I do this? public sealed class UtilityClass { public static MyObject Object1;//see note below about importance of static object names in this class public static MyObject Object2;...
3
by: Mauzi | last post by:
hi, this may sound odd and noob like, but what is the 'big' difference between static and non-static funcitons ? is there any performace differnce? what is the best way to use them ? thnx ...
2
by: John A. Bailo | last post by:
I wrote two windows services that are slight variations on each other. I changed the assembly name ( .exe ) and the namespace within each other. Both have some static methods that share the...
55
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
14
by: Jess | last post by:
Hello, I learned that there are five kinds of static objects, namely 1. global objects 2. object defined in namespace scope 3. object declared static instead classes 4. objects declared...
2
by: jrmemon007 | last post by:
I have 2 computers, one is a acer laptop and the other is a desktop. i want to connect the computers without a router, and only using the crossover cable. After some hardwork the laptop establishes a...
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: 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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.