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

Fully qualified names

fc2
Hi

I have a problem with fully qualified names. According to the C#
language specification:

"Every namespace and type has a fully qualified name, which uniquely
identifies the namespace or type amongst all others."

However, I have problems compiling the following:

namespace Foo.System.Bar
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("Hello, World");
}
}
}

With compiler output:

"The type or namespace name 'Console' does not exist in the namespace
'Foo.System' (are you missing an assembly reference?)"

Changing the namespace name from "Foo.System.Bar" to "Foo.Sys.Bar"
solves
the problem so I guess it has to do with the rules for resolving types
(they are rather unclear in the language spec.).

The bottom line is that I'm unable to access System.Console in my
program
even when using the fully qualified name. I wonder if this is a
compiler
bug or expected behaviour?
/fc2

Nov 16 '05 #1
5 2986
Try this instead:

using System;

namespace Foo.System.Bar
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World");
}
}
}

/Joakim

fc2 wrote:
Hi

I have a problem with fully qualified names. According to the C#
language specification:

"Every namespace and type has a fully qualified name, which uniquely
identifies the namespace or type amongst all others."

However, I have problems compiling the following:

namespace Foo.System.Bar
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("Hello, World");
}
}
}

With compiler output:

"The type or namespace name 'Console' does not exist in the namespace
'Foo.System' (are you missing an assembly reference?)"

Changing the namespace name from "Foo.System.Bar" to "Foo.Sys.Bar"
solves
the problem so I guess it has to do with the rules for resolving types
(they are rather unclear in the language spec.).

The bottom line is that I'm unable to access System.Console in my
program
even when using the fully qualified name. I wonder if this is a
compiler
bug or expected behaviour?
/fc2

Nov 16 '05 #2
fc2
Ok, but still I ought to always be able to use the fully qualified name
(to explicitly state my intentions).

The situation is further complicated by the fact the MS VS .NET
generates some classes behind my back (for accessing resources and for
settings). The generated code uses fully qualified names to system
libraries and this code won't compile either (unless i change it
manually which is a no-no) since it also tries to find system classes
inside Foo (probably because they are part of the same compilation
unit).
/fc2

Nov 16 '05 #3
This is addressed in C# 2.0 - you can write
global::System.Console.WriteLine().

HTH,
Stefan

"fc2" <fc*@tytte.dk> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
Ok, but still I ought to always be able to use the fully qualified name
(to explicitly state my intentions).

The situation is further complicated by the fact the MS VS .NET
generates some classes behind my back (for accessing resources and for
settings). The generated code uses fully qualified names to system
libraries and this code won't compile either (unless i change it
manually which is a no-no) since it also tries to find system classes
inside Foo (probably because they are part of the same compilation
unit).
/fc2

Nov 16 '05 #4
fc2
Yes, but it doesn't solve the problem with the autogenerated code.

Nov 16 '05 #5
OK, I hate to recommend this, but...

Can you change your namespace, in your app, so that the word "System" is not
part of it?

I guess my thinking is this: we work around "reserved words" all the time.
You ran into one in a place you didn't expect, but that doesn't mean you
can't work around it in the same way. I'm not making excuses... perhaps my
perspective is just different.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"fc2" <fc*@tytte.dk> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
Ok, but still I ought to always be able to use the fully qualified name
(to explicitly state my intentions).

The situation is further complicated by the fact the MS VS .NET
generates some classes behind my back (for accessing resources and for
settings). The generated code uses fully qualified names to system
libraries and this code won't compile either (unless i change it
manually which is a no-no) since it also tries to find system classes
inside Foo (probably because they are part of the same compilation
unit).
/fc2

Nov 16 '05 #6

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

Similar topics

1
by: Stefan | last post by:
I'm installing Oracle 9ias Release 2 on Windows 2000 Advanced Server. The installation instructions say to specify a fully qualified host name for the machine. What is the definition of fully...
2
by: Gravy | last post by:
Hi Is there an easy way to decode type names from a config file. For example I have the following element in my config file: <MyElement type = "myassembly, myclass" /> I want to get the...
4
by: Jim Garrison | last post by:
I know how to use the name() function to access the name of the current node. How do I get the 'fully qualified' name, consisting of the path from the root to the current node? I.e. <a> <b>...
4
by: Aashish Patil | last post by:
Hello, Is it possible to obtain the fully qualified name of a class in c#. What I am looking for is something analogous to Box.class.getName() that exists in Java. Its possible to get this by...
1
by: Erland | last post by:
Hi all, As per my understanding in order to load an assembly using Assembly.Load() you have to provide fully qualified name of the assembly you are trying to load e.g. Assembly...
8
by: fireball | last post by:
I wihsh to discuss whether to use fully qualified names: ..object of objects to operate (create, query..) on is good or not? If someone change order of sql code blocks in my script - this may...
3
by: surej | last post by:
hello, please help me how to configure a DNS server in a LAN network using fully qualified domain names.I am using CENTOS distro... redhat configuration will also do.I am having two ISP.should i...
4
by: Vivek | last post by:
Hi, Generally we work with the 2 part qualified table names in db2 i.e. <schema>. <table name> Is there a more fully qualified table name ? I've seen that a select from <database...
2
by: winkerbean | last post by:
Given the following: class A { class B { A::B( A::B const & ); }; };
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
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
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.