473,672 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compilation Error

Newbie using VC# Express.....

Part the First
========
Can some one tell me why Example 1 compiles and Example 2 does not...

Example 1
------------

using System;
namespace System.Data
{
partial class Console
{
public int GetHeight()
{
int i = System.Console. BufferHeight;
return i;
}
}
}

Example 2
------------

using System;
namespace System
{
partial class Console
{
public int GetHeight()
{
int i = System.Console. BufferHeight;
return i;
}
}
}

The error is: Error 2 'System.Console ' does not contain a definition for
'BufferHeight'

In fact I seem to be able to use any namespace except "System".

Part the Second
==========

Why does the following fail to compile...

using System;
using System.Data;
namespace ClassLibrary1
{
public class Class1 { }
}
namespace System.Data
{
public partial class DataGrid
{
public static void AnyCall(DataGri d pGrid)
{
DataGrid dg = new DataGrid();
BindingContext bc = dg.BindingConte xt; // this line generates
the errors
}
}
}

The errors are:

Error 1 The type or namespace name 'BindingContext ' could not be found (are
you missing a using directive or an assembly reference?)
Error 2 'ClassLibrary1. DataGrid' does not contain a definition for
'BindingContext '

So it can see a DataGrid, but not the properties of it.

It is obvious I do not understand namespaces / accessibility of references....

--
Paul Cotter
Dec 18 '05 #1
1 1688
Both of your problems stem from your creation of namespaces that you are
attempting to use. The using directive informs the compiler that you are
using members of the namespace indicated. When you create a new namespace of
the same name, the code scoped within that new namespace assumes that you
are referring to members of the namespace in which they are created. Since
the members being referenced are in the other namespace outside of that
namespace, having the same name, they do not exist in the current namespace
context, and are not found.

NameSpaces are a device for uniquely identifying members within those
namespaces. Think of a namespace as the "city" part of an address. The name
of the member is like the street address. Now, if you are in Chicago, and
someone says, "where is Broadway?" you simply point to the location of
Broadway in the city you are already in. But if you were outside of Chicago,
and someone said "Where is Broadway?" your first thought would be "Broadway
in what city?" It could be in Chicago, New York, or any of thousands of
cities having a street named "Broadway." Now, let's say you were back in
Chicago, and someone asked you "Where is BroadWay in New York City?" You
wouldn't have to be in New York to know what street they were referring to.
They gave you the NameSpace of the reference.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Paulustrio us" <msdn_whoisat_p aulcotter.com> wrote in message
news:C5******** *************** ***********@mic rosoft.com...
Newbie using VC# Express.....

Part the First
========
Can some one tell me why Example 1 compiles and Example 2 does not...

Example 1
------------

using System;
namespace System.Data
{
partial class Console
{
public int GetHeight()
{
int i = System.Console. BufferHeight;
return i;
}
}
}

Example 2
------------

using System;
namespace System
{
partial class Console
{
public int GetHeight()
{
int i = System.Console. BufferHeight;
return i;
}
}
}

The error is: Error 2 'System.Console ' does not contain a definition for
'BufferHeight'

In fact I seem to be able to use any namespace except "System".

Part the Second
==========

Why does the following fail to compile...

using System;
using System.Data;
namespace ClassLibrary1
{
public class Class1 { }
}
namespace System.Data
{
public partial class DataGrid
{
public static void AnyCall(DataGri d pGrid)
{
DataGrid dg = new DataGrid();
BindingContext bc = dg.BindingConte xt; // this line generates
the errors
}
}
}

The errors are:

Error 1 The type or namespace name 'BindingContext ' could not be found
(are
you missing a using directive or an assembly reference?)
Error 2 'ClassLibrary1. DataGrid' does not contain a definition for
'BindingContext '

So it can see a DataGrid, but not the properties of it.

It is obvious I do not understand namespaces / accessibility of
references....

--
Paul Cotter

Dec 18 '05 #2

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

Similar topics

4
2147
by: konf | last post by:
Hallo, I tried to compile PGSQL 7.4 and I got error (durring make): ar: command not found What is it? Whe I can found it? I have: $ uname -a SunOS ... 5.8 Generic_108528-03 sun4u sparc SUNW,UltraSPARC-IIi-cEngine
10
2349
by: Sune | last post by:
Hi, previously I used Eclipse CDT for compiling my files just to get started with C and leave C++ behind. Now it's time to get a little more serious so I've moved my files to a new workplace and begun to use GNU Autotools. I'm sorry to say I'm new to gcc as well :( Now I get the most ridiculous compile error which I'm unable to solve. Can someone, please, help me with this? gcc output together with the files mentioned in the gcc error...
6
2219
by: Joachim | last post by:
I made some project changes (which seems it doesn't help if I undo) which have created compilation error: " Server Error in '/PCSWebApp1' Application. -------------------------------------------------------------------------------- Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details
2
1801
by: James Zhuo | last post by:
Hi all I've been getting the following compilation error. I should explain the background of the project that i am taking over. This is a project that has been developed by someone else a while ago using dreamweaver, I am basically trying to migrate the project into a Visual Studio .NET environment before I start enhancing it. Any suggestions on where the source of error may be would be greatly appreciated.
0
1460
by: James Zhuo | last post by:
hi all I changed the name of the class LoginPage to a different name "LoginPageOne" But the same error gets generated with the Wiliam.Request.LoginPageOne. That pretty much leaves me clueless at this point. Please help Cheer
3
3343
by: Dan | last post by:
Hi, I have a problem using an aspx page with a Control on it. I get the following error message Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple places; using definition from 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\1f575646\ad3a161b\assembly\dl2\57ca505e\044565c0_f84fc401\Test1.DLL' The problem is that the control is defined in two different assemblies
6
2886
by: Plat | last post by:
I've Googled this for a while, to no avail. Hopefully someone can help me. Maybe I'm using the wrong terminology. Here's the scoop! Let's say I've got a simple *.ASPX page that has a syntax error. For example, broken.aspx might only contain the following line of code: <% Dim x as %> When I visit this page from my Web browser, I see all the helpful ASP.NET Server Error information, including:
3
8697
by: Robert | last post by:
I have a number of web projects converted from 1.1 to 2.0 in VS2005. I am methodically seeing the error below: The element 'compilation' has invalid child element 'compilers'. List of possible elements expected: 'assemblies, buildProviders, codeSubDirectories, expressionBuilders'. Here's what the web config looks like. The error doesn't cause any issues and according to the MSDN documentation this is valid. So why is VS2005
0
1737
by: Stimp | last post by:
I've created an aspx page called HistoryManage.aspx. The page works fine on my local machine but when I load it off the web I get the following strange error... Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
1
2806
by: BSand0764 | last post by:
I'm getting an error that I can't seem to resolve. When I compile the Functor related logic in a test program, the files compile and execute properly (see Listing #1). However, when I incorporate the same logic within my simulation, the class that implements the functor logic has problems compiling. I get the following errors: -- Building myTest.cpp --
0
8486
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8608
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8680
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.