473,406 Members | 2,259 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,406 software developers and data experts.

Creating libraries

Hi

I would like to create a compiled library .net code which I can use in my
apps using imports and with references like mynamespace.myclass.mothod1.
What is the way to create such libraries?

From an organizational point of view, do I need to have one namespace in a
single file or can I spread it over several files?

Thanks

Regards
Nov 20 '05 #1
5 1188
"John" <jo**@nospam.infovis.co.uk> schrieb

I would like to create a compiled library .net code which I can use
in my apps using imports and with references like
mynamespace.myclass.mothod1. What is the way to create such
libraries?
When creating a new project, choose "ClassLibrary" (not available in VB.Net
Standard).
From an organizational point of view, do I need to have one namespace
in a single file or can I spread it over several files?


You can spread it over several files or even several assemblies.
--
Armin

Nov 20 '05 #2
Thanks. Silly question but just for clarification, if I need to separate my
code into several areas like this;

mycompany.dataaccess. ...
mycompany.ui. ...
etc.

and each of these I would like as separate files (so I can import only the
ones I need), where do I make this distinction in my class library?

Thanks

Regards

PS: Let me know if it is too dumb a question and I need to read something.
:)

"Armin Zingler" <az*******@freenet.de> wrote in message
news:O5**************@tk2msftngp13.phx.gbl...
"John" <jo**@nospam.infovis.co.uk> schrieb

I would like to create a compiled library .net code which I can use
in my apps using imports and with references like
mynamespace.myclass.mothod1. What is the way to create such
libraries?
When creating a new project, choose "ClassLibrary" (not available in

VB.Net Standard).
From an organizational point of view, do I need to have one namespace
in a single file or can I spread it over several files?


You can spread it over several files or even several assemblies.
--
Armin

Nov 20 '05 #3
"John" <jo**@nospam.infovis.co.uk> schrieb
Thanks. Silly question but just for clarification, if I need to
separate my code into several areas like this;

mycompany.dataaccess. ...
mycompany.ui. ...
etc.

and each of these I would like as separate files (so I can import
only the ones I need), where do I make this distinction in my class
library?

There is no direct relation.

Namespace:
A file can contain one or several namespaces. Each Namespace can contain
further namespaces. The items (like classes) in the Namespaces can be spread
over several files or assemblies.

Import:
A simplification at file or project level to avoid typing the full qualified
name, e.g. "Form" instead of "System.Windows.Forms.Form"

Assembly/Library:
A collection of files.
Does this answer your question?
--
Armin

Nov 20 '05 #4
On Thu, 23 Oct 2003 15:31:05 +0100, John wrote:
Thanks. Silly question but just for clarification, if I need to separate my
code into several areas like this;

mycompany.dataaccess. ...
mycompany.ui. ...
etc.

and each of these I would like as separate files (so I can import only the
ones I need), where do I make this distinction in my class library?


Just as an example, create a ClassLibrary. Right Click on the project and
select Project Properties. There is an item called Root Namespace. This
is commonly set to the Company name (e. g. MyCompany).

Then add one or more classes to the Library. At the top of the class, add
a namespace statement. For example if the class in question was for
fileio, you could do this:

'In FileIO.vb
Namespace FileIO
Public Class Class1
End Class

Public Class Class2
End Class
End Namespace
Then, in another project, you can add a reference to the class library and
add:

'In SomeOtherProject.vb
Imports MyCompany.FileIO

Private Sub SomeSub()
Dim o As New Class1
Dim p As New Class2

'...etc.
End Sub
Using the Namespace statement, you can add any number of sub levels. For
example, in another class you do this:

'In SomeOtherClass.vb
Namespace FileIO.Special
Public Class SpecialClass1
End Class
End Namespace

And even though that is in a different .dll, it would still be imported
like this:

Imports MyCompany.FileIO.Special

Public Sub AnotherSub()
Dim x As New SpecialClass1
End Sub

Look up the Namespace statement in the help and that should get you
started. I think it is good practice to set you root namespace to the
company name or some unique identifier.

Hope this helps

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #5
You have made it so easy for me, I created a quick class library project
with namespaces & classes and it worked!

It is sure great to see a library with your company name. :)

Thanks

Regards
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:1s*****************************@40tude.net...
On Thu, 23 Oct 2003 15:31:05 +0100, John wrote:
Thanks. Silly question but just for clarification, if I need to separate my code into several areas like this;

mycompany.dataaccess. ...
mycompany.ui. ...
etc.

and each of these I would like as separate files (so I can import only the ones I need), where do I make this distinction in my class library?


Just as an example, create a ClassLibrary. Right Click on the project and
select Project Properties. There is an item called Root Namespace. This
is commonly set to the Company name (e. g. MyCompany).

Then add one or more classes to the Library. At the top of the class, add
a namespace statement. For example if the class in question was for
fileio, you could do this:

'In FileIO.vb
Namespace FileIO
Public Class Class1
End Class

Public Class Class2
End Class
End Namespace
Then, in another project, you can add a reference to the class library and
add:

'In SomeOtherProject.vb
Imports MyCompany.FileIO

Private Sub SomeSub()
Dim o As New Class1
Dim p As New Class2

'...etc.
End Sub
Using the Namespace statement, you can add any number of sub levels. For
example, in another class you do this:

'In SomeOtherClass.vb
Namespace FileIO.Special
Public Class SpecialClass1
End Class
End Namespace

And even though that is in a different .dll, it would still be imported
like this:

Imports MyCompany.FileIO.Special

Public Sub AnotherSub()
Dim x As New SpecialClass1
End Sub

Look up the Namespace statement in the help and that should get you
started. I think it is good practice to set you root namespace to the
company name or some unique identifier.

Hope this helps

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #6

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

Similar topics

11
by: Joshua Beall | last post by:
Hi All, I am working on a registration system, and one of the things I am going to need to be able to do it setup the database tables for each event that I have registration for. Normally I...
5
by: Carl | last post by:
Hi, I am studying C++ right now. I am interested in creating my own mathematical software. Do you have any suggestions on the libraries or std libraries that I can use to creat very simple graphics...
0
by: Andrey Kazakov | last post by:
Hello! I've got an exception ORA-32101 creating environment with any parameters. Environment *env = Environment::createEnvironment(); I am linking with the following libraries : libocci,...
0
by: Dave | last post by:
I am creating a series of libraries using the .Net version of C++. There is no managed code involved. I have run into the following problem. If I specify "Additional Include Libraries" in the...
8
by: PHP2 | last post by:
I am pretty new at this so forgive me if this is a stupid question, but is there a simple way to create a window with C++... Maybe a library or something with simple window commands?
8
by: Aaron | last post by:
I'm coming from C++ programming 5 years ago into VB.NET, so please be patient with me. In C++, I was able to create a "library" of functions and procedures that I would commonly use in various...
3
by: jeffrey.bigham | last post by:
Hello, I have a relatively simple application that I'm trying to migrate from VS2003 to VS2005. The problem I'm having is that after compiling with VS2005, it won't run on any system that...
0
by: Phani | last post by:
Hi All, I have 3 questions here: 1) Problem creating a SPFolder object: I am trying to create a SPFolder object for a document/picture library using the following code with SOM
1
by: prajwalps97 | last post by:
can people here explain the method to 1.create user defined libraries in c ++ using the tlib utility (i'm using the ide tc++ 3.0) can i add libraries to existing libraries.ie to add libraries to...
0
by: krishnakant Mane | last post by:
hello all, I have got a lot of sets of functions and classes that do related work. so just like we get python libraries I too need to create such libraries often called packages. I want to put...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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.