How to connect two classes in a namespace?

K

K Viltersten

I have a solution with a project names
ProjA and ProjB. In ProjA i have a class
called ClassA. It contains a static,
public member MembA.

I'd like to read MembA when executing
code in class ClassB in the project
ProjB, but when i try the following, i
get nothing from Intellisense (and it
doesn't compile either).

ClassA.MembA = null;

The error is as follows.
"The type or namespace name 'ClassA' could
not be found (are you missing a using
directive or an assembly reference?)"

However, them being in the same namespace
mean that they know about eachother,
doesn't it?

Or is it required to reference projects
in the same namespace and the same solution?!
 
M

Marc Gravell

If they are different project, then a reference will be needed to see
the other type. Note that you should avoid circular references (A
references B and B references A) - in fact, the IDE won't let you do
this [you can do it at the command line if you try hard enough].

Marc
 
K

K Viltersten

If they are different project, then a reference will be needed to see the
other type.

When i tried adding the project as a
reference, i got a lot of errors about
XML files mentioned in ClassA.exe.manifest
but not being found. Any thoughts?
 
M

Marc Gravell

Not without more info - but the simplest answer here is to put the
shared types into a dll, and reference that dll from both projects.
References to exes are possibly, but aren't as well supported (VS2005
didn't support it at all IIRC).

Marc
 
K

K Viltersten

Hmm... It seems you're thinking "types" as
in "classes". However, the problem i ran
into was that the manifest file complained
about XML files (normal data, nothing
fancy) being not found.

I solved it by referencing the executble
directly, instead of the project but i'm
unsure if that's a good solution (or a
solution at all). This area isn't exactly
my forte.
 
P

Pavel Minaev

When i tried adding the project as a
reference, i got a lot of errors about
XML files mentioned in ClassA.exe.manifest
but not being found. Any thoughts?

Can you give the exact error message, please, along with the content
of the .manifest?
 
K

K Viltersten

If they are different project, then a
Can you give the exact error message,
please, along with the content of the
.manifest?

It was in swedish, so no, but it said that
the file ThisAndThat.XML mentioned in
ThatRunnable.exe.manifest couldn't be
located.

Right now, i referenced the EXE file hoping
that it's good enoough.
 

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