开发者

Convert Class to Class Library

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 an开发者_运维技巧d 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


  • Start by adding a new project to your solution of type Class Library.

Convert Class to Class Library


(source: c-sharpcorner.com)

  • Then move those classes to this project.

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

Convert Class to Class Library


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.


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.


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜