海纳百川 有容乃大(http://www.brtech.com.cn)

海纳百川,有容乃大(http://www.brtech.com.cn)

  :: 首页 :: 博问 :: 闪存 :: :: 联系 :: 订阅 订阅 :: 管理 ::
 

如何在 Microsoft Visual Studio 2005 中直接Debug Community Server 2.0 的代码 Visual Studio 2005 Web Application Projects

由于 Community Server 2.0 Web项目建立成了 Library 的项目.他的调试就是一个麻烦.

附加到进程的调试方式请看下面Blog,适用于 VS2003 VS2005:
使用这个技术请参看下面Blog:

Community Server 2.0中如何调试项目?
http://ugoer.cnblogs.com/archive/2006/02/27/339040.html


另外一个方法就是把 Library 项目 变成 Web 项目,
VS2003 开发环境下,使用这个技术请参看下面Blog:
调试MonoRail程序的三种方法
http://wj.cnblogs.com/archive/2005/08/29/225197.html

lib项目文件转换成web项目文件
http://mixiaobo.cnblogs.com/archive/2006/03/11/347828.html?

VS2003中以ClassLibrary工程的方式管理Web工程.
http://hjf1223.cnblogs.com/archive/2006/03/17/352474.html


其实在 VS2003 开发环境下完全可以不变 Library 项目变成Web项目,稍加配置就可以调试.
具体操作:
在项目的调试属性里, 设为通过url启动,url设为该项目的网址.
同时把上面的"启用asp.net调试"设为true
(
注意,这个 CommunityServerWeb 项目当然是被部署在IIS.)


上面两个 VS2003 下的方法,不使用于 VS2005 开发环境.

如果想在VS2005开发环境下使用VS2003的一些WEB开发方法,设置,可以看微软的这个工具:
http://msdn.microsoft.com/asp.net/reference/infrastructure/wap/default.aspx

把一个项目从其他项目变成 WAP 项目,你只需要修改对应的 csproj 文件

把其中的 Local 变成 
{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
 即可.

这里要解决的在 Microsoft Visual Studio 2005 中直接Debug Community Server 2.0 的代码,最核心的一步就是做上面提到的项目类型修改,改好了就没问题了。然后在项目配置中,配置一下启动页,一切都OK了。

详细的步骤请参看 http://broncosolutions.ca/COMMUNITY/blogs/andrew_renner/archive/2006/04/05/77.aspx

为了避免有些人连不上那里的服务器,我下面Copy过来:

Download the source http://communityserver.com/files/40/releases/default.aspx
Download the latest release of Web Application Projects http://msdn.microsoft.com/asp.net/reference/infrastructure/wap/default.aspx
Download the VS 2005 Update to support Web Application Projects http://www.microsoft.com/downloads/details.aspx?FamilyId=8B05EE00-9554-4733-8725-3CA89DD9BFCA&displaylang=en
Install the VS 2005 Update
Install the Web Application Projects
Load the solution <path>\CS_2.0.60217.2664_SDK\src\Community Server 20.sln
Right click on the CommunityServerWeb20 project and click unload project
Right click on the same project again and click Edit CommunityServerWeb20.csproj
Change the following line from

<ProjectType>Local</ProjectType>

to
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

From: Scott Gu's site
This instructs VS 2005 to treat this project not as a regular class library project, but rather as a VS 2005 Web Application Project (this will cause the web-items to by added to your new item dialog, support running the application using the built-in VS web-server or IIS, and enable auto-attaching to web-servers for debug scenarios among other things).

Close the opened project file and click save
Right click the same project again and click reload project
Right click the same project again and click Properties
You should now notice a WEB option on the left side
Set the start page option to current page (this allows you to hit F5 on any page and it will start there)
Set the servers options to Use IIS Web Server
Set the starting URL to http://localhost/community or whatever your url maybe in IIS (you have to put the http:// in or it will fail)
Leave the debuggers section unchanged (ASP.NET)
Save changes (Almost Done)
Right click the same project again and click Set as startup project
Open the web.config file
Change the compilation debug setting from false to true
<compilation defaultLanguage="c#" debug="true" />
Last Step: open IIS and go to your website/virtual directory
Click the directory security tab
Click the Edit button under Anonymous Access and Authentication Control
Check the check box at the bottom for Integrated Windows Authentication
NOTE: Be sure that IIS is pointing to your source (SDK) web directory

NOTE 2: If you find debugging to be slow... change your compilation options and tell VS not to rebuild the entire solution every time.  This will significantly speed things up.  Just be sure to rebuild the projects that you change.

To do this:

Right  Click on the solution
Click Configuration Manager
Choose debug as the Active Solution Configuration
In the build column only leave the projects checked that you want to build everytime you hit F5
Click Close
References:

http://webproject.scottgu.com/CSharp/Migration/Migration.aspx

http://communityserver.org/forums/thread/522403.aspx

http://developer.communityserver.org/default.aspx/CS.DebuggingInVS2005

 

按照网上看到地一些说法,这个工具将在 VS2005 SP1 中被包含.目前可以看到的最新版本是 
Visual Studio 2005 Web Application Projects (RC1)

对我来说,这个工具我最喜欢的就是:
使用这个工具,我们就可以像以前 VS2003 那样的开发一个项目了.
整个站点的 code 文件被编译成一个 DLL

目前VS2005 Web项目中 AppCode 目录下文件编译成 AppCode.dll 。如果每个Web项目出现一个Appcode,那我就无法把这几个web项目部署在同一站点。只能部署在同一站点的不同的虚拟目录下。这个问题就在这种项目中不会出现。

附,使用这个工具后的WEB项目配置页面
?

其他相关参考资料:


VS2003 WEB
应用程序向VS2005的移植
http://lgp.cnblogs.com/archive/2006/03/14/349620.aspx
英文原文: Upgrading VS 2003 Web Projects to be VS 2005 Web Application Projects
http://webproject.scottgu.com/CSharp/Migration/Migration.aspx


将博客园程序从Visual Studio 2003迁移到Visual Studio 2005的尝试
http://dudu.cnblogs.com/archive/2006/02/18/333115.html

Debugging CS 2.0 in VS 2005
http://developer.communityserver.org/default.aspx/CS.DebuggingInVS2005

New Release of WAP (April 7, 2006)
http://forums.asp.net/thread/1253950.aspx

Tutorial 1: Building Your First Web Application Project
http://webproject.scottgu.com/CSharp/HelloWorld/Helloworld.aspx

Upgrading VS 2005 Web Site Projects to be VS 2005 Web Application Projects
http://webproject.scottgu.com/CSharp/migration2/migration2.aspx

Visual Studio 2005 Web Application Project Tutorials (with C#)
http://webproject.scottgu.com/CSharp/Default.aspx

VS 2005 Web Application Projects Forums
http://forums.asp.net/1019/showforum.aspx

Visual Studio 2005 Web Application Project Preview
http://webproject.scottgu.com/

Debugging Community Server 2.0 with VS 2005 and Web Application Projects
http://broncosolutions.ca/COMMUNITY/blogs/andrew_renner/archive/2006/04/05/77.aspx

An update to support Visual Studio 2005 Web Application Projects is available
http://support.microsoft.com/kb/915364

Community Server 2.0中如何调试项目

ASP.NET 2.0下,web编译模式有点变化,在发布web项目是无法指定生成的程序集(dll)的名称(至少我目前没有发现在何处可以指定),而是随机生成的长串字符。这让人有时很头疼。

Community Server 2.0
基于asp.net 2.0下的工程采取了一个巧妙的做法,就是把web项目建立成Library的项目。具体如下图所示:


这样编译上是没有问题了,但由于Library项目是没有入口函数的,所以不可以调试,更不可以使用vs2005 下的虚拟IIS。那要如何才可以调试这个CommunityServer.Web 项目呢?
如果有调试过sharepoint webpart的朋友一定不会陌生,因为在这种情况下只能附加进程来调试了




附加 w3wp.exe进程进来。之后设置断点即可。

posted on 2006-02-27 19:25 uGoer 阅读(1785) 评论(6)  编辑 收藏 收藏至365Key 所属分类: 3:CommunityServer

评论

# re: Community Server 2.0中如何调试项目?我告诉你! 2006-02-27 20:06 四海为家

这跟.net 2.0没什么关系吧? 我做的项目, 我都是要求用library项目开发web项目的, 而且如何调试也不是象你这样.
关于这个问题, 还是参看这篇blog
顺便一句, 你知道怎么在library项目中添加webform页吗? 呵呵, 如果不知道, 提示一下, 修改vsdir文件.  回复   

# re: Community Server 2.0中如何调试项目?我告诉你! 2006-02-27 20:07 四海为家

忘给地址了
http://wj.cnblogs.com/archive/2005/08/29/225197.html  回复   

# re: Community Server 2.0中如何调试项目?我告诉你! 2006-02-28 09:44 uGoer

@四海为家
你的方法:正确的调试方式是,在项目的调试属性里, 设为通过url启动,url设为该项目的网址即可这样只能启动这个web项目,但是无法扑抓到断点,你可以试试。  回复   

# re: Community Server 2.0中如何调试项目?我告诉你! 2006-02-28 12:05 四海为家

我又忘提了, 在项目的调试属性里,, 除了设为通过url启动外, 还要把上面的"启用asp.net调试"设为true, 抱歉啊
实际上配置一下, .net 1.1 下用library项目开发和用web项目开发没区别, 还少了用frontpage扩展的好多问题 :)  回复   

# re: Community Server 2.0中如何调试项目?我告诉你! 2006-02-28 12:15 uGoer

@四海为家
没有大区别是指在vs.net 2003
这里是说vs2005 下,区别还是比较大。另外,你说的"启用asp.net调试"设为true vs 2005下的属性-〉调试页面下是没有的。

调试MonoRail程序的三种方法

最近在研究MonoRail,但是MonoRailGenerator所生成的项目输出类型是类库,那么如何调试它呢?我摸索了下,有以下三种方法:

1
)用附加进程
       
这里附加不是附加到IEXPLORE.EXE而是附加到aspnet_wp.exe。附加后进入调试状态,然后你打开IE,输入地址就可以了。如果你是用Cassini的话,那就附加到Cassini.exe


2
)创建一个新的控制台项目加入原有项目,用Cassini来调试。你只需要加入一下代码:

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
    Server server =    
new Server(8080, @"/", @"D:\NetUDisk\NetUDisk");
    server.Start();

    Process.Start("IExplore.exe", "http://localhost:8080/");

    Console.ReadLine();

    server.Stop();
}



3
)把lib项目文件转换成web项目文件,转换方法如下:(假设项目名称为:NetUDisk
        a
-建立虚拟目录指向项目所在的目录
        b
-用文本编辑器打开NetUDisk.csproj把的第三行ProjectType = "Local"更改成ProjectType = "Web"
        c
-新建立一个名字叫NetUDisk.csproj.webinfo的文件,里面内容如下:

<VisualStudioUNCWeb>
    
<Web URLPath = "http://localhost/NetUDisk/NetUDisk.csproj" />
</VisualStudioUNCWeb>

        d-在web.config里面的<system.web>下加入:

<compilation 
         
defaultLanguage="c#"
         debug
="true"
    
/>

        
       
好了,就4步,当然另外一种转换方法是用vs.net新建一个asp.net的项目,然后把所有的文件都移到项目文件夹里面,最后别忘记修改web.config哦。

 

lib项目文件转换成web项目文件

lib项目文件转换成web项目文件,转换方法如下:(假设项目名称为:NetUDisk
        a
-建立虚拟目录指向项目所在的目录
        b
-用文本编辑器打开NetUDisk.csproj把的第三行ProjectType = "Local"更改成ProjectType = "Web"
        c
-新建立一个名字叫NetUDisk.csproj.webinfo的文件,里面内容如下:

<VisualStudioUNCWeb>
    
<Web URLPath = "http://localhost/NetUDisk/NetUDisk.csproj" />
</VisualStudioUNCWeb>

        d-在web.config里面的<system.web>下加入:

<compilation 
         
defaultLanguage="c#"
         debug
="true"
    
/>

        
       
好了,就4步,当然另外一种转换方法是用vs.net新建一个asp.net的项目,然后把所有的文件都移到项目文件夹里面,最后别忘记修改web.config哦。

 

VS2003中以ClassLibrary工程的方式管理Web工程

尽管目前已经基本不用 VS2003 作为主要开发工具了,但是今天打开 SubText 却发现它的 Web 工程却是用 ClassLirary 形式的工程来管理的。也就是说不需要在 IIS 创建一个 WEB 工程虚拟目录映射才能找开 WEB 工程,这样就会给我们带来极大的方便。在 VS2005 Web Site 也解决了这个问题,但是却带来了其实的问题,比如没有项目文件,无法很好地管理文件的排除与包含问题。

通过 SubText 项目中的 AspNetWithoutWebProjects.txt 介绍的地址( http://pluralsight.com/wiki/default.aspx/Fritz.AspNetWithoutWebProjects ),了解到在 VS2003 中可以通过修改一个环境文件和项目文件,可以达到就可以实现用 ClassLirary 的工程管理方式来管理 WEB 工程。这里记录下与大家共享。

打开 VS2003 的安装目录,并转到 VC#\CSharpProjectItems 目录下,可以看到还有两个子目录 WebProjectItems LocalProjectItems ,先打开 WebProjectItems 下的 WebProjectItems.vsdir 文件 拷贝下:

CSharpAddWebFormWiz.vsz

CSharpAddWebServiceWiz.vsz

CSharpAddWebUserControl.vszdd

CSharpAddWebDataForm.vsz

4 行的完整代码。

然后转到 LocalProjectItems目录 ,打开 LocalProjectItems.vsdir 文件把上面拷贝的内容粘贴进来。

这一步操作的目的是让 ClassLirary 工程的右键添加新项的菜单中有添加 WebForm Web 引用, WebUserControl, 等这些项,默认情况下是没有这些的,只有添加 WinForm 等不是 Web 工程特有的菜单。

对环境文件的修改这样就行了。接下来就要修改 Web 工程本身的文件。打开项目工程 (.csproj) 文件,把: ProjectType = "Web" 改为 ProjectType = "Local" 。然后删除工程目录下的 .webinfo 文件,否则工程将无法打开。
   
如果工程被包含在一个解决方案文件中,要让解决方案能正常打开,需要打开.sln把对WEB工程改成普通工程的引用。如:
     
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication133",   
           "http://localhost/WebApplication133/WebApplication133.csproj",            
           "{39CB37A5-F735-4684-B5DA-DD355B683090}"
  
   改为:
     Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication133",    
                  "WebApplication133.csproj",     
                  "{39CB37A5-F735-4684-B5DA-DD355B683090}"
      
也就是把URL地址去掉就行了。
      
这样Web工程就可以以ClassLirary的方式打开了,但如果要正确编译,甚至调试,还必须保证,输出路径设为:bin\ 
把调试模式改为URL,单击应用,设置对应的启动URL就可以正常调试了。
(
这里注意一点,没有点应用启动URL的输入框是灰色的不能输入。)

 

posted on 2006-06-02 15:44  阿昆  阅读(1427)  评论(0编辑  收藏  举报