Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't my namespace recognise my other namespaces?

Status
Not open for further replies.

starseyer

Programmer
Jun 6, 2005
5
US
I have three custom namespaces, two of which I'm attempting to import into the other with "using."

<code>
using System;
using InvoiceClasses;
using PlanClasses;

namespace SubaccountClasses
{
/// <summary>
/// Description of Subaccount.
/// </summary>
public abstract class Subaccount
{
private string _subaccountNumber;
private string _comments;
private string _notes;
private string _city;
</code>

SO why do I get an error that InvoiceClasses and Plan cannot be found? I've used InvoiceClasses sucessfully in an aspx file already. All namespaces are in the same directory.

Thanks for any help!
 
Are you sure that you set the other files/projects are dependencies and references? (I had that problem today.)

Good Luck
 
I hate to display my ignorance here, but I'm not sure I know what you mean. You may have to spell it out, as I'm a beginner.

I need to create objects in a class in one namespace of a class that is defined in another one of my namespaces. Is this the sort of dependency you are taking about, or do you mean something else?
 
Open your Solution Explorer pane, expand the project, right-click on "References" and select "Add Reference". Find your other projects under the "Projects" pane.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Oh, here is the source of the confusion. I don't have Visual Studio and my files are not put together in a project.

So what should I do now?
 
If you're using csc.exe, use the /reference switch.

If you're using SharpDevelop, it has a way to establish references in it's combines -- I think it's similar to how Visual Studio does it, but I don't have a copy handy to check.

If you're using another tool, check it's documentation.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
are you compiling from the command line? if so are you referenceing the library /r:planClasses.dll
Marty
 
I've been compiling like
csc /t:library PlanClasses.cs

So I need to use the /r: switch then . . .

Thanks! I'll give that a try.
 
Your are making a library out of PlanClasses.cs the /t:library will make it a dll which is correct.
the /r is for referencing the dll when you are going to use
it.
csc /? for the docs
Marty
 
Got it. I remember seeing the /r switch when I was looking up how to compile from the command line, but I not sure what it was used for.

Thanks a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top