views:

43

answers:

4

I'm trying to follow along with Paul Sheriff's e-book "Fundamentals of N-tier" which is really good so far.

At the end of chapter 2 he says we should break the classes we have created into separate class libraries and that these libraries(dlls) can then be used from any application. The book doesn't explain how to do this.

I have the classes built, but I don't know how to convert them to Class Libraries and reference them in my project.

===========================================================

Thanks for everyone's help I really appreciate it.

I've created the class library in the same project and added a reference to it.

DataCommon is the name of the Class Library DataLayer is the class GetDataTable is a method in the class

how do I access this method from the web project.

I added a "using DataCommon;" statement at the top of the class that I'm trying to access the class library in. I get a "the type or namespace could not be found" message

+2  A: 
  • Start by adding a new project to your solution of type Class Library.

alt text

  • Then move those classes to this project.

  • Finally reference the project in the ASP.NET site.

alt text

Darin Dimitrov
thanks, I've created the class Library.
Joshua Slocum
when I go to Add Refernce Projects tab, there is nothing there
Joshua Slocum
Make sure that the solution contains multiple projects: at least the class library you've added and the web site.
Darin Dimitrov
thanks Darin that clears things up
Joshua Slocum
A: 

Just cut out the code you want to reuse and copy into a new dll project. Then reference that dll project from your application and include the namespace anywhere you want to use those classes. There isn't any other magic involved. Just cut from one project and put in another.

spinon
A: 

Create a new "class library", a project type when creating new project. Then just copy the class into the project, ensuring you are changing the namespace to the appropriate namespace.

Dustin Laine
A: 

I have the classes built, but I don't know how to convert them to Class Libraries and reference them in my project.

Create a new project of type "Class Library" and add your class files to that.

To reference them from your project, you just right click the project in solution explorer and "Add Reference". If the you've got both projects in the same solution, you can then click the Project tab and make your selection. If not, then click the Browse tab and navigate to the bin/debug or bin/release folder from your class library project which contains the compiled dll. (you must have built your class library project for the compiled dll to exist, of course)

kekekela
thanks for the help
Joshua Slocum
ok, I'm having problems registering with Open ID
Joshua Slocum