Moving Classes Into Own DLLs

J

Jeremy S

I wrote an ASP.NET application and pretty much separated out various layers
of functionality into individual class files (e.g., dal.cs for all db
access). It's currently all in one VS.NET project and gets compiled into one
dll. I want to re-use some of the classes in other projects - so what all do
I need to do to get these classes into their own dll? I presume that they
will go into their own VS.NET project - but I've held off on doing that
because I don't yet understand how debugging will work if I want to step
through code that starts, for example from a code-behind class and goes into
the DAL class which would be in another project.

Also, once I get these various components separated into own dlls, I'm
wondering what it takes to share them among different Web Applications on
the same Web server. Can I just put my DAL.DLL into the GAC and each Web
application will automatically find it there? Must each dll in the GAC have
a strong name?

I'd apprecite some high-level guidance or suggested readings.

Thanks!
 
K

Kevin Spencer

Hi Jeremy,

The way that Visual Studio works in this regard is this:

A project compiles into a single DLL or executable. A solution hosts various
projects, and therefore, can include various DLLs and/or executables. When
you include a project into a VS.Net solution, and you need to reference a
separate DLL, you create a reference instead to the project, not the DLL, in
the project that has the dependency.

When you debug the solution, all of the projects that are included in the
solution are debugged simultaneously, so you can place breakpoints, watches,
etc., in any of the code of any of the projects.

So, what I would recommend, in terms of breaking out the classes, is to
create a new project for each class that you want in a separate DLL, and
move the class code files into the new projects. Include all of these
projects into a single solution, and voila! You have a componentized
solution. In the future, when creating new solutions, you can include any of
these separate projects into the new solutions.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
S

Steve C. Orr [MVP, MCSD]

You'll want to create a class library.
Move the classes into there that you'd like to be able to reuse.
You can then add a reference to the resulting DLL from various projects.
To be able to step into the project though, you'll wan the new project to be
part of your solution, then add a project reference.
You can use the GAC if you want, although it's not required.
If you do use the GAC though, your assembly must have a strong name.
 
J

Jeremy S

Thank you Kevin and Steve; it's all a bit more straight-forward than I
thought.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top