.NET 2.0 Code Challenge

G

Guest

Get the following code to compile using .NET 2.0. You can use VS Team Studio,
the command line complier, etc.

The restrictions are:
1. Place no code in the APP_CODE folder.
2. Do not create a second project that is referenced by the first.

The code is extremely simple:

1. Create a new web site
2. Add a new class to the project
3. In the Page_Load handler of default.aspx.cs, create a reference to the
new class.

For example:

in file Default.aspx.cs
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TestClass tc = new TestClass();
}
}

in file TestClass.cs
public class TestClass
{
public TestClass()
{
}
}

That's it! Simple, yet, the code will not compile as is.
 
T

tdavisjr

Currently, the only way to get code to compile is to place it in the
APP_CODE folder. Why are you against doing this? This is the way
things are set up and until MS comes up with another way, then we will
have to stick with this method.
 
G

Guest

Why are you against doing this?

I'm against it because I should be the one to decide on my project
structure...not Microsoft. Frankly, I'm surprised you had to ask.

Roy
 
G

Gabriel Lozano-Morán

Soon you will have the opportunity to use the same project structure in
Visual Studio 2005 as you are used in Visual Studio 2003. But for now code
placed in one of the special directories (that start with APP) will be
protected, the ISAPI filter will make sure that the content in these
directories are NOT accessible through http requests.

Gabriel Lozano-Morán
MCSD .NET
Real Software
http://www.realdn.be
http://www.realsoftware.be
 
B

Bruce Wood

You mean you haven't yet learned the golden rule of Microsoft
development?

"If you do it whichever way Redmond thought you should do it,
development will be a breeze. If you insist on doing it your own way,
development will be hell."

Otherwise known as, "Don't push on a rope," "Don't spit into the wind,"
etc.

I'm not being sarcastic... coming to C# after years of C / Java
programming, that's what I'm finding. :)
 
K

Kevin Spencer

And why would I want to do this?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.
 
M

Marc Noon

Well you can always create a dll and call your class up that way. At least
that's how MS envisions you doing it.

-Marc
 
R

RCS

I'm afraid to ask if the command-line parameters are ok with you too.
Because Microsoft came up with those, and didn't check with you. I mean, you
should be able to type whatever command-line parameters you want, right?

Maybe I'm not getting it?
 
W

Willy Denoyette [MVP]

Roy said:
Get the following code to compile using .NET 2.0. You can use VS Team
Studio,
the command line complier, etc.

The restrictions are:
1. Place no code in the APP_CODE folder.
2. Do not create a second project that is referenced by the first.

The code is extremely simple:

1. Create a new web site
2. Add a new class to the project
3. In the Page_Load handler of default.aspx.cs, create a reference to the
new class.

For example:

in file Default.aspx.cs
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TestClass tc = new TestClass();
}
}

in file TestClass.cs
public class TestClass
{
public TestClass()
{
}
}

That's it! Simple, yet, the code will not compile as is.

You can't do this with the current Web project model, a new project template
will be released soon that suits your needs. Please read this for more
details.

http://weblogs.asp.net/scottgu/archive/2005/12/07/432630.aspx

Willy.
 
C

Christopher Reed

Why does it matter? Frankly, I'm surprised that you don't like the new
structure given exposure to VS 2003.

Then again, if you don't like the way VS handles your setup, you can always
use Notepad.

(Personally, I am using VWD Express (VS Lite) and I really like it. In the
past, I would use text editors for my development work because I didn't like
the way VS worked.)
 

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