Web Development with SharpDevelop, Web Matrix, and DBGCLR

http://dotnetjunkies.com/WebLog/markdigiovanni/archive/2004/06/17/16847.aspx

Visual Studio.NET 2003 makes development a whole lot easier than it ever was before.  But what if you have to develop a web application and you do not have the power of VS.NET 2003 available to you?

I would hate to be without Intellisense (I’m spoiled), debug support, and many of the other features that VS.NET 2003 provides.  There is a way to accomplish this developmental challenge with the following three tools:

SharpDevelop, the free open source .NET IDE, has just been released as Fidalgo RC1 (6/16/2004).  This development environment does not support debugging, or ASP.NET development.  However, SharpDevelop is a great product and it is worth getting excited about.

SharpDevelop’s IDE is very similar to VS.NET 2003; it even has a version of Intellisense.  I felt right at home here.

Web Matrix, the free ASP.NET IDE was released by Microsoft to support ASP.NET development.  This IDE does not support debugging, Windows development, Intellisense, and many other niceties of Visual Studio.NET 2003.

DebugCLR (DbgCLR.exe) is available in the .NET Framework SDK or with Visual Studio.  This tool allows the developer to step into managed code without the need of Visual Studio.NET.

Code snippets in this example are in C#, but can be modified for VB.NET.

Configuring the Solution in SharpDevelop

SharpDevelop has a similar notion of a solution called Combines.  These combines can contain multiple projects. 

I’ve created a project folder for SharpDevelop here: C:\Projects_SharpDevelop and set my default location to this directory from Tools > Options:

Adding a combine:

File > New Combine:

Select a C#, or VBNET Class Library project and call it WebDemo2:

SharpDevelop will create a new class file called MyClass.cs by default.  Delete this file, we will not use it.

This next step is very important.  Set the project output path to C:\Projects_SharpDevelop\WebDemo2\bin.  The bin folder may not exist, so you will need to create it.  To accomplish this, right click on the project, select Project Options > Configurations > Output and set the output path.

Next, add a new file to the project by right clicking on the WebDemo2 project, Add >New File:

Choose a new C# or VB.NET file (depending on what type of Combine you’ve created) and call it MyCodeBehindClass.aspx.cs.

Drop the .aspx from the class name.  This class should inherit from Page.  It should look like this:

Delete the constructor.  It is not needed.

Add the following using statements:

and the following code:

Press F8 to build the Combine.

Configuring the Solution in Web Matrix

Open Web Matrix.

To create a new project which is essentially a shortcut to the directory, click File > New Project and choose Folder ShortCut:

          

Enter the directory path that points to the SharpDevelop Combine: C:\Projects_SharpDevelop\WebDemo2.

You will notice a new shortcut is created in the Workspace sidebar on the right.  Expand the shortcut to see the files that exist from SharpDevelop.

Create a new aspx file.  Right click the shortcut and click Add New File, select ASP.NET Page, and name it MyWebForm.aspx:

 

Next, click the “All” tab at the bottom of the new file, and replace the existing page directive with this one:

This directive can be all in one line.  I wrapped it for this walk through.

Click the “Design” tab at the bottom and drag on a TextBox by expanding the web control's group and selecting the TextBox control from the toolbar to your left.

Click on the play icon on the toolbar or press F5.  Make sure the web path is the same as the Combine location:

I am using the built-in web server provided by Web Matrix (this will display an icon in the taskbar).  You can also use IIS.  This is the main reason we changed the output path of the project.  The web application expects the dlls to be in a bin directory, not bin\debug or bin\release.

The page will run and display the TextBox with the string set in the SharpDevelop class file:

LEAVE THE BROWSER OPEN FOR DEBUGGING

Debugging the Combine

To debug the application, launch DbgCLR.exe.  The quickest way to find this application is to do a search.  If you have VS.NET 2003 installed, the default location is: C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\GuiDebug\DbgCLR.exe.

Open the MyCodeBehindClass.aspx.cs from File > Open > File or CTLR+O.

Set a break point on the following line:

Next, choose the process to step into.  If you are running this example in IIS, choose the aspnet_wp.exe process.  If you are using the Web Matrix web server, choose WebServer.exe.

Click Tools > Debug Processes or CTLR+ALT+P and choose the appropriate process to step into and click Select.  Then close.

Now, refresh the web browser.  You will be taken to the break point:

Why do this?  I always have had this fascination with doing things the hard way.  If you’re anything like me, you might do this just because you can.

Take some time to get familiar with SharpDevelop and Web Matrix.  They both have their own feel.

Additional resources:

SharpDevelop:
http://www.sharpdevelop.com/OpenSource/SD/WhatsNew.aspx
http://www.sharpdevelop.com/OpenSource/SD/Forum/

Web Matrix:
http://www.asp.net/webmatrix/faq.aspx
http://www.asp.net/Forums/ShowForumGroup.aspx?tabindex=1&ForumGroupID=4

--Mark

posted on Thursday, June 17, 2004 1:20 PM

原文地址:https://www.cnblogs.com/huqingyu/p/27455.html