---
title: "Visual Studio 2008 每日提示(三十三)"
author: "cjc"
date: "2009-03-05T23:53:00Z"
tags: []
slug: "visual-studio-2008"
draft: false
lastmod: "2009-03-05T23:53:00Z"
id: 402643
url: "https://cjc.iteye.com/blog/402643"
---

&lt;script&gt;function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}&lt;/script&gt;

本篇包括tip331-tip340

[http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-33.html](http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-33.html)

## #331、让在文件标签里后移的文件标签保留到最近使用的位置

原文链接：[You can keep recently-used files from falling off the File Tab Channel](http://blogs.msdn.com/saraford/archive/2008/10/09/did-you-know-you-can-keep-recently-used-files-from-falling-off-the-file-tab-channel-331.aspx)

**操作步骤：**  
注意使用这个功能需要修改注册表。在注册表HKEY\_CURRENT\_USER\\Software\\Microsoft\\VisualStudio\\9.0下新建一个DWORD UseMRUDocOrdering = 1。不需要重启ide就可以生效。

假定在IDE里有几个打开的文件，如下图所示  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowYoucankeeprecentlyusedfilesfro_98D6/image_thumb.png)

点击 Class1.vb 标签，Class1.vb会马上移到最左边最近使用的位置。  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowYoucankeeprecentlyusedfilesfro_98D6/image_thumb_1.png)

**评论：这个功能很实用，如果打开文件标签很多的话，很方便的移到最左边。**

[http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-33.html](http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-33.html)

## #332、在IDE里编辑项目文件

原文链接:[How to edit a .csproj or .vbproj project file within the IDE](http://blogs.msdn.com/saraford/archive/2008/10/10/did-you-know-how-to-edit-a-csproj-or-vbproj-project-file-within-the-ide-332.aspx)

**操作步骤：**  
1、右键单击解决方案，选择“**卸载项目**”，项目变成不可用的状态  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouk.vbprojprojectfilewithintheIDE332_A577/image_thumb_1.png)  
2、右键单击项目，选择“编辑项目”。  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouk.vbprojprojectfilewithintheIDE332_A577/image_thumb_2.png)  
3、你可以自定义项目文件。  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouk.vbprojprojectfilewithintheIDE332_A577/image_thumb_3.png)  
4、完成后，可以右键项目名，选择“**重新加载项目**”  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouk.vbprojprojectfilewithintheIDE332_A577/image_thumb_5.png)

5、如果你打开了项目文件，会提示你是否关闭项目文件。  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouk.vbprojprojectfilewithintheIDE332_A577/image_thumb_6.png)

**评论：我一般都是直接在记事本里修改项目文件。**

## #333、在解决方案里修改生成顺序

原文链接:[How to change the build order for your solution](http://blogs.msdn.com/saraford/archive/2008/10/13/did-you-know-how-to-change-the-build-order-for-your-solution-333.aspx)

**操作步骤：**  
右键单击解决方案，选择“项目依赖项”  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowHowtochangethebuildorderforyou_CB00/image_thumb_3.png)

在“项目依赖项”对话框，选择当前项目依赖的项目  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowHowtochangethebuildorderforyou_CB00/image_thumb_4.png)

你也可以在解决方案的属性对话框里修改项目依赖  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowHowtochangethebuildorderforyou_CB00/image_thumb.png)

**评论：我一般都是在解决方案里面进行设置。**

## #334、在解决方案里查看生成顺序

原文链接:[You can view the build order for the solution](http://blogs.msdn.com/saraford/archive/2008/10/14/did-you-know-you-can-view-the-build-order-for-the-solution-334.aspx)

**操作步骤：**  
右键单击解决方案，选择“**项目生成顺序**”

在项目依赖项的“生成顺序”标签里，可以看见项目生成的顺序  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowYoucanviewthebuildorderforthes_CEE6/image_thumb_1.png)

**评论：这个生成顺序是通过修改依赖项来生成的**

## #335、从已经存在的代码创建新项目

原文链接:[You can create a new project from existing code](http://blogs.msdn.com/saraford/archive/2008/10/15/did-you-know-you-can-create-a-new-project-from-existing-code-335.aspx)

**操作步骤：**  
菜单：**文件+新建+从现有的代码创建项目**  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowYoucancreateanewprojectfromexi_D764/image_thumb.png)  
会打开一个向导，通过向导可以基于你指定的代码创建项目  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowYoucancreateanewprojectfromexi_D764/image_thumb_1.png)

**评论：这个功能我很少用，一般我都会把项目建好，然后引入现有的代码。**

## #336、创建项目模板

原文链接:[You can create project templates](http://blogs.msdn.com/saraford/archive/2008/10/16/did-you-know-you-can-create-project-templates-336.aspx)

**操作步骤：**  
在打开菜单：**文件+新建+项目**，如果你想创建一个和当前项目完全一样的项目。你可以利用当前打开的项目做成项目模板。  
方法如下：  
菜单：**文件+导出模板**，打开导出模板向导，如果有多个项目，请选择需要导出的项目  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowYoucancreateprojecttemplates33_E94F/image_thumb_1.png)

导出的模板文件，保存在 Documents\\Visual Studio 2008\\My Exported Templates目录，模板文件是一个zip文件，包括与项目有关的文件、vstemplate 文件、xml文件。

导出项目模板后，在新建项目的时候，就会在新建对话中的我的模板里看见导出的模板，利用这个模板文件你可以创建一个和导出这个模板的项目一模一样的项目。

![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowYoucancreateprojecttemplates33_E94F/image_thumb_3.png)

**评论：这个功能非常实用，特别对于三层结构的构架来说，可以利用模板快速搭建。**

## #337、在新建项目对话增加他人创建的模板

原文链接：[How to add other people’s created project templates to the New Project Dialog](http://blogs.msdn.com/saraford/archive/2008/10/17/did-you-know-how-to-add-other-people-s-created-project-templates-to-the-new-project-dialog-338.aspx)

**操作步骤：**  
菜单：**工具+选项+项目和解决方案+常规**，  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowHowtoaddotherpeoplescreatedpro_F0A9/image_thumb_2.png)

这里是指定项目模板存放的位置，你可以把他人的项目模板复制到“用户项目模板位置”所在的目录。  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowHowtoaddotherpeoplescreatedpro_F0A9/image_thumb_2.png)

**评论：你可以把搜集到各种模板都放到用户模板的位置，方便自己使用。**

## #338、在新建项目对话框中，指定在语言下的节点显示项目模板

原文链接：[Y ou can specify which New Project Dialog Language sub-node to show a project template](http://blogs.msdn.com/saraford/archive/2008/10/20/did-you-know-you-can-specify-which-new-project-dialog-language-sub-node-to-show-a-project-template-337.aspx)

**操作步骤：**  
在上一篇介绍中，模板文件默认都会显示在语言（比如vb 或c#）的根目录，如果你想模板出现在语言下一个节点里，你可以这样做：  
在用户模板目录的某语言目录下，比如：My Documents\\Visual Studio 2008\\Templates\\ProjectTemplates\\Visual Basic ，新建一个目录：test case  
然后把模板文件复制到这个目录下即可。在新建项目对话框里，模板文件将会出现在Visual Basic下的test case节点里  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowYoucanspecifywhichNewProjectDi_EEAD/image_thumb.png)

**评论：嘿嘿，这个方法的好处在于你可以为不同类型的模板放在不同的节点下。**

## #339、指定出现在新建项目对话框中你的项目模板图标

原文链接：[you can specify the project icon for your template to appear in the New Project Dialog](http://blogs.msdn.com/saraford/archive/2008/10/21/did-you-know-you-can-specify-the-project-icon-for-your-template-to-appear-in-the-new-project-dialog-339.aspx)

**操作步骤：**  
在导出项目模板的向导的第二页，有个指定模板图标的选项  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknowyoucanspecifytheprojecticonfor_FBA8/image_thumb.png)

指定后，就可以在新建项目对话框看见你的模板图标了  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/Didyouknowyoucanspecifytheprojecticonfor_FBA8/image_thumb.png)

**评论：指定自己项目模板图标，比较cool，也显得比较专业不是**

## #340、导出项目模板时不自动导入到Visual Studio

原文链接：[How to import your project template if you chosen not to automatically import it](http://blogs.msdn.com/saraford/archive/2008/10/22/did-you-know-how-to-import-your-project-template-if-you-chosen-not-to-automatically-import-it-340.aspx)

**操作步骤：**  
在导出模板想到第二页，有个选项：自动将模板导入到Visual Studio。  
![](http://blogs.msdn.com/blogfiles/saraford/WindowsLiveWriter/DidyouknowHowtoimportyourprojecttemplate_9AA4/image_thumb.png)

如果不选中该项，那么模板文件只会在用户导出到模板的目录一份，例如：\\My Documents\\Visual Studio 2008\\My Exported Templates ，而不会再导出一份到vs 的模板目录：\\My Documents\\Visual Studio 2008\\Templates\\ProjectTemplates.

**评论：如果你只是导出模板，而不打算导入到Visual Studio的模板目录，可以不选该项。**

**更多文章见：[守望轩](http://www.watch-life.net/)\[[http://www.watch-life.net](http://www.watch-life.net/)/]**