Reference classes of a website project

T

Tem

My solution has 2 website projects. I need to reference a class in Website
A's app_code folder in Website B. but I can't figure out what namespace to
use.
Can this be done?

Tem
 
S

sloan

You need to push the common code ...DOWN into a common assembly.

This is sometimes called a business layer....or comparable.

And then have both websites reference the same dll.

.........

A website should be considered a presentation layer....and almost anything
you can push down a level will help you in the end.

You're fortunate in that with 2 presentation layers...you actually can
visualize the WHY you should push it down a little better than those who use
a single layer, with a single presentation layer.


Here is a sample of a layered application.

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!139.entry
 
N

Nicholas Paldino [.NET/C# MVP]

Tem,

You can't do this. Rather, you need to create a library project and
place the class in there, then add the reference to the output in each
website.
 
T

Tem

then what is the point of the app_code folder?

sloan said:
You need to push the common code ...DOWN into a common assembly.

This is sometimes called a business layer....or comparable.

And then have both websites reference the same dll.

........

A website should be considered a presentation layer....and almost anything
you can push down a level will help you in the end.

You're fortunate in that with 2 presentation layers...you actually can
visualize the WHY you should push it down a little better than those who
use a single layer, with a single presentation layer.


Here is a sample of a layered application.

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!139.entry
 
T

Tem

is there a way to change the default reference of a new code page?


so that new code files I create in my project will have my references

Have

using System;
using MyProject.MyClass;

for every new file


Nicholas Paldino said:
Tem,

You can't do this. Rather, you need to create a library project and
place the class in there, then add the reference to the output in each
website.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Tem said:
My solution has 2 website projects. I need to reference a class in
Website A's app_code folder in Website B. but I can't figure out what
namespace to use.
Can this be done?

Tem
 
S

sloan

You can have compiled code which is SPECIFIC to the presentation layer.

That's a reason for App_Code.

Usually....presentation specific code...but common among pages is a good
candidate here.

Google
N Layered Development

...

App_Code is ok for hobby'ist websites that don't need code reuse/sharing.

But not for anything beyond that.
 
N

Nicholas Paldino [.NET/C# MVP]

Tem,

Well, you could create a new item template (if you google, you should be
able to find examples), but remember, you also have to set the reference in
your project, just adding the using statement isn't enough.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Tem said:
is there a way to change the default reference of a new code page?


so that new code files I create in my project will have my references

Have

using System;
using MyProject.MyClass;

for every new file


Nicholas Paldino said:
Tem,

You can't do this. Rather, you need to create a library project and
place the class in there, then add the reference to the output in each
website.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Tem said:
My solution has 2 website projects. I need to reference a class in
Website A's app_code folder in Website B. but I can't figure out what
namespace to use.
Can this be done?

Tem
 
T

Tem

Can I use the same project (Class library) with multiple solutions? is this
allowed in .net or VS?
 
S

sloan

Yes.

You should plan out your directory structure a little bit, and then make
this happen.

That's the point. Push code down into reusable components.

...

During development, your (multiple) solutions...can reference the "common"
project.
As in, "Add Existing Project". This will allow you to actually step thru
the debugger.

During deployment, or when you think the "common" assembly is really
good....you can build it...and then reference from the other projects...via
a hard file.


I would STRONGLY recommend this book:
http://www.amazon.com/Developing-Application-Frameworks-NET-Chen/dp/1590592883/

Not so much for the code samples (its 1.1 code) but for the lessons you'll
learn about reusing code.

Check ebay , because sometimes you can get a book like this for really
cheap.
 
S

sloan

Here is the setup I (my company) uses:





(compiled code..dll's only)
\DotNet\v20\Assemblies\Applications\
\DotNet\v20\Assemblies\Framework\ (nothing in here, just a holder for
release and beta folders)
\DotNet\v20\Assemblies\Framework\Release\
\DotNet\v20\Assemblies\Framework\Beta\



( SOURCE CODE)
\DotNet\v20\Source\Applications\
\DotNet\v20\Source\Framework\
\DotNet\v20\Source\ThirdParty\



Examples:

(SOURCE CODE examples)

\DotNet\v20\Source\Applications\NorthwindManager\
(This is an application...one of many probably)
(but all the source code for the NorthwindManager goes here)


\DotNet\v20\Source\Framework\MyCompany.DataAccessHelper\
(This is a framework piece...the source code).
(Notice I can reference it via other applications via a RELATIVE path if
need be)


\DotNet\v20\Source\ThirdParty\Wintellect\PowerCollections\
(This is where I put source code for projects I get from the web or
something)




(COMPILED CODE examples)

\DotNet\v20\Assemblies\Applications\NorthwindManager.dll

\DotNet\v20\Assemblies\Framework\Release\MyCompany.DataAccessHelper.dll

\DotNet\v20\Assemblies\Framework\Release\PowerCollections.dll
 
T

Tem

Thanks

sloan said:
Here is the setup I (my company) uses:





(compiled code..dll's only)
\DotNet\v20\Assemblies\Applications\
\DotNet\v20\Assemblies\Framework\ (nothing in here, just a holder for
release and beta folders)
\DotNet\v20\Assemblies\Framework\Release\
\DotNet\v20\Assemblies\Framework\Beta\



( SOURCE CODE)
\DotNet\v20\Source\Applications\
\DotNet\v20\Source\Framework\
\DotNet\v20\Source\ThirdParty\



Examples:

(SOURCE CODE examples)

\DotNet\v20\Source\Applications\NorthwindManager\
(This is an application...one of many probably)
(but all the source code for the NorthwindManager goes here)


\DotNet\v20\Source\Framework\MyCompany.DataAccessHelper\
(This is a framework piece...the source code).
(Notice I can reference it via other applications via a RELATIVE path if
need be)


\DotNet\v20\Source\ThirdParty\Wintellect\PowerCollections\
(This is where I put source code for projects I get from the web or
something)




(COMPILED CODE examples)

\DotNet\v20\Assemblies\Applications\NorthwindManager.dll

\DotNet\v20\Assemblies\Framework\Release\MyCompany.DataAccessHelper.dll

\DotNet\v20\Assemblies\Framework\Release\PowerCollections.dll
 

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

Top