469,908 Members | 2,041 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,908 developers. It's quick & easy.

referrring to a vb.net-declared namespace from c# class

SC
i have 2 separate projects:

1) Project A: Class library, written in VB.NET; It's namespace is
explicitly defined in the code like:

Namespace MyCompany.Project.ClassesA
....
End Namespace

2) Project B: Classes written in C#. It looks like:

using MyCompany.Project.ClassesA; <-----------ERROR

namespace MyCompany.Project.ClassesB {
....
}

The problem is that I get an error message:

The type or namespace name 'ClassesA' does not exist in the class or
namespace MyCompany.Project' (are you missing an assembly reference?)

I've referenced it in my References but for some reason the compiler
seems to get confused when my namespaces have "."!!!

Has anyone had this problem? I've even created a project C in VB.NET
to reference ClassesA and it's worked out fine. Just when the caller
is in C# do i have this issue.

HELP!!!

Thanks!
Nov 16 '05 #1
3 1314
In article <1c*************************@posting.google.com> ,
sc***@hotmail.com says...
i have 2 separate projects:

1) Project A: Class library, written in VB.NET; It's namespace is
explicitly defined in the code like:

Namespace MyCompany.Project.ClassesA
...
End Namespace

2) Project B: Classes written in C#. It looks like:

using MyCompany.Project.ClassesA; <-----------ERROR

namespace MyCompany.Project.ClassesB {
...
}

The problem is that I get an error message:

The type or namespace name 'ClassesA' does not exist in the class or
namespace MyCompany.Project' (are you missing an assembly reference?)

I've referenced it in my References but for some reason the compiler
seems to get confused when my namespaces have "."!!!

Has anyone had this problem? I've even created a project C in VB.NET
to reference ClassesA and it's worked out fine. Just when the caller
is in C# do i have this issue.


Try using ILDASM to view the namespace in the VB.NET assembly. VB.NET
projects have a "default namespace" that is appended to the namespaces
declared in code. It makes it confusing to find the "true" fully
qualified name.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 16 '05 #2
SC,

I think that you might not have added the reference correctly. I
created a VB class library with the namespace that you specified
("MyCompany.Project.ClassesA"), and then I created a Windows Application in
C#, using the other namespace ("MyCompany.Project.ClassesB") and it compiled
just fine.

Are you sure that you set the reference correctly to the assembly
containing the classes from the first namespace?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SC" <sc***@hotmail.com> wrote in message
news:1c*************************@posting.google.co m...
i have 2 separate projects:

1) Project A: Class library, written in VB.NET; It's namespace is
explicitly defined in the code like:

Namespace MyCompany.Project.ClassesA
...
End Namespace

2) Project B: Classes written in C#. It looks like:

using MyCompany.Project.ClassesA; <-----------ERROR

namespace MyCompany.Project.ClassesB {
...
}

The problem is that I get an error message:

The type or namespace name 'ClassesA' does not exist in the class or
namespace MyCompany.Project' (are you missing an assembly reference?)

I've referenced it in my References but for some reason the compiler
seems to get confused when my namespaces have "."!!!

Has anyone had this problem? I've even created a project C in VB.NET
to reference ClassesA and it's worked out fine. Just when the caller
is in C# do i have this issue.

HELP!!!

Thanks!

Nov 16 '05 #3
VS.NET deals with VB a little differently. In the properties for the
project (common properties -> General), you will see a root namespace field.
By default it is the name of the project.

This means, that whatever other namespaces you defined, they will be placed
inside this namespace.

So you need to blank this out, then there is no root namespace, and it will
generate the correct namespaces.

You can use the object browser to see exactly what namespaces are available
in your project,.

"SC" <sc***@hotmail.com> wrote in message
news:1c*************************@posting.google.co m...
i have 2 separate projects:

1) Project A: Class library, written in VB.NET; It's namespace is
explicitly defined in the code like:

Namespace MyCompany.Project.ClassesA
...
End Namespace

2) Project B: Classes written in C#. It looks like:

using MyCompany.Project.ClassesA; <-----------ERROR

namespace MyCompany.Project.ClassesB {
...
}

The problem is that I get an error message:

The type or namespace name 'ClassesA' does not exist in the class or
namespace MyCompany.Project' (are you missing an assembly reference?)

I've referenced it in my References but for some reason the compiler
seems to get confused when my namespaces have "."!!!

Has anyone had this problem? I've even created a project C in VB.NET
to reference ClassesA and it's worked out fine. Just when the caller
is in C# do i have this issue.

HELP!!!

Thanks!

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by lawrence | last post: by
1 post views Thread by Novice | last post: by
3 posts views Thread by hussein | last post: by
9 posts views Thread by Bob | last post: by
16 posts views Thread by Nathan Sokalski | last post: by
13 posts views Thread by Kenneth Windish | last post: by
13 posts views Thread by Steve H. | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.