How to include the a User-Defined namespace (C#) defined in one project into the code of anopther project in VS 2003


I'm working in a ASP. NET web application that includes many different projects (using VS 2003).  As in VS 2003, each project is defined as a namespace.

Assumed that there is a project, i.e. a namespace, named NSPACE_1 in which I deifned a public class, named PCLASS_1_NS1, that in turn has a public method, named PMETHOD_1.

There is another project, i.e. namespce, named NSPACE_2. In one of the class of this namespace, there is a method where the code  needs to call the above public method PMETHOD_1.

I don't know how to include the NSPACE_1 in the code so that the public methods of this namespace is introduced to the NSPACE_2. I've tried some way like "using NSPACE_1" at the top of .cs file of the web form but the compiler complains about this.

If you've some idea about this, please help.

Thank you very much,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

have you added the NSPACE_1 namespace file to your project as a refernce if its compiled as a dll or the .cs or .vb file containing the namespace
somitsAuthor Commented:
Hi tpwells:

Thanks for your comments.
What do you mean the "NSPACE_1 namespace file"? Do you mean the .cs file of the class PCLASS_1_NS1, in which the public method PMETHOD_1 is defined?


yes, if the file is not compiled into an assembly then you will need to include the file in your project
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

somitsAuthor Commented:
Hi tpwells

How can I include the .cs file int a project.
Do I need to copy the physical file into the folder of the project? OR only adding some text into some system file of the project that indicates the path of the file?

Thanks a lot,

yes copy the file itself to your project directory and then right-click on your prject in the Solution Explorer and select "Add Existing..." then select and open the .cs file in your project directory
Hi somits

I don’t think that is the correct way to do it as you are duplicating the files.
Cause when you make changes to one file you will have to make changes everywhere you have copied the files

In our Company we do it in following way


Using NSPACE_1; for C#

Imports NSPACE_1; for

Also you have to specify the reference or else you will get following error

The type or namespace name NSPACE_1could not be found (are you missing a using directive or an assembly reference?)

To add reference perform following steps

1      Right Click on solution in solution explorer(Ctrl + W)
2      Select Add reference
3      Browse for the Dll of Nspace_1

It’s located in the bin\Debug folder where NSPACE_1 is complied
For vs2005 generally its
f you start by selecting default option then your dll will be mostly at this location

C:\Documents and Settings\Snehal\My Documents\Visual Studio 2005\Projects\ NSPACE_1

If you are still unable to find it search for NS*.Dll

4      now make object of PCLASS_1_NS1
5      and you will be able to access the methods of that class
6      Now make the object for that class and you will get the intellence feature

Also if you make the functions static then you don’t even need make new object
Directly use the classname.functions name

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.