473,408 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Namespace confusion

Using VS 2008, I have a project that uses the dll from another project.

The Namespace is MyFunctions, with a class of DbObject. The beginning of
the code is:
***************************
Imports System
Imports System.Data
Imports System.Data.SqlClient

Namespace MyFunctions

Public Class DbObject
**************************

The Project, class vb file, and dll are called MyFunctions.

In my code, I have to:

Imports MyFunctions.MyFunctions

To get this to work:

Dim myDbObject As New DbObject("a test")
Why don't I need:

Imports MyFunctions

How would I change the project to allow me to use only the Namespace?

Thanks,

Tom
Sep 14 '08 #1
8 1051
On Sep 14, 8:08*am, "tshad" <t...@dslextreme.comwrote:
Using VS 2008, I have a project that uses the dll from another project.

The Namespace is MyFunctions, with a class of DbObject. *The beginning of
the code is:
***************************
Imports System
Imports System.Data
Imports System.Data.SqlClient

Namespace MyFunctions

* Public Class DbObject
**************************

The Project, class vb file, and dll are called MyFunctions.

In my code, I have to:

Imports MyFunctions.MyFunctions

To get this to work:

* * Dim myDbObject As New DbObject("a test")

Why don't I need:

Imports MyFunctions
When you use "MyFunctions.MyFunctions", it sounds like you have 2
nested namespaces with the same name which is not necessary for
readablity. If DbObject is located under MyFunctions, you'd better
remove second MyFunctions namespace and revise your assembly as:

Imports MyFunctions

Dim myDbObject As New DbObject("a test")
'.....Here actually it's same with without "Imports"
' Dim myDbObject As New MyFunctions.DbObject("a test")

HTH,

Onur Güzel

Sep 14 '08 #2
kimiraikkonen wrote:
On Sep 14, 8:08 am, "tshad" <t...@dslextreme.comwrote:
>Using VS 2008, I have a project that uses the dll from another
project.

The Namespace is MyFunctions, with a class of DbObject. The
beginning of the code is:
***************************
Imports System
Imports System.Data
Imports System.Data.SqlClient

Namespace MyFunctions

Public Class DbObject
**************************

The Project, class vb file, and dll are called MyFunctions.

In my code, I have to:

Imports MyFunctions.MyFunctions

To get this to work:

Dim myDbObject As New DbObject("a test")

Why don't I need:

Imports MyFunctions

When you use "MyFunctions.MyFunctions", it sounds like you have 2
nested namespaces with the same name which is not necessary for
readablity. If DbObject is located under MyFunctions, you'd better
remove second MyFunctions namespace and revise your assembly as:
I seem to have this but not sure why.

When I created the Class Library project, it created 2 folders :

MyFunctions <----Folder
Myfunctions <--- Folder
MyFunctions.sln
MyFunction.suo

VS puts the code files in the 2nd MyFunctions folder.

My files are set up as I show (with one namespace).

In my web site, I referenced the .dll from this project and it is the one
that thinks there are 2 namespaces. Imports MyFunctions won't work because
it thinks there are 2 namespaces.

Thanks,

Tom
Imports MyFunctions

Dim myDbObject As New DbObject("a test")
'.....Here actually it's same with without "Imports"
' Dim myDbObject As New MyFunctions.DbObject("a test")

HTH,

Onur Güzel

Sep 14 '08 #3
In your project properties, see what you have for 'Root namespace'. All
classes in your VB project are in this namespace. You'll find that it's
probably set to "MyFunctions". Either clear the root namespace or avoid
adding the namespace explicitly in your code files.
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
VB & C# to Java
Java to VB & C#
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++: VB, C#, or Java to C++/CLI
"tshad" wrote:
Using VS 2008, I have a project that uses the dll from another project.

The Namespace is MyFunctions, with a class of DbObject. The beginning of
the code is:
***************************
Imports System
Imports System.Data
Imports System.Data.SqlClient

Namespace MyFunctions

Public Class DbObject
**************************

The Project, class vb file, and dll are called MyFunctions.

In my code, I have to:

Imports MyFunctions.MyFunctions

To get this to work:

Dim myDbObject As New DbObject("a test")
Why don't I need:

Imports MyFunctions

How would I change the project to allow me to use only the Namespace?

Thanks,

Tom
Sep 14 '08 #4
David Anton wrote:
In your project properties, see what you have for 'Root namespace'.
All classes in your VB project are in this namespace. You'll find
that it's probably set to "MyFunctions". Either clear the root
namespace or avoid adding the namespace explicitly in your code files.
That was the problem.

But why would VS work this way?

I don't think I have seen anywhere where it says to do this.

You would normally set the namespace in your file as part of the code. Why
would the Project add another?

Thanks,

Tom
>Using VS 2008, I have a project that uses the dll from another
project.

The Namespace is MyFunctions, with a class of DbObject. The
beginning of the code is:
***************************
Imports System
Imports System.Data
Imports System.Data.SqlClient

Namespace MyFunctions

Public Class DbObject
**************************

The Project, class vb file, and dll are called MyFunctions.

In my code, I have to:

Imports MyFunctions.MyFunctions

To get this to work:

Dim myDbObject As New DbObject("a test")
Why don't I need:

Imports MyFunctions

How would I change the project to allow me to use only the Namespace?

Thanks,

Tom

Sep 14 '08 #5
On Sun, 14 Sep 2008 10:18:13 -0700, "tshad" <tf*@dslextreme.com>
wrote:
>David Anton wrote:
>In your project properties, see what you have for 'Root namespace'.
All classes in your VB project are in this namespace. You'll find
that it's probably set to "MyFunctions". Either clear the root
namespace or avoid adding the namespace explicitly in your code files.
That was the problem.

But why would VS work this way?

I don't think I have seen anywhere where it says to do this.

You would normally set the namespace in your file as part of the code. Why
would the Project add another?
I would not normally add the Namespace in every file, I would have the
root NameSpace specified in the project so that I don't have to put it
in every file in the project.
Sep 14 '08 #6
Tom,

Why are you all the time calling the behaviour of Java developers (and
languages very much based on that) normal behaviour. Mostly I use in C# only
one namespace in a solution, not even a project, and it gives me only a lot
of time correcting those (by the way, there is as well a default namespace
in the project properties in C#, only it does not work as fine as in VB).

You consequently are debating that you want that the VB languages need as
much typing as languages direct derived from C, while you only are
referening to those languages without giving any other reason.

Don't forget that C# is a typical scholar languages. Where things need to be
easy to explain as you don't know the functions yet.

Just my opinion.

Cor
"tshad" <tf*@dslextreme.comschreef in bericht
news:eM**************@TK2MSFTNGP03.phx.gbl...
David Anton wrote:
>In your project properties, see what you have for 'Root namespace'.
All classes in your VB project are in this namespace. You'll find
that it's probably set to "MyFunctions". Either clear the root
namespace or avoid adding the namespace explicitly in your code files.
That was the problem.

But why would VS work this way?

I don't think I have seen anywhere where it says to do this.

You would normally set the namespace in your file as part of the code.
Why would the Project add another?

Thanks,

Tom
>>Using VS 2008, I have a project that uses the dll from another
project.

The Namespace is MyFunctions, with a class of DbObject. The
beginning of the code is:
***************************
Imports System
Imports System.Data
Imports System.Data.SqlClient

Namespace MyFunctions

Public Class DbObject
**************************

The Project, class vb file, and dll are called MyFunctions.

In my code, I have to:

Imports MyFunctions.MyFunctions

To get this to work:

Dim myDbObject As New DbObject("a test")
Why don't I need:

Imports MyFunctions

How would I change the project to allow me to use only the Namespace?

Thanks,

Tom

Sep 15 '08 #7
The root namespace is supposed to be something that makes the full name
unique - there could be many MyFunctions but probably only one
tshad.MyFunctions.

"tshad" <tf*@dslextreme.comwrote in message
news:eM**************@TK2MSFTNGP03.phx.gbl...
David Anton wrote:
>In your project properties, see what you have for 'Root namespace'.
All classes in your VB project are in this namespace. You'll find
that it's probably set to "MyFunctions". Either clear the root
namespace or avoid adding the namespace explicitly in your code files.
That was the problem.

But why would VS work this way?

I don't think I have seen anywhere where it says to do this.

You would normally set the namespace in your file as part of the code.
Why would the Project add another?

Thanks,

Tom
Sep 15 '08 #8

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:BE**********************************@microsof t.com...
Tom,

Why are you all the time calling the behaviour of Java developers (and
languages very much based on that) normal behaviour.
Didn't realize I was. I assumed (and yes I know the problem with that :) )
that it was normal to do this. But that was because in my old job, I did
all my coding (VB and C#) in Dreamweaver so I had no project that would put
the namespace in it. This meant I would have to do this.

Also, many of the sample code I have seen on the net (VB or C#) had the
namespace in the source.
>Mostly I use in C# only one namespace in a solution, not even a project,
and it gives me only a lot of time correcting those (by the way, there is
as well a default namespace in the project properties in C#, only it does
not work as fine as in VB).

You consequently are debating that you want that the VB languages need as
much typing as languages direct derived from C, while you only are
referening to those languages without giving any other reason.
I don't think I do that. I personally like both languages and the
differences tend not to be the languages themselves but the implementations
of the languages in VS.

I know that I did make this statement in another thread:
*********************************************
Option Strict On doesn't fix every quirk in VB.NET... ;)
I agree.

and the same thing about C#. We have these discussions at work all the
time. Why doesn't C# to this like VB does or why doesn't VB do that like C#
does.
************************************************** **

My point here was that at work the people that like VB are constantly
complaining when they have to work on C# projects that VB does this or that
better.

And when people that like C# are constantly complaining when they have to
work on VB projects that C# does this or that better.

I just think it is funny.

I happen to like the Case sensitivity of C# because it I can use the same
names for different things (camel case for memory variables, pascal case for
functions and upper case for constants for example). Others hate it.

Tom
Don't forget that C# is a typical scholar languages. Where things need to
be easy to explain as you don't know the functions yet.

Just my opinion.

Cor
"tshad" <tf*@dslextreme.comschreef in bericht
news:eM**************@TK2MSFTNGP03.phx.gbl...
>David Anton wrote:
>>In your project properties, see what you have for 'Root namespace'.
All classes in your VB project are in this namespace. You'll find
that it's probably set to "MyFunctions". Either clear the root
namespace or avoid adding the namespace explicitly in your code files.
That was the problem.

But why would VS work this way?

I don't think I have seen anywhere where it says to do this.

You would normally set the namespace in your file as part of the code.
Why would the Project add another?

Thanks,

Tom
>>>Using VS 2008, I have a project that uses the dll from another
project.

The Namespace is MyFunctions, with a class of DbObject. The
beginning of the code is:
***************************
Imports System
Imports System.Data
Imports System.Data.SqlClient

Namespace MyFunctions

Public Class DbObject
**************************

The Project, class vb file, and dll are called MyFunctions.

In my code, I have to:

Imports MyFunctions.MyFunctions

To get this to work:

Dim myDbObject As New DbObject("a test")
Why don't I need:

Imports MyFunctions

How would I change the project to allow me to use only the Namespace?

Thanks,

Tom


Sep 16 '08 #9

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

Similar topics

2
by: puzzlecracker | last post by:
after reading some of the post I found out something rather radical to my previous understanding: that when you do #include<iostream> #include<string> #include<vector> etc compiler puts...
7
by: Kai-Uwe Bux | last post by:
Hi folks, I observed something that puzzles me. When I do namespace xxx { using std::swap; } it appears that xxx::swap and std::swap are not strictly equivalent. In particular, I think...
1
by: Phill. W | last post by:
Having changed a VB.Net(2003) DLL project, I'm getting Type Loading problems in other code that uses my DLL. In my source code, I have a Namespace Statement something like this: Namespace...
29
by: Tiraman | last post by:
Hi, I Build my own dll with my own namespace name and i would like to put it in one place but for the project bin folder so all of the projects will be able to use it . i tried to put the dll...
6
by: vivekian | last post by:
Hi, I am not sure if this is a relevant topic here, anyways, When using the std namespace is it a good practice to .. put this right at the beginning using namespace std ;
2
by: shumaker | last post by:
I'm confused about the default namespace setting in the project properties. Help has the following: "Default namespace Specifies the base namespace for all files in the project. For example,...
13
by: Axel Dahmen | last post by:
Hi, I've got a question on namespaces. After reading http://www.w3.org/TR/xml-names11 I still don't understand how namespaces are applied to attributes - particularly in regard to how processing...
2
by: cj | last post by:
What does the line <System.Web.Services.WebService(Namespace:="http://tempuri.org/")_ do in the example below? Imports System.Web.Services Imports System.Web.Services.Protocols Imports...
3
by: huohaodian | last post by:
I have a webservice class MyService.asmx.cs with: namespace XMLWS { public class Poster : System.Web.Services.WebService
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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
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
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...
0
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
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...

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.