Directory Layout Suggestions

  • Thread starter Thread starter Jonathan Wood
  • Start date Start date
J

Jonathan Wood

I'm curious: if you are developing an ASP.NET Website concurrently with some
DLLs that the Website will use, how do you arrange your folders/projects to
make things easy, without requiring you to bounce between projects.

I'm reading the book Pro ASP.NET 2.0 E-Commerce in C# 2005. The author
recommends starting by creating a blank solution. Next, he selects the New
Solution Folder command to create a folder, Web, to hold the Website files
and then selects the Add|New Web Site command to create a Website project in
this folder.

Next, he creates another subdirectory called Class Libraries. And then he
creates class library projects in these folders. As I understand it, he is
going to compile these libraries into DLLs and then post them on the Website
when it is completed.

While I understand some reasons for this, this seems overly complicated and
error prone. Somehow, it just doesn't seem like Visual Studio was intended
to be used this way. So I was wondering how others were handling this type
of solution.

Thanks!

Jonathan
 
It's not just that he will compile them and post them onto the website.
Once you have the class library projects in your solution, you add a
reference in the Web Project and click the "Projects" tab, then choose the
projects which will output your *.dll's.
This allows you to develop your *.dll's and Web Project in tandem.

Note that when debugging, ensure that all the projects in the solution are
set to debug mode, so you can step directly from your web applications
through all of the *.dll's code as well.

William
 
To be honest, I couldn't seem to get that arrangement working. Sometimes
Visual Studio creates the folder directly in the corresponding folder in the
Websites folder. Other times, they are created somewhere else. I couldn't
even get it to run that way.

As I said, it doesn't appear that's the configuration the Visual Studio
designers had in mind for this type of stuff. It just felt like I was
working against Visual Studio that way.

Jonathan
 
Create your web project and ensure you have a solution.

You can then do one of two things:
1) Create a new project for your dll output
a) Go back to your Web Project and right click on the solution name >
choose add existing project > navigate to the dll project you just created
and select it.
2) From your Web Project, right click on the solution name > choose add new
project (and configure the new project as a class library)

(Make sure yer clicking the solution name and not the project name when
trying to add an existing or create a new project to add to the solution)

At this point you have 1 solution with 2 projects in it.
Right click the Web Project name > select add reference > Projects > select
the class library project (the only item in the list) and yer set.

Note that this functionality does not exist in the Express version. To get
around this, use the App_Code folder to create your classes for what will
eventually go into your class library.
When yer ready to compile the App_Code files into a dll, exclude them from
the Web Project, pop em into yer Class Library Project, compile the dll,
reference it in your Web Project and yer set.

The whole, compile your dll, reference it in yer web project, rebuild the
web project and then test it routine gets real old real fast, hope this
helps.
 
Thanks for the info. I'm not using the Express version.

I've got a little over a week to get this code working so I'm leaning
towards simply placing my classes in the App_Code folder for now (without
compiling to a DLL).

But I've printed out your post and will go over it again when I get some
more time.

Thanks again.

Jonathan
 
Thanks for all your help on this and other issues.

I decided to implement my Web User Control as a regular Web Control, which
requires it's in a separate assembly to take full advantage of. So I finally
got around to following your suggestions here in adding multiple projects to
my solution, and am putting all my other classes in this project as well.

I got this working with the help of your comments and am really thrilled at
the additional features my controls can have this way.

One thing, I created my new project as a class library since it will contain
only callable classes. However, I then had to add a bunch of references for
it to compile. I'm thinking I could've created it as a Website and these
references would be included automatically but that doesn't seem quite
right. I'm just wondering if the approach I took could cause me any other
problems.

Thanks again for all the help.

Jonathan
 
Nope, you did it like champ!

If ya ever need more references, don't be shy, just pop em in =)

William
 
Back
Top