473,507 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Same namespace structure across multiple languages?

Question: Can namespaces be shared by several projects within a
solution, if those projects use different languages?

We wrote some db code in C#, and some biz logic in VB.NET. We brought
both projects within the same solution. We used identical namespace
commands for both: "Level1.Level2.Level3" Both the C# and VB.NET
classes live off "Level3."

In other VB classes, I can do this...
"Dim x as Level1.Level2.Level3.myVBClass"

In other C# classes we can do this...
"Level1.Level2.Level3.myCSClass x"

But from VB.NET we can't do this...
"Dim x as Level1.Level2.Level3.myCSClass"

If I change the namespace path slightly for C#, like making it
"LevelXXX.Level2.Level3" -- then suddenly I can see it from VB.NET.

It tells me we can't share namespaces, which seems really really weird.
Why have a programming system where (1) you can use multiple languages,
yay! - and (2) you can use namespaces to provide clean structure, yay!
-- but you can't do both at the same time?

- Tom
Jul 21 '05 #1
3 1774
I figured it out. There are two factors. One is that you need to
right-click on both projects, pick Properties, and blank out the field
marked "Root Namespace." If you don't, then that value is quietly
prepended to whatever namespace you put in the code.

The other thing is, only one project can have a reference to the other.
If the VB has a reference to the C# one, then VB can see objects from
both -- but the C# can only see its own. Or vice versa. But you can
never get both to see both, because that would require each to have a
reference to the other -- a circular reference. So the best you can do
is give one a reference to the other, and it works there.

The upshot is, I got my code to work the way I wanted.

- Tom
========================================
Tom Kelleher Consulting, Inc.
Kelleher@TKelleher-removethispart-.com
========================================

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #2
Hi Tom,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you cannot reference a C# class from a
VB.NET project under same namespace. If there is any misunderstanding,
please feel free to let me know.

Based on my research, this issue occurs becasue there is a default root
namespace set in the VB.NET project. To remove this root namespace, please
use the following steps:

1. In the Solution Explorer, right click the VB.NET project and select
properties from the popup menu.
2. Select Common Properties/General from the left pane.
3. Clear the text in the Root namespace textbox.
4. Click OK.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #3
Hi Tom,

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2212
by: Steve George | last post by:
Hi, I have a scenario where I have a master schema that defines a number of complex and simple types. I then have a number of other schemas (with different namespaces) where I would like to reuse...
17
3481
by: beliavsky | last post by:
Many of my C++ programs have the line using namespace std; but the "Accelerated C++" book of Koenig and Moo has many examples where the library names are included one at a time, for example ...
5
4252
by: Dave Slinn | last post by:
Any advice on how to organize my core class library project into sub-namespaces? What are the general rules of thumb regarding cross-namespace references? Can I have a class in namespace A have a...
25
1875
by: Daniel P. | last post by:
MS or anyone still claims that C# and VB.NET generate the exact same IL code? http://www.osnews.com/story.php?news_id=5602&page=3
9
2918
by: MDoyle | last post by:
Here is the easiest question you’ll get all day from a complete newbie. I installed Visual Studio on my laptop last night and have been tryin to write my very first C# programs this morning. I’m...
8
9077
by: Simon Edwards | last post by:
Something thats been bugging me for a while... how do you create a namespace that has many children (namespaces) I.e system.io.blah.blah Iv'e done it by creating a class which contains...
3
307
by: Tom Kelleher | last post by:
Question: Can namespaces be shared by several projects within a solution, if those projects use different languages? We wrote some db code in C#, and some biz logic in VB.NET. We brought both...
1
10935
by: leno | last post by:
Hi all, I'm having this problem when i combined multiple schema's into one. The error msg is below: Unable to load schema with target namespace 'http://www.tdbanknorth.com/IFX170_TDBN' from...
1
4109
ajhayes
by: ajhayes | last post by:
I posted a few weeks ago about trying to set up a way to order by unit number (http://bytes.com/topic/access/answers/864507-need-help-setting-up-table-structure-ordering-unit) I'm trying to use a...
0
7111
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.