The type or namespace name 'MyClass' could not be found (are you missing a using directive or an ass

C

carqs123

What is the procedure for using a class defined in the same solution
but in another project?
The language I am using is c-sharp.

I have a solution with two projects in it. A c-sharp program in
project1 uses MyClass, which is defined in project2. In the solution
properties I set project1 to depend on project2.

I keep getting the "type or namespace name 'MyClass' could not be
found" error.

I defined a namespace in project2 and made sure MyClass was encompassed
by this namespace. Then I put the "using namespace" statement in the
project1 program.
This did not help.

Any suggestions?
 
M

Matt

carqs123 said:
What is the procedure for using a class defined in the same solution
but in another project?
The language I am using is c-sharp.

I have a solution with two projects in it. A c-sharp program in
project1 uses MyClass, which is defined in project2. In the solution
properties I set project1 to depend on project2.

I keep getting the "type or namespace name 'MyClass' could not be
found" error.

I defined a namespace in project2 and made sure MyClass was encompassed
by this namespace. Then I put the "using namespace" statement in the
project1 program.
This did not help.

Any suggestions?

I'm not entirely sure what you are trying to say here, but I think your
answer is to add a reference to the other project. Fully qualifying
your
calls to the secondary namespace class (i.e. Namespace2.MyClass2)
wouldn't hurt either :)

Matt
 
C

carqs123

Matt said:
I'm not entirely sure what you are trying to say here, but I think your
answer is to add a reference to the other project. Fully qualifying
your
calls to the secondary namespace class (i.e. Namespace2.MyClass2)
wouldn't hurt either :)

Right. How does one do that?

I tried using Namespace2.MyClass2 in using statement and variable
definitions.
I get... "type or namespace Namespace2 could not be found..."

How does one "add a reference" ?
 
M

Matt

carqs123 said:
Right. How does one do that?

I tried using Namespace2.MyClass2 in using statement and variable
definitions.
I get... "type or namespace Namespace2 could not be found..."

How does one "add a reference" ?

In the solution explorer view, you will see a list of references. Right
click on it
and you'll see "add". Just use that. The references are near the top,
right below
the solution name.


Matt
 
C

carqs123

OK OK, figured it out. Right mouse click on the references folder in
the solutions explorer. Add Reference. Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top