.NET 2.0代码挑战 [英] .NET 2.0 Code Challenge

查看:94
本文介绍了.NET 2.0代码挑战的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取以下代码以使用.NET 2.0进行编译。您可以使用VS Team Studio,

命令行编译器等。


限制条件为:

1.放置否APP_CODE文件夹中的代码。

2.不要创建第一个引用的第二个项目。


代码非常简单:


1.创建一个新网站

2.在项目中添加一个新类

3.在默认的Page_Load处理程序中。 aspx.cs,创建对

新类的引用。


例如:


in file Default .aspx.cs

public partial class默认值:System.Web.UI.Page

{

protected void Page_Load(object sender,EventArgs e )

{

TestClass tc = new TestClass();

}

}


文件TestClass.cs

公共类TestClass

{

public TestClass()

{

}

}


就是这样!很简单,代码不会按原样编译。

解决方案

目前,获取代码编译的唯一方法是将其放在

APP_CODE文件夹。你为什么反对这样做?这就是

设置的方式,直到MS出现另一种方式,然后我们将

必须坚持使用这种方法。

>你为什么反对这样做?


我反对它因为我应该决定我的项目

结构......不是微软。坦率地说,我很惊讶你不得不问。


Roy


很快你就有机会使用它了您在Visual Studio 2003中使用的
Visual Studio 2005中的项目结构。但是现在代码

放在一个特殊目录(以APP开头)中将是

受保护,ISAPI过滤器将确保这些

目录中的内容无法通过http请求访问。


Gabriel Lozano-Morán

MCSD .NET

真实软件
http://www.realdn.be
http:/ /www.realsoftware.be


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.

解决方案

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.


> 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


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


这篇关于.NET 2.0代码挑战的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆