473,666 Members | 2,058 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 1788
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
2231
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
3502
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
4269
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
1899
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
2926
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
9086
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
10956
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
8444
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
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
8869
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...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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,...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.