Print Search
帖子排序:    
帖子发起人: 魏东   发起时间: 2006-01-05 08:45 上午   回复: 4
dongwei 离线,最后访问时间: 2007-11-1 13:22:51 魏东



发帖数前10位
男
注册: 2005-07-25
CHINA
发 贴: 86
Writing an Online Compiler with ASP. NET 2.0

附件: Writing_an_Online_Compiler_with_ASP_NET_2_0.zip
 2006-01-05, 08:45 上午

Writing an Online Compiler with ASP. NET 2.0

By: Joel Martinez

Have you ever found yourself at your cousin's farm needing to recompile your .NET website over their Linux based 56k modem? Perhaps you don't have Visual Studio.NET? Or maybe, you simply want an easy way to give .NET a try.

Well, your problems are solved. The download accompanied by this article includes an ASP.NET page that will allow you to compile .net code in either C# or VB.NET. The resulting binary file will reside in the web application's root directory where you can download it to your local computer.

The online compiler is written in C# and ASP.NET.

Using The Online Compiler

The .NET Framework is done in such a way that the internal functions of the compilers are exposed programmatically via CodeDom classes. These classes have several uses, including the ability to build up code structure by structure, "if" statement by "if" statement, variable by variable; and also the ability to compile straight from a complete text of a code file.

We will be focusing on the compilation from text. Our application will take the user's input from a textbox, pass it to the compiler, and display any errors should there be any. Below is a screenshot of the interface.

Put some valid C# or VB.NET code into the large textbox, make sure the correct language is chosen in the Compile With dropdown, and click compile. It will report the status of the compilation. Using the following code:

using System;
class CMXClass
{
  public bool DoesItRock()
  {
     return true;
  }
}

The following results can be seen:

As you can see, the resulting assembly is delivered to the root directory of the web application. Unfortunately, due to web server security restrictions, you will have to use FTP to download the file. If, however, your code does not compile correctly, it will promptly report any and all errors to you. The code below is trying to use a bad construct which will not compile:

using System;
class CMXClass
{
  public bool DoesItRock()
  {
     s/0;
     return true;
  }
}

If you try to compile that, you will see the below screen:

Conclusion

The included application is a quick and easy way to get started with compiling .NET code if you don't already have a fully featured editor/compiler.


积极主动、认真细致、勤俭节约、务实创新、执之以恒。
所有坚韧不拔的努力迟早会取得报酬的。
耐心和持久永远胜过激烈和狂热。
IP 地址: 已记录   报告
williamkin 离线,最后访问时间: 2007-1-31 16:55:48 谁与争疯

发帖数前25位
注册: 2005-10-17
发 贴: 32
Re: Writing an Online Compiler with ASP. NET 2.0
 2006-01-05, 13:15 下午
It is really good! at least a very wonderful idea!
IP 地址: 已记录   报告
dcding 离线,最后访问时间: 2006-11-7 13:48:14 dcding

发帖数前10位
注册: 2005-07-23
发 贴: 279
Re: Writing an Online Compiler with ASP. NET 2.0
 2006-04-12, 15:01 下午
有点意思。
IP 地址: 已记录   报告
xts668 离线,最后访问时间: 2006-5-13 20:26:31 xts668

发帖数前100位
注册: 2006-05-13
发 贴: 2
Re: Writing an Online Compiler with ASP. NET 2.0
 2006-05-13, 20:23 下午
哦,知道了
IP 地址: 已记录   报告
shakewang 离线,最后访问时间: 2006-8-4 20:26:10 shakewang



发帖数前10位
男
注册: 2005-07-25
发 贴: 49
Re: Writing an Online Compiler with ASP. NET 2.0
 2006-05-14, 22:51 下午
不错的想法, 不过感觉实际用途不大。在web的文本框里写代码可不是一件舒服的事.另外,服务器上的执行权限也是个问题 .
三人行,必有我师
IP 地址: 已记录   报告
合肥微软技术中心社区 » 技术讨论区 » .NET技术相关 » Writing an Online Compiler with ASP. NET 2.0

Powered by Community Server Powered by CnForums.Net