473,624 Members | 2,290 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.L evel3.myVBClass "

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

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

If I change the namespace path slightly for C#, like making it
"LevelXXX.Level 2.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 1787
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@TKelle her-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 misunderstandin g,
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
2228
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 some of these master complex and simple types. This I believe will assist me in transforming between the master schema and the other smaller schemas that contain a subset of the elements in the master schema. I understand that I can import an...
17
3497
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 using std::cin; using std::cout;
5
4268
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 function or a property that returns a class from a different namespace? For example, lets say I have a root namespace called ACME for my class library project. Under the root namespace are classes such as Individual, Address, etc. I also...
25
1897
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
2925
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 running into few issues that I’m sure someone on this forum will be able to help m understand quickly. I started out with a traditional “Hello World” program, again, my firs C# programs. I was surprised to see how the System namespace wa...
8
9085
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 another class. i can see the properties of the first class and the namespace of the second (inner class) but can't see the properties of the 2nd....
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 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"
1
10955
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 'IFX170_TDBN.xsd'. combinedXSD: <xsd:schema xmlns:TDBN="http://www.tdbanknorth.com/WebServices" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:IFXTDBN="http://www.tdbanknorth.com/IFX170_TDBN" xmlns:IFX="http://www.tdbanknorth.com/IFX170_XSD"...
1
4121
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 similar structure to what OldBirdman suggested in my previous post, but I'm a bit stuck. Here is what I've set up: tbl_Orders Order_Number Order_Date
0
8177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8488
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7170
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4084
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1793
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.