Cobold
Cobold

Reputation: 2613

How can I use my classes in several projects?

How can I create a namespace and classes in it, then save it, and reuse the namespace in other projects? Do I have to click on Create Class Library in Visual Studio?

Upvotes: 2

Views: 102

Answers (2)

Cobold
Cobold

Reputation: 2613

I found the answer in Understanding and Using Assemblies and Namespaces in .NET

Here's what you need to do:

  1. Create a Class Library

  2. Build it to generate a .dll file

  3. And add a reference to the dll file in any project to use it

Upvotes: 3

Akram Shahda
Akram Shahda

Reputation: 14781

Sort of .. To create types and use them in several projects you need to place them in a seperate assembly. This assembly could be generated from a class library, or any other project type. The type of the assembly file could be either a dynamic library or an executable.

You can place those types in a specific namespace. Also, you can place them in several namespaces.

To use these types from an external project you have to do the following:

  1. Add a reference to the mentioned assembly.

  2. Either importing the namespaces that contains those classes in your code file. Or, using their fully qualified names.


Refer to Implementing a Class Library in VB.NET

Upvotes: 2

Related Questions