<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>裁纸刀下 &#187; Visual Studio</title>
	<atom:link href="http://ofcss.com/tags/visual-studio/feed" rel="self" type="application/rss+xml" />
	<link>http://ofcss.com</link>
	<description>独立 自由 诚信 宽容 责任 平常心</description>
	<lastBuildDate>Thu, 19 Jan 2012 14:24:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Visual Studio 2010 Ultimate RTM 版开放MSDN下载</title>
		<link>http://ofcss.com/2010/04/14/vs2010-rtm-avaliable-on-msdn.html</link>
		<comments>http://ofcss.com/2010/04/14/vs2010-rtm-avaliable-on-msdn.html#comments</comments>
		<pubDate>Tue, 13 Apr 2010 20:31:51 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[所谓技术]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[软件]]></category>

		<guid isPermaLink="false">http://wukangrui.com/2010/04/14/vs2010-rtm-avaliable-on-msdn.html</guid>
		<description><![CDATA[<p>在4月12日召开盛大的发布会之后，微软很快在官方网站开始提供Visual Studio 2010版相关试用版本的下载，MSDN的下载也已经提供。不过目前暂时没有中文版。 <a href="http://ofcss.com/2010/04/14/vs2010-rtm-avaliable-on-msdn.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p>在4月12日召开盛大的发布会之后，微软很快在官方网站开始提供Visual Studio 2010版相关试用版本的下载，MSDN的下载也已经提供。不过目前暂时没有中文版。</p>
<p> <span id="more-924"></span>
<p>MSDN上的已经提供了Visual Studio 2010版全系列及.NET Framework 4.0相关的所有产品的下载。中文语言的暂时还没有任何项目。</p>
<p align="center"><a href="http://file.wukangrui.com/attachments/2010/04/image8.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2010/04/image_thumb7.png" width="523" height="112" /></a> </p>
<p align="left">以下为ultimate版的文件信息：</p>
<blockquote><p><em>文件名 en_visual_studio_2010_ultimate_x86_dvd_509116.iso</em></p>
<p><em>发布日期 (UTC): 4/12/2010 8:53:48 AM       <br />上次更新日期 (UTC): 4/12/2010 10:44:43 AM</em></p>
<p><em>SHA1: 84C90BB02AF92347010FF9058E0A2BA28F19CC53       <br />ISO/CRC: B22E6250</em></p>
<p><em>Available to Levels: Developer AA; BizSpark Admin; BizSpark; VS Ultimate with MSDN (VL); VS Ultimate with MSDN (Retail);</em>&#160;</p>
</blockquote>
<p>安装后的版本提示为 Version 10.0.30319.1 RTMRel</p>
<p><a href="http://file.wukangrui.com/attachments/2010/04/image4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2010/04/image_thumb3.png" width="541" height="405" /></a> </p>
</p>
<p>安装后开始菜单下的项目变化不大，最主要的是增加了Microsoft Test Manager 2010，需要和Team Foundation Server搭配使用。</p>
<p>启动后可以选择的默认开发环境增加了几个。</p>
<p align="center"><a href="http://file.wukangrui.com/attachments/2010/04/image5.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2010/04/image_thumb4.png" width="326" height="180" /></a> </p>
<p align="left">我选择的是 Visual C# Development Settings，初次启动后连起始页都没有了，我估计应该是自动检测和导入了Visual Studio 2008的设置造成的。</p>
<p align="left">创建新项目的界面：</p>
<p align="center"><a href="http://file.wukangrui.com/attachments/2010/04/image6.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2010/04/image_thumb5.png" width="557" height="373" /></a> </p>
</p>
<p>创建新项目后，发现开发环境的颜色配置的确就是导入了Visual Studio 2008的配色方案，但是字体却恢复成了默认的“新宋体”而不是我在VS2008中设置的“Consolas”。</p>
<p>随便建个项目做了一点测试，很明显可以感觉出来在创建项目、添加新项、添加引用的时候反应敏捷了很多，用直接双击工具箱的方式向页面添加控件速度依然会比较慢（第一个控件，之后就没有延迟了）。</p>
<p>尝试打开一个Visual Studio 2008的解决方案，提示转换，但是没有备份的选项，转换时依然会自动提示是否将网站转换到4.0版本，其它项目不会转换。我的解决方案中包含三个类库一个ASP.NET MVC 1.0项目，转换后编译运行正常。</p>
<p>初步体验暂时如此。</p>
<p>需要下载试用版的同学可以移步到：<a title="http://www.microsoft.com/visualstudio/en-us/download" href="http://www.microsoft.com/visualstudio/en-us/download">http://www.microsoft.com/visualstudio/en-us/download</a>。至于试用期满的问题，相信序列号很快就会出现。在Help菜单下单击Register Product按钮不是跳转到网站，而是弹出一个提示框，估计试用版升级为正式版的入口就在此处。</p>
<p align="center"><a href="http://file.wukangrui.com/attachments/2010/04/image7.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2010/04/image_thumb6.png" width="494" height="194" /></a></p>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2005-12-03 -- <a href="http://ofcss.com/2005/12/03/visual-studio-2005-trial.html" title="Visual Studio 2005体验感受">Visual Studio 2005体验感受</a></li><li>2011-03-07 -- <a href="http://ofcss.com/2011/03/07/ie8-compatibility-settings.html" title="IE8/9兼容性设置">IE8/9兼容性设置</a></li><li>2010-04-04 -- <a href="http://ofcss.com/2010/04/04/vspaste-customization-with-net-reflector.html" title="VSPaste 的持续改造">VSPaste 的持续改造</a></li><li>2009-06-17 -- <a href="http://ofcss.com/2009/06/17/regular-expression-in-dreamweaver.html" title="Dreamweaver中的正则表达式">Dreamweaver中的正则表达式</a></li><li>2009-06-05 -- <a href="http://ofcss.com/2009/06/05/uncharted-waters-4-in-windows7-x64.html" title="Windows 7 兼容性展示：大航海时代4">Windows 7 兼容性展示：大航海时代4</a></li><li>2009-05-24 -- <a href="http://ofcss.com/2009/05/24/sql-express-2008-x64-integration-with-visual-studio-2008-sp1.html" title="Visual Studio 2008 搭配64位SQL Server的问题解决方案">Visual Studio 2008 搭配64位SQL Server的问题解决方案</a></li><li>2009-05-16 -- <a href="http://ofcss.com/2009/05/16/window7-beta-dvd-from-microsoft.html" title="微软发放的Windows 7测试版光盘">微软发放的Windows 7测试版光盘</a></li><li>2009-04-30 -- <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html" title="VS2008 中 JS IntelliSense出错的解决">VS2008 中 JS IntelliSense出错的解决</a></li><li>2009-04-16 -- <a href="http://ofcss.com/2009/04/16/tencent-qq-2009-rtm-released.html" title="QQ2009正式版发布">QQ2009正式版发布</a></li><li>2009-04-13 -- <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html" title="[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2010/04/14/vs2010-rtm-avaliable-on-msdn.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VSPaste 的持续改造</title>
		<link>http://ofcss.com/2010/04/04/vspaste-customization-with-net-reflector.html</link>
		<comments>http://ofcss.com/2010/04/04/vspaste-customization-with-net-reflector.html#comments</comments>
		<pubDate>Sun, 04 Apr 2010 07:02:00 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[所谓技术]]></category>
		<category><![CDATA[.NET Reflector]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VSPaste]]></category>

		<guid isPermaLink="false">http://wukangrui.com/2010/04/04/vspaste-customization-with-net-reflector.html</guid>
		<description><![CDATA[<p>Paste from Visual Studio 是一个很好用的代码高亮插件，对于使用Visual Studio编写代码，用WLW写博客的我们来说实在是不二之选。但是作者从2007年11月22日之后就停止了该插件的更新。而到这时，这个插件还有一些不如人意的地方。 很多人都尝试过对这个插件的改造工作（参见《自己改造VSPaste插件》、《定制Paste from Visual Studio插件（上）》、《定制Paste from Visual Studio插件（下）》），在他们研究的过程中，都由于.NET Reflector无法完成工作而借助了IL。而我在尝试的时候，却发现只是用 .NET Reflector 就完成了对插件源代码的改造工作。以下是具体方法： 用.NET Reflector打开VSPaste.dll文件，选择Export： 导出后就会得到一个C#的项目： &#160; 然后，用Visual Studio打开这个项目。我的目的是解决以下几个问题： 当IDE的颜色主题做了修改之后（主要是背景），粘贴时自动将背景颜色设置到&#60;pre&#62;标签而不是&#60;span&#62;标签（一般情况下，背景色的改变都不会是针对关键字而是对整个文本编辑器的）； 如果从代码中间段复制（缩进层次比较多），粘贴时自动将多余的缩进去除。 这两个工作在《自己改造VSPaste插件》中其实都做了，唯一的区别就是DiryBoy是去除背景，而我要保留背景，只是换个地方放置。 第一步，参照DiryBoy的代码直接实现缩进的去除，在VSPaste.cs文件中找到Undent方法，替换其中的源代码： public static string Undent(string s) { var beginSpaces = new System.Text.RegularExpressions.Regex(“^(?:&#60;span[^&#62;]*&#62;&#124;)( +)”); var &#8230; <a href="http://ofcss.com/2010/04/04/vspaste-customization-with-net-reflector.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p><a title="Paste from Visual Studio" href="http://gallery.live.com/liveItemDetail.aspx?li=d8835a5e-28da-4242-82eb-e1a006b083b9" target="_blank">Paste from Visual Studio</a> 是一个很好用的代码高亮插件，对于使用<a title="Microsoft Visual Studio" href="http://msdn.microsoft.com/zh-cn/vstudio/default.aspx" rel="external" target="_blank">Visual Studio</a>编写代码，用<acronym title="Windows Live Writer">WLW</acronym>写博客的我们来说实在是不二之选。但是作者从2007年11月22日之后就停止了该插件的更新。而到这时，这个插件还有一些不如人意的地方。</acronym> </p>
<p>很多人都尝试过对这个插件的改造工作（参见<a title="DiryBoy's .Net Life：自己改造VSPaste插件" href="http://www.cnblogs.com/Diryboy/archive/2008/12/02/1345407.html" rel="external" target="_blank">《自己改造VSPaste插件》</a>、<a title="老赵：定制Paste from Visual Studio插件（上）" href="http://blog.zhaojie.me/2009/12/vspaste-customization-1.html" rel="external" target="_blank">《定制Paste from Visual Studio插件（上）》</a>、<a title="老赵：定制Paste from Visual Studio插件（下）" href="http://blog.zhaojie.me/2009/12/vspaste-customization-2.html" rel="external" target="_blank">《定制Paste from Visual Studio插件（下）》</a>），在他们研究的过程中，都由于<a title=".NET Reflector" href="http://www.red-gate.com/products/reflector/" rel="external" target="_blank">.NET Reflector</a>无法完成工作而借助了IL。而我在尝试的时候，却发现只是用 <a title=".NET Reflector" href="http://www.red-gate.com/products/reflector/" rel="external" target="_blank">.NET Reflector</a> 就完成了对插件源代码的改造工作。以下是具体方法：</p>
<p><span id="more-909"></span>
<p>用.NET Reflector打开VSPaste.dll文件，选择Export：</p>
<p align="center"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://file.wukangrui.com/attachments/2010/04/image.png" width="385" height="480"></p>
<p>导出后就会得到一个C#的项目：</p>
<p align="center"><a href="http://file.wukangrui.com/attachments/2010/04/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2010/04/image_thumb.png" width="385" height="217"></a>&nbsp;</p>
<p align="left">然后，用Visual Studio打开这个项目。我的目的是解决以下几个问题：</p>
<ol>
<li>
<div align="left">当IDE的颜色主题做了修改之后（主要是背景），粘贴时自动将背景颜色设置到&lt;pre&gt;标签而不是&lt;span&gt;标签（一般情况下，背景色的改变都不会是针对关键字而是对整个文本编辑器的）；</div>
<li>
<div align="left">如果从代码中间段复制（缩进层次比较多），粘贴时自动将多余的缩进去除。</div>
</li>
</ol>
<p>这两个工作在<a title="DiryBoy's .Net Life：自己改造VSPaste插件" href="http://www.cnblogs.com/Diryboy/archive/2008/12/02/1345407.html" rel="external" target="_blank">《自己改造VSPaste插件》</a>中其实都做了，唯一的区别就是<a href="http://www.cnblogs.com/Diryboy/" rel="external" target="_blank">DiryBoy</a>是去除背景，而我要保留背景，只是换个地方放置。</p>
<p>第一步，参照DiryBoy的代码直接实现缩进的去除，在VSPaste.cs文件中找到Undent方法，替换其中的源代码：</p>
<pre style="background: #2e2e2e" class="code"><span style="color: #ff8040">public static string </span><span style="color: #d3d3d3">Undent(</span><span style="color: #ff8040">string </span><span style="color: #d3d3d3">s) {
    </span><span style="color: #ff8040">var </span><span style="color: #d3d3d3">beginSpaces = </span><span style="color: #ff8040">new </span><span style="color: #d3d3d3">System.Text.RegularExpressions.</span><span style="color: #2b91af">Regex</span><span style="color: #d3d3d3">(</span><span style="color: #fcc289">"^(?:&lt;span[^&gt;]*&gt;|)( +)"</span><span style="color: #d3d3d3">);
    </span><span style="color: #ff8040">var </span><span style="color: #d3d3d3">depth = beginSpaces.Match(s).Groups[1].Value.Length;
    </span><span style="color: #ff8040">if </span><span style="color: #d3d3d3">(depth == 0) </span><span style="color: #ff8040">return </span><span style="color: #d3d3d3">s;

    </span><span style="color: #ff8040">var </span><span style="color: #d3d3d3">space2trim = </span><span style="color: #ff8040">new </span><span style="color: #d3d3d3">System.Text.RegularExpressions.</span><span style="color: #2b91af">Regex
                     </span><span style="color: #d3d3d3">(
                         </span><span style="color: #fcc289">"^(&lt;span[^&gt;]*&gt;|) {" </span><span style="color: #d3d3d3">+ depth + </span><span style="color: #fcc289">"}"
                         </span><span style="color: #d3d3d3">, System.Text.RegularExpressions.</span><span style="color: #2b91af">RegexOptions</span><span style="color: #d3d3d3">.Multiline
                     );
    </span><span style="color: #ff8040">var </span><span style="color: #d3d3d3">tmp = space2trim.Replace(s, </span><span style="color: #fcc289">"$1"</span><span style="color: #d3d3d3">);
    </span><span style="color: #ff8040">var </span><span style="color: #d3d3d3">garbageSpan = </span><span style="color: #ff8040">new </span><span style="color: #d3d3d3">System.Text.RegularExpressions.</span><span style="color: #2b91af">Regex
                     </span><span style="color: #d3d3d3">(
                        </span><span style="color: #fcc289">"^&lt;span[^&gt;]*&gt;&lt;/span&gt;"
                        </span><span style="color: #d3d3d3">, System.Text.RegularExpressions.</span><span style="color: #2b91af">RegexOptions</span><span style="color: #d3d3d3">.Multiline
                     );
    </span><span style="color: #ff8040">return </span><span style="color: #d3d3d3">garbageSpan.Replace(tmp, </span><span style="color: #2b91af">String</span><span style="color: #d3d3d3">.Empty);
}</span><span></pre>
</p>
<p></span></p>
<p>接下来是要将背景设置在&lt;pre&gt;标签中，从源代码里可以发现，&lt;pre&gt;标签的生成是在VSPaste.cs的CreateContent方法中，而背景颜色的判断和设置却不在这里，于是我首先想到的是让具体负责背景颜色的代码将颜色值传递出来，所以对CreateContent的方法我做了这样的修改：</p>
<pre style="background: #2e2e2e" class="code"><span style="color: #ff8040">if </span><span style="color: #d3d3d3">(</span><span style="color: #2b91af">Clipboard</span><span style="color: #d3d3d3">.ContainsData(</span><span style="color: #2b91af">DataFormats</span><span style="color: #d3d3d3">.Rtf))
{
    </span><span style="color: #ff8040">string </span><span style="color: #d3d3d3">allBackColor = </span><span style="color: #ff8040">string</span><span style="color: #d3d3d3">.Empty;
    </span><span style="color: #ff8040">string </span><span style="color: #d3d3d3">htmlContent = Undent(</span><span style="color: #2b91af">HTMLRootProcessor</span><span style="color: #d3d3d3">.FromRTF(
        (</span><span style="color: #ff8040">string</span><span style="color: #d3d3d3">)</span><span style="color: #2b91af">Clipboard</span><span style="color: #d3d3d3">.GetData(</span><span style="color: #2b91af">DataFormats</span><span style="color: #d3d3d3">.Rtf),
        </span><span style="color: #ff8040">out </span><span style="color: #d3d3d3">allBackColor));
    </span><span style="color: #ff8040">if</span><span style="color: #d3d3d3">(</span><span style="color: #ff8040">string</span><span style="color: #d3d3d3">.IsNullOrEmpty(allBackColor)) {
        newContent = </span><span style="color: #ff8040">string</span><span style="color: #d3d3d3">.Format(
            </span><span style="color: #fcc289">"&lt;pre class=\"code\"&gt;{0}&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;"</span><span style="color: #d3d3d3">,
            htmlContent);
    }
    </span><span style="color: #ff8040">else
    </span><span style="color: #d3d3d3">{
        newContent = </span><span style="color: #ff8040">string</span><span style="color: #d3d3d3">.Format(
            </span><span style="color: #fcc289">"&lt;pre class=\"code\" style=\"background:{0};\"&gt;{1}&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;"</span><span style="color: #d3d3d3">,
            allBackColor,
            htmlContent);
    }
    </span><span style="color: #ff8040">return </span><span style="color: #2b91af">DialogResult</span><span style="color: #d3d3d3">.OK;
}</span><span></pre>
<p>原来的代码是：</p>
<pre style="background: #2e2e2e" class="code"><span style="color: #ff8040">if </span><span style="color: #d3d3d3">(</span><span style="color: #2b91af">Clipboard</span><span style="color: #d3d3d3">.ContainsData(</span><span style="color: #2b91af">DataFormats</span><span style="color: #d3d3d3">.Rtf))
{
    newContent = </span><span style="color: #fcc289">"&lt;pre class=\"code\"&gt;" </span><span style="color: #d3d3d3">+ Undent(</span><span style="color: #2b91af">HTMLRootProcessor</span><span style="color: #d3d3d3">.FromRTF((</span><span style="color: #ff8040">string</span><span style="color: #d3d3d3">) </span><span style="color: #2b91af">Clipboard</span><span style="color: #d3d3d3">.GetData(</span><span style="color: #2b91af">DataFormats</span><span style="color: #d3d3d3">.Rtf))) + </span><span style="color: #fcc289">"&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;"</span><span style="color: #d3d3d3">;
    </span><span style="color: #ff8040">return </span><span style="color: #2b91af">DialogResult</span><span style="color: #d3d3d3">.OK;
}</span><span></pre>
<p>我的改变就是用为HTMLRootProcessor类的FromRTF方法增加一个传出参数，通过这个参数来获取背景色，从而可以在生成&lt;pre&gt;标签时直接使用。接下来，打开HTMLRootProcessor这个方法，通过阅读其源代码，可以知道，由int类型的颜色转成string类型是通过ColorProcessor的CssColor方法实现的，而每个HTMLRootProcessor方法里面有一个colors的私有字段就是ColorProcessor的实例。所以，我将HTMLRootProcessor的FromRTF方法改造如下：</p>
<pre style="background: #2e2e2e" class="code"><span style="color: #ff8040">public static string </span><span style="color: #d3d3d3">FromRTF(</span><span style="color: #ff8040">string </span><span style="color: #d3d3d3">rtf, </span><span style="color: #ff8040">out string </span><span style="color: #d3d3d3">allBackColor)
{
    </span><span style="color: #ff8040">string </span><span style="color: #d3d3d3">str;
    </span><span style="color: #ff8040">using </span><span style="color: #d3d3d3">(</span><span style="color: #2b91af">StringWriter </span><span style="color: #d3d3d3">writer = </span><span style="color: #ff8040">new </span><span style="color: #2b91af">StringWriter</span><span style="color: #d3d3d3">())
    {
        </span><span style="color: #ff8040">using </span><span style="color: #d3d3d3">(</span><span style="color: #2b91af">StringReader </span><span style="color: #d3d3d3">reader = </span><span style="color: #ff8040">new </span><span style="color: #2b91af">StringReader</span><span style="color: #d3d3d3">(rtf))
        {
            </span><span style="color: #2b91af">ProcessorStack </span><span style="color: #d3d3d3">stack = </span><span style="color: #ff8040">new </span><span style="color: #2b91af">ProcessorStack</span><span style="color: #d3d3d3">();
            </span><span style="color: #2b91af">HTMLRootProcessor </span><span style="color: #d3d3d3">processor = </span><span style="color: #ff8040">new </span><span style="color: #2b91af">HTMLRootProcessor</span><span style="color: #d3d3d3">(stack, writer);
            stack.Push(processor);
            </span><span style="color: #2b91af">Scanner </span><span style="color: #d3d3d3">scanner = </span><span style="color: #ff8040">new </span><span style="color: #2b91af">Scanner</span><span style="color: #d3d3d3">(reader);
            </span><span style="color: #ff8040">new </span><span style="color: #2b91af">Parser</span><span style="color: #d3d3d3">(scanner, stack).Parse();
            <strong style="background: #666">allBackColor = processor.background.HasValue ? processor.colors.CssColor(processor.background.Value) : </span><span style="color: #ff8040">string</span><span style="color: #d3d3d3">.Empty;</strong>
            str = writer.ToString();
        }
    }
    </span><span style="color: #ff8040">return </span><span style="color: #d3d3d3">str;
}</span><span></pre>
</p>
<p></span></span></span></p>
<p>其中高亮的代码就是重点，首先我利用HTMLRootProcessor自带的background属性来存储背景色，然后调用colors实例的CssColor方法来为其赋值，如果没有背景色，则返回空字符串。最后一步，就是修改对background属性赋值的语句，使其只需要判断一次即可（整个代码总共就一种背景色，没必要反复赋值了）。这段代码在HTMLRootProcessor的SyncColors方法中，改造后的代码如下：</p>
<pre style="background: #2e2e2e" class="code"><span style="color: #ff8040">private void </span><span style="color: #d3d3d3">SyncColors(</span><span style="color: #ff8040">bool </span><span style="color: #d3d3d3">bgOnly)
{
    </span><span style="color: #ff8040">int</span><span style="color: #d3d3d3">? nullable;
    </span><span style="color: #ff8040">int</span><span style="color: #d3d3d3">? nullable2;
    </span><span style="color: #ff8040">if </span><span style="color: #d3d3d3">((</span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.background != </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.nextBackground) || ((((nullable = </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.color).GetValueOrDefault() != (nullable2 = </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.nextColor).GetValueOrDefault()) || (nullable.HasValue != nullable2.HasValue)) &amp;&amp; !bgOnly))
    {
        </span><span style="color: #ff8040">if </span><span style="color: #d3d3d3">(</span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.color.HasValue || </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.background.HasValue)
        {
            </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.writer.Write(</span><span style="color: #fcc289">"&lt;/span&gt;"</span><span style="color: #d3d3d3">);
        }
        </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.color = </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.nextColor;
        </span><span style="color: #ff8040">if</span><span style="color: #d3d3d3">(</span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.background.HasValue == </span><span style="color: #ff8040">false</span><span style="color: #d3d3d3">)
            </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.background = </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.nextBackground;
        </span><span style="color: #ff8040">if </span><span style="color: #d3d3d3">(</span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.color.HasValue || </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.background.HasValue)
        {
            </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.writer.Write(</span><span style="color: #fcc289">"&lt;span style=\""</span><span style="color: #d3d3d3">);
            </span><span style="color: #ff8040">if </span><span style="color: #d3d3d3">(</span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.color.HasValue)
            {
                </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.writer.Write(</span><span style="color: #fcc289">"color:"</span><span style="color: #d3d3d3">);
                </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.writer.Write(</span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.colors.CssColor(</span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.color.Value));
            }
            </span><span style="color: gray">//if (this.background.HasValue)
            //{
            //    if (this.color.HasValue)
            //    {
            //        this.writer.Write(';');
            //    }
            //    this.writer.Write("background:");
            //    this.writer.Write(this.colors.CssColor(this.background.Value));
            //}
            </span><span style="color: #ff8040">this</span><span style="color: #d3d3d3">.writer.Write(</span><span style="color: #fcc289">"\"&gt;"</span><span style="color: #d3d3d3">);
        }
    }
}</span></pre>
<p>其中做了两处修改，第一处是在对background赋值前判断其是否已经有值，如果有了，则不再进行赋值操作。第二处是将原来给&lt;span&gt;标签增加背景色的代码注释掉。</p>
<p>至此已经全部改造完毕，然后进行编译，顺利通过。将得到的VSPaste.dll覆盖到C:\Program Files\Windows Live\Writer\Plugins 目录下，启动<acronym title="Windows Live Writer">WLW</acronym>，随便从Visual Studio中赋值一段代码，粘贴，得到了本文中代码显示的效果。为了确认，打开没有改变颜色主题的Visual Web Developer 2008 Exress，复制一段代码，粘贴到<acronym title="Windows Live Writer">WLW</acronym>中，得到了没有背景色的代码样式（这里就不演示了）。至此，大功告成。</p>
<p>最后，对编译修改后的源代码做一点补充说明：如果生成配置是Debug，则没有任何问题，改成Release则一旦使用该插件就会造成<acronym title="Windows Live Writer">WLW</acronym>崩溃。如果要使用Release配置编译，则应该做如下调整：</p>
<p align="center"><a href="http://file.wukangrui.com/attachments/2010/04/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2010/04/image_thumb1.png" width="510" height="280"></a> </p>
<p>这是经过我反复调整测试后得出的，关键在于“定义Debug常量”，其它选项都可选可不选。</p>
<p>本人水平有限，虽然通过尝试得出了正确结果，但是对于编译时发生的事情却不知其所以然，也无法解释其原因。望高人指点。</p>
<p>==================================================</p>
<p>修改后的VSPaste.dll下载：<a href="http://file.wukangrui.com/vspaste.zip" rel="attachment" target="_blank">vspaste.zip</a></p>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2010-04-14 -- <a href="http://ofcss.com/2010/04/14/vs2010-rtm-avaliable-on-msdn.html" title="Visual Studio 2010 Ultimate RTM 版开放MSDN下载">Visual Studio 2010 Ultimate RTM 版开放MSDN下载</a></li><li>2009-05-24 -- <a href="http://ofcss.com/2009/05/24/sql-express-2008-x64-integration-with-visual-studio-2008-sp1.html" title="Visual Studio 2008 搭配64位SQL Server的问题解决方案">Visual Studio 2008 搭配64位SQL Server的问题解决方案</a></li><li>2009-04-30 -- <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html" title="VS2008 中 JS IntelliSense出错的解决">VS2008 中 JS IntelliSense出错的解决</a></li><li>2009-04-13 -- <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html" title="[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html" title="[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html" title="[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述">[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述</a></li><li>2005-12-03 -- <a href="http://ofcss.com/2005/12/03/visual-studio-2005-trial.html" title="Visual Studio 2005体验感受">Visual Studio 2005体验感受</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2010/04/04/vspaste-customization-with-net-reflector.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2008 搭配64位SQL Server的问题解决方案</title>
		<link>http://ofcss.com/2009/05/24/sql-express-2008-x64-integration-with-visual-studio-2008-sp1.html</link>
		<comments>http://ofcss.com/2009/05/24/sql-express-2008-x64-integration-with-visual-studio-2008-sp1.html#comments</comments>
		<pubDate>Sun, 24 May 2009 12:14:40 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[乱七八糟]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://wukangrui.net/2009/05/24/sql-express-2008-x64-integration-with-visual-studio-2008-sp1.html</guid>
		<description><![CDATA[<p>这应该是一个老问题了，微软早在SQL Server 2005版的时候就给出了解答，可是由于解决这个问题的关键补丁直至今日既没有集成到Visual Studio 2008 SP1，也没有作为自动更新或者下载中心单独下载的补丁提供。而是需要用户联系微软客户支持部门索取才可以获得。因此到了SQL Server 2008 SP1 + Visual Studio 2008 SP1，依然存在。不过由于64位系统和相关软件兼容性的问题，以前这个问题遇到的人并不算多。但是Windows 7发布的时候，64位系统兼容性已经大大改善，大内存支持的问题也促使更多的人考虑选择64位操作系统。我也在这个时候终于第一次遇到了Visual Studio 2008搭配64位SQl Server Express的这个兼容性问题。本文对该问题做具体介绍，并提供我解决问题的办法。 首先，描述一下问题。微软官方对此问题的描述： 连接到一个 64 位实例时的 Microsoft SQL Server Express 2008 使用 Visual Studio 2008 Service Pack 1 (SP 1)，您可能会收到以下错误信息： SQL Server 文件 &#8230; <a href="http://ofcss.com/2009/05/24/sql-express-2008-x64-integration-with-visual-studio-2008-sp1.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p>这应该是一个老问题了，微软早在SQL Server 2005版的时候就给出了解答，可是由于解决这个问题的关键补丁直至今日既没有集成到Visual Studio 2008 SP1，也没有作为自动更新或者下载中心单独下载的补丁提供。而是需要用户联系微软客户支持部门索取才可以获得。因此到了SQL Server 2008 SP1 + Visual Studio 2008 SP1，依然存在。不过由于64位系统和相关软件兼容性的问题，以前这个问题遇到的人并不算多。但是Windows 7发布的时候，64位系统兼容性已经大大改善，大内存支持的问题也促使更多的人考虑选择64位操作系统。我也在这个时候终于第一次遇到了Visual Studio 2008搭配64位SQl Server Express的这个兼容性问题。本文对该问题做具体介绍，并提供我解决问题的办法。</p>
<p> <span id="more-653"></span>
<p>首先，描述一下问题。微软官方对此问题的描述：</p>
<blockquote><p>连接到一个 64 位实例时的 Microsoft SQL Server Express 2008 使用 Visual Studio 2008 Service Pack 1 (SP 1)，您可能会收到以下错误信息： </p>
<p>SQL Server 文件 (*.mdf) 的连接要求 SQL Server Express 2005 才能正常工作。 请验证 URL 中的下载的组件的安装： </p>
<p><a href="http://go.microsoft.com/fwlink/?LinkId=49251">http://go.microsoft.com/fwlink/?LinkId=49251</a> (http://go.microsoft.com/fwlink/?LinkId=49251) </p>
<p><b>请注意 </b>从 64 位计算机连接到 SQL Server Express 2008 一个 32 位实例时不会发生此问题。</p>
</blockquote>
<p>界面截图如下：</p>
<p align="center"><a href="http://file.wukangrui.com/attachments/2009/05/image.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2009/05/image-thumb.jpg" width="504" height="205" /></a> </p>
<p>这个问题在32位SQL Server里也有人遇到，不过问题的原因和解决方法都不同，32位系统下有可能是实例名设置不匹配、临时文件有问题等原因。但是在64位系统下，就算那些问题统统查过并且修正之后，依然无法解决。因此必须依赖于微软的单独提供的补丁才可以。</p>
<p>为了避免其它原因造成相同或相似的问题，我从安装开始，讲一下整个过程：</p>
<ol>
<li>下载 SQL Server 2008 EXPRESS 版本（带高级服务的也可以，我这里以带高级服务的版本为例），解压到 X:\SQLEXPRADV_x64_ENU。“X:\”代表你电脑上任意盘符。     </li>
<li>以管理员身份运行命令提示行 cmd.exe 。     </li>
<li>切换到刚才解压的目录，带参数运行setup.exe，例如：
<p>setup.exe /ACTION=INSTALL /INSTALLSHAREDWOWDIR=&quot;C:\Program Files (x86)\Microsoft SQL Server&quot; /INSTALLSHAREDDIR=&quot;C:\Program Files\Microsoft SQL Server&quot;      </p>
<p>说明：这里 INSTALLSHAREDWOWDIR代表32位共享组件安装目录，INSTALLSHAREDDIR代表64位共享组件安装目录。如果你想在安装过程中修改默认安装路径，必须带参数启动安装程序，否则会遇到未指定共享组件安装路径的错误提示。网上的大部分文章建议先用默认选项安装，到最后一步退出，然后修改config文件，再加载config文件来进行安装。该方案可行，但是太麻烦了。      </li>
<li>按照安装向导一步一步进行安装，你可以进行路径和组件的自定义，但是强烈建议不要勾选Business Intelligence Development Studio组件，因为即使你选了，该组件也会安装失败，必须在安装完SQL Server 2008 SP1以后回来再装才能安装成功。如果你选了，那么安装最后提示该组件安装失败也没关系，其它的已经安装成功。     </li>
<li>自定义安装选项的话，在定义运行帐户、默认语言等的那个界面，千万不要启用 Filestream 访问，否则即使打了专用补丁，你仍然会遇到在Visual Studio 2008中直接添加SQL Server 数据库失败的问题，同样是由于启用用户实例失败，但是Filestream造成的那个错误暂时无解，所以不要选择。     </li>
<li>成功安装SQL Server 2008之后， 继续安装 SQL Server 2008 SP1，这个没有什么要注意的，同意协议下一步就行了。     </li>
<li>安装完SQL Server 2008 SP1以后，现在可以再运行一次带高级服务的SQL Server 2008 Express安装包来安装Business Intelligence Development Studio了（如果你需要的话），但是 Filestream 访问还是不能选。     </li>
<li>全部安装完以后，就需要微软用于解决64位SQL Server Express不能在Visual Studio 2008 中直接添加SQL数据库的补丁 VS90SP1-KB957944-x86 了。微软关于该补丁的描述见 <a href="http://support.microsoft.com/default.aspx/kb/957944">http://support.microsoft.com/default.aspx/kb/957944</a> ，不过没必要听他们的去打电话或者发邮件向客服申请，直接到这个地址：<a href="http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=957944">http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=957944</a> ，填写你的Email并提交申请，最多2分钟之后，你就会收到微软发来的下载地址和解压密码。不过这个地址没多久就会失效。如果没有保存，下次再需要的时候还得再次申请。      </li>
<li>安装好补丁Kb957944，检查Visual Studio 2008的“工具 | 选项 | 数据库工具”下的“数据连接”和“设计时验证数据库（Design-time Validation Database）”两个选项，里面都有SQL实例名，要和你安装的实例名相同。另外还要检查你的SQL服务配置，是否已经启用了Named Pipe。     </li>
<li>.现在试试看在你的.NET项目中直接添加SQL Server 数据库，应该可以正常工作了。</li>
</ol>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2010-04-14 -- <a href="http://ofcss.com/2010/04/14/vs2010-rtm-avaliable-on-msdn.html" title="Visual Studio 2010 Ultimate RTM 版开放MSDN下载">Visual Studio 2010 Ultimate RTM 版开放MSDN下载</a></li><li>2010-04-04 -- <a href="http://ofcss.com/2010/04/04/vspaste-customization-with-net-reflector.html" title="VSPaste 的持续改造">VSPaste 的持续改造</a></li><li>2009-06-20 -- <a href="http://ofcss.com/2009/06/20/icbc-u-key-in-windows-7-x64.html" title="工行U盾在Windows 7 x64版下的使用">工行U盾在Windows 7 x64版下的使用</a></li><li>2009-06-08 -- <a href="http://ofcss.com/2009/06/08/using-fastcgi-to-host-php-applications-on-iis-7x.html" title="在 IIS 7.x 中用 FastCGI 运行 PHP">在 IIS 7.x 中用 FastCGI 运行 PHP</a></li><li>2009-06-05 -- <a href="http://ofcss.com/2009/06/05/uncharted-waters-4-in-windows7-x64.html" title="Windows 7 兼容性展示：大航海时代4">Windows 7 兼容性展示：大航海时代4</a></li><li>2009-05-23 -- <a href="http://ofcss.com/2009/05/23/google-chrome-in-windows7-x64.html" title="windows 7 x64 上的Google Chrome">windows 7 x64 上的Google Chrome</a></li><li>2009-05-16 -- <a href="http://ofcss.com/2009/05/16/window7-beta-dvd-from-microsoft.html" title="微软发放的Windows 7测试版光盘">微软发放的Windows 7测试版光盘</a></li><li>2009-04-30 -- <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html" title="VS2008 中 JS IntelliSense出错的解决">VS2008 中 JS IntelliSense出错的解决</a></li><li>2009-04-13 -- <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html" title="[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html" title="[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2009/05/24/sql-express-2008-x64-integration-with-visual-studio-2008-sp1.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VS2008 中 JS IntelliSense出错的解决</title>
		<link>http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html</link>
		<comments>http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html#comments</comments>
		<pubDate>Thu, 30 Apr 2009 18:55:01 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[所谓技术]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://wukangrui.net/2009/04/30/solution-for-js-intellisense-error.html</guid>
		<description><![CDATA[<p>JScript 智能提示(IntelliSense)是 Visual Studio 2008 的一个重要新特性，尤其是现在 Visual Studio 2008 还提供了 jQuery 智能提示的官方支持。遗憾的是在实际应用中经常遇到如图所示的错误提示，并且出现这样的错误以后，包括jQuery在内的智能提示统统失效。非常让人恼火。我最开始的时候仅从提示“Error updating JScript IntelliSense”猜测以为是VS把智能提示缓存起来，然后缓存文件出错。后来尝试过很多方式都无法解决。 后来偶然看到 jeffrey 写的 日志，才知道原来是由于加载的额外js文件缺乏智能提示文件（vsdoc.js）导致的。 jeffrey 有一个非常简单易行的解决建议，就是创建一个和出错文件对应的 –vsdoc.js 文件放到该文件相同的目录下。比如 ASP.NET MVC 里默认就为jQuery.min.js 提供一个 jQuery.min-vsdoc.js 文件， 同样的道理，如果我们在 Scripts 目录下有一个 myScript.js 文件， 那么我们只需要创建一个空的 myScript-vsdoc.js 文件放到 Scripts 目录下，就可以避免因为加载 myScript.js &#8230; <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p>JScript 智能提示(IntelliSense)是 Visual Studio 2008 的一个重要新特性，尤其是现在 Visual Studio 2008 还提供了 jQuery 智能提示的官方支持。遗憾的是在实际应用中经常遇到如图所示的错误提示，并且出现这样的错误以后，包括jQuery在内的智能提示统统失效。非常让人恼火。我最开始的时候仅从提示“Error updating JScript IntelliSense”猜测以为是VS把智能提示缓存起来，然后缓存文件出错。后来尝试过很多方式都无法解决。</p>
<p><img style="display: block; float: none; margin-left: auto; margin-right: auto" alt="JScript IntelliSense Error" src="http://blog.darkthread.net/photos/darkthread/images/4566/original.aspx" /></p>
<p> <span id="more-561"></span>
<p>后来偶然看到 <a href="http://blog.darkthread.net/blogs/darkthreadtw/" rel="nofollow" target="_blank">jeffrey</a> 写的 <a href="http://blog.darkthread.net/blogs/darkthreadtw/archive/2009/04/22/js-intellisense-error.aspx" target="_blank">日志</a>，才知道原来是由于加载的额外js文件缺乏智能提示文件（vsdoc.js）导致的。</p>
<p>jeffrey 有一个非常简单易行的解决建议，就是创建一个和出错文件对应的 –vsdoc.js 文件放到该文件相同的目录下。比如 ASP.NET MVC 里默认就为jQuery.min.js 提供一个 jQuery.min-vsdoc.js 文件， 同样的道理，如果我们在 Scripts 目录下有一个 myScript.js 文件， 那么我们只需要创建一个空的 myScript-vsdoc.js 文件放到 Scripts 目录下，就可以避免因为加载 myScript.js 文件导致的 JS 智能提示失效问题。</p>
<p>当然了，这只是权益之计，不过很有效，因为我们在编写js的时候，增加的js文件往往是自己写的脚本，也就无所谓有没有智能提示了，如果你真的需要智能提示，那么不妨写一个。</p>
<p>由这个问题引发出来一个问题，就是对于在网上发布共享JS库的人，是不是应该考虑完善你的作品，提供对应的&#160; -vsdoc.js 文件呢？</p>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2009-04-13 -- <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html" title="[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html" title="[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html" title="[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述">[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述</a></li><li>2010-10-25 -- <a href="http://ofcss.com/2010/10/25/understanding-user-behavior-google-analytics-event-tracking-jquer.html" title="借助jQuery和Google分析服务的事件追踪深入了解用户行为【译】">借助jQuery和Google分析服务的事件追踪深入了解用户行为【译】</a></li><li>2010-04-14 -- <a href="http://ofcss.com/2010/04/14/vs2010-rtm-avaliable-on-msdn.html" title="Visual Studio 2010 Ultimate RTM 版开放MSDN下载">Visual Studio 2010 Ultimate RTM 版开放MSDN下载</a></li><li>2010-04-04 -- <a href="http://ofcss.com/2010/04/04/vspaste-customization-with-net-reflector.html" title="VSPaste 的持续改造">VSPaste 的持续改造</a></li><li>2009-07-08 -- <a href="http://ofcss.com/2009/07/08/asp-net-mvc-best-practices-part-4.html" title="ASP.NET MVC 最佳实践（四）">ASP.NET MVC 最佳实践（四）</a></li><li>2009-07-07 -- <a href="http://ofcss.com/2009/07/07/asp-net-mvc-best-practices-part-3.html" title="ASP.NET MVC 最佳实践（三）">ASP.NET MVC 最佳实践（三）</a></li><li>2009-07-01 -- <a href="http://ofcss.com/2009/07/01/asp-net-mvc-best-practices-part-2.html" title="ASP.NET MVC 最佳实践（二）">ASP.NET MVC 最佳实践（二）</a></li><li>2009-06-28 -- <a href="http://ofcss.com/2009/06/28/asp-net-mvc-best-practices-part-1.html" title="ASP.NET MVC 最佳实践（一）">ASP.NET MVC 最佳实践（一）</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</title>
		<link>http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html</link>
		<comments>http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html#comments</comments>
		<pubDate>Mon, 13 Apr 2009 17:41:50 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[所谓技术]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[动手实验]]></category>
		<category><![CDATA[翻译]]></category>

		<guid isPermaLink="false">http://wukangrui.net/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html</guid>
		<description><![CDATA[<p>在这次的练习中，你将学习如何开发一个 ASP.NET 应用，整个练习过程包括创建控制器、视图和模型。 通过这次练习，要创建一个分页显示用户列表的 ASP.NET MVC应用。具有显示用户资料，以及创建、修改、删除用户地址的功能。该应用共有三个控制器：用户控制器处理用户信息列表和显示用户信息；地址控制器负责用户地址的创建、编辑和删除；主页控制器负责显示站点的欢迎页面。 提示：为了确保每个步骤都正常运行，最好在每个任务结束的时候都编译整个解决方案。 任务1 &#8211; 创建实体数据模型 在本任务中你要用 实体数据模型（Entity Data Model）创建可编程实体类到数据存储结构（通常是SQL Server数据库或者其他数据库）的映射。Entity Data Model (EDM) 是在 实体框架 (Entity Framework）中专门设计来作为程序中的数据定义的。 点击 开始 &#124; 所有程序 &#124; Microsoft Visual Studio 2008 &#124; Microsoft Visual Studio 2008 启动 VS 2008。 打开 &#8230; <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p>在这次的练习中，你将学习如何开发一个 ASP.NET 应用，整个练习过程包括创建控制器、视图和模型。</p>
<p>通过这次练习，要创建一个分页显示用户列表的 ASP.NET MVC应用。具有显示用户资料，以及创建、修改、删除用户地址的功能。该应用共有三个控制器：用户控制器处理用户信息列表和显示用户信息；地址控制器负责用户地址的创建、编辑和删除；主页控制器负责显示站点的欢迎页面。</p>
<p>提示：为了确保每个步骤都正常运行，最好在每个任务结束的时候都编译整个解决方案。</p>
<p> <span id="more-474"></span>
<p><b>任务1 - 创建实体数据模型</b></p>
<p>在本任务中你要用 <strong>实体数据模型</strong>（<strong>Entity Data Model</strong>）创建可编程实体类到数据存储结构（通常是SQL Server数据库或者其他数据库）的映射。<strong>Entity Data Model</strong> (EDM) 是在 实体框架 (Entity Framework）中专门设计来作为程序中的数据定义的。</p>
<ol>
<li>点击 <strong>开始 | 所有程序 | Microsoft Visual Studio 2008 | Microsoft Visual Studio 2008</strong> 启动 VS 2008。</li>
<li> 打开 <strong>AspNetMvcEx02-DevelopingMvcAppbegin</strong> 目录下的解决方案文件 <strong>MvcSampleApp.sln</strong>。</li>
<li>在 <strong>解决方案浏览器</strong> 中， 打开 <strong>Views</strong> 目录下的 <strong>Shared</strong> 目录。步骤：点击目录名字前面的加号图标，选择 <strong>Site.Master</strong> 文件， 右键点击它并选择 <strong>删除 </strong>。</li>
<li>导入提供的 Site.Master。 步骤：右键点击 <strong>Shared</strong> 文件夹， 指向 <strong>添加</strong> 然后选择 <strong>现有项</strong>。在 <strong>添加现有项</strong> 对话框中，转到 <strong>AspNetMvcAssetsShared</strong> 目录，然后选中该目录下的所有文件（实际就只有一个 Site.Master 文件），点 <strong>添加</strong>。&#160;
<p>提示：与传统的 ASP.NET Web 页面一样， ASP.NET 页面视图 (.aspx 文件)可以使用母版页来为站点的通用部分提供统一的样式。</p>
</li>
<li>
<p>创建 <strong>AdventureWorks</strong> 实体数据模型。步骤：在 解决方案浏览器 中， 在 <strong>MvcSampleApp</strong> 项目中右键点击 <strong>Models</strong> 文件夹， 指向 <strong>添加</strong>， 然后点击 <strong>新建项</strong>。</p>
</li>
<li>在 <strong>新建项</strong> 对话框里选择 <strong>ADO.NET Entity Data Model</strong>。将要创建的项命名为 <strong>AdventureWorks.edmx</strong>，然后点 <strong>添加</strong>。&#160;
<p><a href="http://file.wukangrui.com/attachments/2009/04/image7.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb7.png" width="644" height="437" /></a>        <br /><em><strong>图一</strong> 添加 ADO.NET Entity Data Model</em></p>
</li>
<li>在 <strong>实体模型数据向导</strong> 打开后， 选择 <strong>从数据库生成</strong> 然后点击 <strong>下一步</strong>。</li>
<li>点击 <strong>新建连接</strong> 定义数据库连接。 </li>
<li>In the <b>Choose Data Source</b> dialog, select <b>Microsoft SQL Server</b> as <b>Data Source</b> and click <b>Continue</b>. 在 <strong>选择数据库</strong> 对话框中，选择<strong> Microsoft SQL Server</strong> 作为数据源，然后点 <strong>继续</strong>。（这一步在大部分情况下默认不出现）</li>
<li>In the <b>Connection Properties</b> dialog window, enter <b>AspNetMvcLabs</b> as <b>Server Name</b>, then select <b>AdventureWorksLT</b> database and click <b>OK</b>.在 <strong>连接属性</strong> 对话框里，输入你的 <strong>本地 SQL Server 安装实例 </strong>名称（例如“.”或者“.SQLEXPRESS”），然后在下方选择 <strong>AdventureWorksLT</strong> 数据库 （没有安装 SQL Server 2005 示例数据库的可以从网上下载安装），然后点击 <strong>OK</strong>。
<p>Note:<b>AspNetMvcLabs</b> is the default alias for the database server installed when the <b>SetupEx.cmd</b> script was run at the beginning of this lab.</p>
<p><a href="http://file.wukangrui.com/attachments/2009/04/image8.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb8.png" width="455" height="733" /></a>&#160; <br /><em><b>图二 </b>定义数据连接</em></p>
</li>
<li>回到 <strong>实体数据模型向导</strong>， 点击 <strong>下一步</strong>。</li>
<li>在 <strong>选择数据库对象</strong> 这一步，只需要选择以下三个表：&#160;
<ul>
<li><b>Address (SalesLT)Address </b></li>
<li><b>Customer (SalesLT)</b></li>
<li><b>CustomerAddress (SalesLT)</b></li>
</ul>
</li>
<li>保持 <strong>模型命名空间</strong> 这一项为默认值，点击 <strong>完成</strong>。&#160;
<p><a href="http://file.wukangrui.com/attachments/2009/04/image9.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb9.png" width="484" height="484" /></a>&#160; <br /><strong>图三 </strong><i>选择要包含在模型中的数据库对象</i></p>
</li>
<li>
<p>创建数据容器类 AdventureWorksRepository，这个容器类向其它类暴露数据访问方法，通过这些方法从底层数据模型获取数据实体。在 MvcSampleApp 项目中右击 Models 目录，指向 添加 然后点击 现有项。转到 AspNetMvcAssets 目录， 选择 AdventureWorksRepository.cs 文件，然后点击 添加。       <br />提示：更多详细信息，参见 <a href="http://msdn2.microsoft.com/zh-cn/library/bb387122.aspx" target="_blank">实体数据模型</a> 。</p>
</li>
</ol>
<p>（未完待续）</p>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html" title="[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html" title="[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述">[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述</a></li><li>2009-07-08 -- <a href="http://ofcss.com/2009/07/08/asp-net-mvc-best-practices-part-4.html" title="ASP.NET MVC 最佳实践（四）">ASP.NET MVC 最佳实践（四）</a></li><li>2009-07-07 -- <a href="http://ofcss.com/2009/07/07/asp-net-mvc-best-practices-part-3.html" title="ASP.NET MVC 最佳实践（三）">ASP.NET MVC 最佳实践（三）</a></li><li>2009-07-01 -- <a href="http://ofcss.com/2009/07/01/asp-net-mvc-best-practices-part-2.html" title="ASP.NET MVC 最佳实践（二）">ASP.NET MVC 最佳实践（二）</a></li><li>2009-06-28 -- <a href="http://ofcss.com/2009/06/28/asp-net-mvc-best-practices-part-1.html" title="ASP.NET MVC 最佳实践（一）">ASP.NET MVC 最佳实践（一）</a></li><li>2009-04-30 -- <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html" title="VS2008 中 JS IntelliSense出错的解决">VS2008 中 JS IntelliSense出错的解决</a></li><li>2011-03-14 -- <a href="http://ofcss.com/2011/03/14/browser-rendering-optimizer-translation-extra.html" title="对《优化浏览器渲染》的补充【译】">对《优化浏览器渲染》的补充【译】</a></li><li>2011-03-10 -- <a href="http://ofcss.com/2011/03/10/css-border-tricks-with-collapsed-boxes-translation.html" title="CSS边框实现&ldquo;无图化&rdquo;设计【译】">CSS边框实现&ldquo;无图化&rdquo;设计【译】</a></li><li>2010-10-31 -- <a href="http://ofcss.com/2010/10/31/prevent-a-float-drop-in-ie6-translation.html" title="CSS技巧:如何避免IE6中的&quot;浮动下坠&quot;【译】">CSS技巧:如何避免IE6中的&quot;浮动下坠&quot;【译】</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用</title>
		<link>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html</link>
		<comments>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html#comments</comments>
		<pubDate>Thu, 09 Apr 2009 15:08:09 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[所谓技术]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[动手实验]]></category>
		<category><![CDATA[翻译]]></category>

		<guid isPermaLink="false">http://wukangrui.net/2009/04/09/aspnetmvc-hands-on-labs-create-application.html</guid>
		<description><![CDATA[<p>在这个练习中你将学习如何在 Visual Studio 中创建一个 ASP.NET MVC 应用。并初步了解默认项目结构和一些开发约定。 ASP.NET MVC 框架分为 Model， View 和 Controller 三个部分。模型组件（Model）一般用于维护数据库中的持久数据层的状态。视图组件（View）由控制器挑选并渲染到适当的用户界面。默认状态下， ASP.NET MVC 框架用ASP.NET已有的 ASP.NET 页面（.aspx）、 母版页（.master）以及用户控件（.ascx）等类型来作为浏览器呈现。控制器组件（Controller）组件将用户请求定位到适当的控制器（Controller）行为（Action）和方法（Method），从请求中获取用于行为方法运行的参数值， 并处理行为和方法执行中可能产生的错误。 然后控制器用该请求对应的视图进行渲染。 默认状况下，每个组件存放在 MVC WEB 应用工程的一个独立目录下。 任务1 &#8211; 创建一个 ASP.NET MVC Web 应用工程 在这个任务中你将通过Visual Studio的MVC模板创建和配置一个空的 ASP.NET MVC 应用工程。 打开 &#8230; <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p>在这个练习中你将学习如何在 Visual Studio 中创建一个 ASP.NET MVC 应用。并初步了解默认项目结构和一些开发约定。</p>
<p>ASP.NET MVC 框架分为 Model， View 和 Controller 三个部分。模型组件（Model）一般用于维护数据库中的持久数据层的状态。视图组件（View）由控制器挑选并渲染到适当的用户界面。默认状态下， ASP.NET MVC 框架用ASP.NET已有的 ASP.NET 页面（.aspx）、 母版页（.master）以及用户控件（.ascx）等类型来作为浏览器呈现。控制器组件（Controller）组件将用户请求定位到适当的控制器（Controller）行为（Action）和方法（Method），从请求中获取用于行为方法运行的参数值， 并处理行为和方法执行中可能产生的错误。 然后控制器用该请求对应的视图进行渲染。 默认状况下，每个组件存放在 MVC WEB 应用工程的一个独立目录下。</p>
<p><span id="more-444"></span></p>
<p><strong>任务1 - 创建一个 ASP.NET MVC Web 应用工程</strong></p>
<p>在这个任务中你将通过Visual Studio的MVC模板创建和配置一个空的 ASP.NET MVC 应用工程。</p>
<ol>
<li>打开 Microsoft Visual Studio 2008：依次点击 <strong>开始</strong>|<strong>所有程序</strong>|<strong>Microsoft Visual Studio 2008</strong>|<strong>Microsoft Visual Studio 2008</strong>.</li>
<li>点击 <strong>文件</strong> 菜单， 指向 <strong>新建</strong>， 然后点击 <strong>项目</strong>。</li>
<li>在 <strong>新建项目</strong> 对话框中，确保右上角选中的版本为 <strong>.NET Framework 3.5</strong>，在 <strong>项目类型</strong> 下选择 <strong>Visual C#</strong>，然后在 <strong>Visual Studio 已安装的模板</strong> 中选择 <strong>ASP.NET MVC Web Application</strong> 类型。你可以设置项目位置为 <strong>你的路径AspNetMvcEx01-CreatingMvcAppbegin </strong>作为项目目录。</li>
<li>修改 <strong>名称</strong> 为 <strong>MvcSampleApp</strong> 然后点击 确定 。 <a href="http://file.wukangrui.com/attachments/2009/04/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb.png" border="0" alt="image" width="605" height="484" /> </a><em>图一：创建新项目对话框<br />
</em>在点击 确定 按钮之后，Visual Studio 会问你是否同时创建测试项目（would you like to create a test project）。选择 <strong>Yes</strong>， 输入 <strong>MvcSampleApp.Test</strong> 作为<strong>项目名称</strong>（<strong>Name</strong> of the Project）， 然后点击 <strong>确定</strong>（<strong>OK</strong>）。注：我安装的是Visual Studio 2008 SP1 简体中文版 + ASP.NET MVC 1.0，在我的系统上，创建测试项目的对话框为英文，因此这里加上英文对照。<br />
提示：当你创建一个新的MVC Web应用时， Visual Studio 会为你提供同时创建两个项目的选择，第一个项目是Web项目用来实现你的应用，第二个项目是一个测试项目，你可以在其中为你的MVC组件编写单元测试。<br />
<a href="http://file.wukangrui.com/attachments/2009/04/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb2.png" border="0" alt="image" width="552" height="367" /></a><br />
<em>图二：创建 MVC 单元测试项目<br />
</em>提示：测试项目对话框中的 测试框架（Test Framework） 下拉列表现在只有一个 Visual Studio Unit Test，这个列表是可扩展的，在你的机器上安装了其他测试框架的时候，它将会包含其他的测试框架供你选择。由此你可以容易地用你喜欢的单元测试框架来为你的 ASP.NET MVC 应用编写单元测试。</li>
<li>在Visual Studio 中配置站点使用端口 50000。这一步是为了和本动手实验中的后续联系保持一致所必须的。
<ol type="a">
<li>在 <strong>解决方案浏览器</strong> 中，右击 <strong>MvcSampleApp</strong> 项目，并在上下文菜单中选择 <strong>属性</strong> 。</li>
<li>在 <strong>属性</strong> 页中，打开 <strong>Web</strong> 标签。</li>
<li>In the <strong>Servers</strong> section select <strong>Specific Port</strong>. 在 <strong>服务器</strong> 设置项下面，选择 <strong>使用Visual Studio开发服务器</strong>，并选中 <strong>特定端口</strong> 。</li>
<li>设置端口号为 <strong>50000</strong> 。</li>
<li>按下 <strong>Ctr + S</strong> 保存所做的改动。</li>
</ol>
<p><a href="http://file.wukangrui.com/attachments/2009/04/image3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb3.png" border="0" alt="image" width="635" height="480" /></a><br />
<em>图三：配置本地测试属性</em></li>
</ol>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2009-04-13 -- <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html" title="[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html" title="[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述">[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述</a></li><li>2009-07-08 -- <a href="http://ofcss.com/2009/07/08/asp-net-mvc-best-practices-part-4.html" title="ASP.NET MVC 最佳实践（四）">ASP.NET MVC 最佳实践（四）</a></li><li>2009-07-07 -- <a href="http://ofcss.com/2009/07/07/asp-net-mvc-best-practices-part-3.html" title="ASP.NET MVC 最佳实践（三）">ASP.NET MVC 最佳实践（三）</a></li><li>2009-07-01 -- <a href="http://ofcss.com/2009/07/01/asp-net-mvc-best-practices-part-2.html" title="ASP.NET MVC 最佳实践（二）">ASP.NET MVC 最佳实践（二）</a></li><li>2009-06-28 -- <a href="http://ofcss.com/2009/06/28/asp-net-mvc-best-practices-part-1.html" title="ASP.NET MVC 最佳实践（一）">ASP.NET MVC 最佳实践（一）</a></li><li>2011-03-14 -- <a href="http://ofcss.com/2011/03/14/browser-rendering-optimizer-translation-extra.html" title="对《优化浏览器渲染》的补充【译】">对《优化浏览器渲染》的补充【译】</a></li><li>2009-06-22 -- <a href="http://ofcss.com/2009/06/22/whatever-hover-pseudo-class-without-javascript.html" title="Whatever:hover &#8211; 无需javascript让IE支持丰富伪类">Whatever:hover &#8211; 无需javascript让IE支持丰富伪类</a></li><li>2009-04-30 -- <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html" title="VS2008 中 JS IntelliSense出错的解决">VS2008 中 JS IntelliSense出错的解决</a></li><li>2011-03-10 -- <a href="http://ofcss.com/2011/03/10/css-border-tricks-with-collapsed-boxes-translation.html" title="CSS边框实现&ldquo;无图化&rdquo;设计【译】">CSS边框实现&ldquo;无图化&rdquo;设计【译】</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述</title>
		<link>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html</link>
		<comments>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html#comments</comments>
		<pubDate>Thu, 09 Apr 2009 14:41:35 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[所谓技术]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[动手实验]]></category>
		<category><![CDATA[翻译]]></category>

		<guid isPermaLink="false">http://wukangrui.net/2009/04/09/aspnetmvc-hands-on-labs-introduction.html</guid>
		<description><![CDATA[<p>MVC(Model View Controller) 架构模式通常分为三个主要部分： 模型（Models）：模型对象一般是在应用中实现逻辑域的部分。通常情况下，模型对象用于在数据库中取得和存储模型状态。 视图（Views）：视图是应用中显示用户界面（UI）的组件。典型状况下，用户界面是根据模型数据创建。比如一个产品表的编辑视图中可能包括基于当前产品对象状态的文本框、下拉列表以及单选、复选框等。 控制器（Controllers）：控制器是处理用户交互，操作对应模型、最后选择相应视图来渲染用户界面的组件。在一个MVC架构的应用中，视图只用于显示信息；控制器对用户的输入和交互行为进行处理和响应。 MVC模式可以帮助你将应用拆分的不同方面拆分以形成多层结构（输入逻辑、商业逻辑和用户界面逻辑等），并为这些不同的层提供宽松的耦合关系。这样你就能在开发过程中一次只将精力集中于实现其中的一个方面。除了在处理复杂事务的优势外，调试基于MVC模式的应用也比调试传统ASP.NET WEB应用程序更容易， 因此MVC模式鼓励使用测试驱动开发（TDD: Test-driven development）来创建应用程序。 ASP.NET MVC 框架为ASP.NET Web Forms开发人员提供了创建基于MVC的WEB应用的选择。ASP.NET MVC 框架是一个轻量级的、高可测试性的框架，它与基于Web Forms的应用程序一样，结合了现有的ASP.NET特性，例如母版页和基于用户（Membership-based）的认证等。 除此之外，MVC应用程序三个主要组件之间的宽耦合更方便进行多人并行开发。例如，一个开发人员开发试图，另一个开发人员开发逻辑控制器，与此同时还有一个开发人员在模型层进行商业逻辑开发。 目标 在这个动手实验室系列中，你将学习到： 认识和了解 ASP.NET MVC 框架； 创建一个 ASP.NET MVC 应用程序； 在创建 ASP.NET MVC 应用程序的过程中执行测试。 &#160; 系统需求 为了完成此实验，你必须具备以下的系统配置环境： Microsoft Visual &#8230; <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p>MVC(Model View Controller) 架构模式通常分为三个主要部分：</p>
<ul>
<li>模型（Models）：模型对象一般是在应用中实现逻辑域的部分。通常情况下，模型对象用于在数据库中取得和存储模型状态。</li>
<li>视图（Views）：视图是应用中显示用户界面（UI）的组件。典型状况下，用户界面是根据模型数据创建。比如一个产品表的编辑视图中可能包括基于当前产品对象状态的文本框、下拉列表以及单选、复选框等。</li>
<li>控制器（Controllers）：控制器是处理用户交互，操作对应模型、最后选择相应视图来渲染用户界面的组件。在一个MVC架构的应用中，视图只用于显示信息；控制器对用户的输入和交互行为进行处理和响应。</li>
</ul>
<p> <span id="more-442"></span>
<p>MVC模式可以帮助你将应用拆分的不同方面拆分以形成多层结构（输入逻辑、商业逻辑和用户界面逻辑等），并为这些不同的层提供宽松的耦合关系。这样你就能在开发过程中一次只将精力集中于实现其中的一个方面。除了在处理复杂事务的优势外，调试基于MVC模式的应用也比调试传统ASP.NET WEB应用程序更容易， 因此MVC模式鼓励使用测试驱动开发（TDD: Test-driven development）来创建应用程序。</p>
<p><strong>ASP.NET MVC</strong> 框架为ASP.NET Web Forms开发人员提供了创建基于MVC的WEB应用的选择。<strong>ASP.NET MVC</strong> 框架是一个轻量级的、高可测试性的框架，它与基于Web Forms的应用程序一样，结合了现有的ASP.NET特性，例如母版页和基于用户（Membership-based）的认证等。</p>
<p>除此之外，MVC应用程序三个主要组件之间的宽耦合更方便进行多人并行开发。例如，一个开发人员开发试图，另一个开发人员开发逻辑控制器，与此同时还有一个开发人员在模型层进行商业逻辑开发。</p>
<h3>目标</h3>
<p>在这个动手实验室系列中，你将学习到：</p>
<ul>
<li>认识和了解 ASP.NET MVC 框架；</li>
<li>创建一个 ASP.NET MVC 应用程序；</li>
<li>在创建 ASP.NET MVC 应用程序的过程中执行测试。</li>
</ul>
<p>&#160;</p>
<p> <a href="#" name="_Toc168302999"></a><a href="#" name="_Toc157870738"></a><br />
<h3>系统需求</h3>
<p>为了完成此实验，你必须具备以下的系统配置环境：</p>
<ul>
<li>Microsoft Visual Studio 2008 SP1</li>
<li>Microsoft ASP.NET MVC 1.0 </li>
<li>Microsoft SQL 2005 or Microsoft SQL 2008 (体验版或更高版本) </li>
<li>Adventure Works 示例数据库
<ul>
<li>Microsoft SQL 2005 下使用: <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=4004" target="_blank">AdventureWorksLT.msi</a>
<p><b>备注：</b> 该 msi 安装程序只是将示例数据库文件拷贝到你的文件系统中；你还需要手动在SQL SERVER服务器中附加该数据库。更多信息，请参考 <a href="http://technet.microsoft.com/zh-cn/library/ms190209.aspx" target="_blank">如何：在SQL Server Management Studio 中附加数据库</a>.            <br /><i>Vista 用户请注意：</i> 确认将数据库文件安装到 “C:Program Files”以外的目录， 因为该文件夹具有额外的权限设置，可能会由于文件的只读属性造成你无法在工程文件中进行保存。</p>
</li>
<li>Microsoft SQL 2008 下使用: <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=18407">AdventureWorks 2008 sample databases</a>
<p><b>备注：</b> 该 msi 安装程序只是将示例数据库拷贝到你的文件系统中；不过，你只需要用到 <strong>AdventureWorksLT</strong> 数据库。</p>
<p>&#160;</p>
</li>
</ul>
</li>
</ul>
<h3>安装</h3>
<p>本实验所需的所有必备组件可以用依赖性检测工具来检验。要确定所有项目都已正确配置，请执行以下步骤：</p>
<p>备注：要执行以下安装步骤，你需要在以管理员身份运行的命令提示窗口（cmd.exe）中运行所有脚本。</p>
<ol>
<li>如果以前从没有进行过依赖性检测，请运行依赖性检测工具。要进行检测，运行 CheckDepenencies.cmd 脚本，该脚本位于 <strong>%TrainingKitInstallation%LabsaspNetMvcSetup</strong> 目录。根据向导提示扫描并安装任何缺少的组件（安装后，如果需要可以重新扫描）。
<p>提示：为了方便起见，在这个实验中你将用到的绝大部分代码会安装在Visual Studio 的 代码片段（code snippets）中。CheckDependencies.cmd 结束时会自动加载 Visual Studio 安装管理器来安装代码片段。</p>
</li>
</ol>
<h3>练习</h3>
<p>这个动手实验中包含以下练习：</p>
<ol>
<li>创建 ASP.NET MVC 应用程序 </li>
<li>开发和完善 ASP.NET MVC 应用程序 </li>
<li>测试 ASP.NET MVC 应用程序</li>
</ol>
<p>完成整个实验预计需要时间: <b>90分钟。</b></p>
<p>补充说明:</p>
<p><a href="#" name="_Toc166647553"></a><a href="#" name="_Toc172462715"></a><a href="#" name="_Toc182141329"></a>每个练习中都包含一个起始解决方案，起始解决方案中缺少的代码将在练习工程中完成。因此如果你直接运行起始解决方案，将不能正常执行。    <br />在每个练习中你还可以找到一个 End 目录，其中包括了在整个练习结束时你应该得到的解决方案。在练习过程中如果你需要额外的帮助，可以参考该解决方案。</p>
<p>（文本翻译自 ASP.NET MVC Training Kit，下载地址：<a title="http://www.microsoft.com/downloads/details.aspx?FamilyID=1E0BE0B2-910A-4676-9F3A-41E4D9C0FC08&amp;displaylang=en" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=1E0BE0B2-910A-4676-9F3A-41E4D9C0FC08&amp;displaylang=en">http://www.microsoft.com/downloads/details.aspx?FamilyID=1E0BE0B2-910A-4676-9F3A-41E4D9C0FC08&amp;displaylang=en</a>）</p>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2009-04-13 -- <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html" title="[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html" title="[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用</a></li><li>2009-07-08 -- <a href="http://ofcss.com/2009/07/08/asp-net-mvc-best-practices-part-4.html" title="ASP.NET MVC 最佳实践（四）">ASP.NET MVC 最佳实践（四）</a></li><li>2009-07-07 -- <a href="http://ofcss.com/2009/07/07/asp-net-mvc-best-practices-part-3.html" title="ASP.NET MVC 最佳实践（三）">ASP.NET MVC 最佳实践（三）</a></li><li>2009-07-01 -- <a href="http://ofcss.com/2009/07/01/asp-net-mvc-best-practices-part-2.html" title="ASP.NET MVC 最佳实践（二）">ASP.NET MVC 最佳实践（二）</a></li><li>2009-06-28 -- <a href="http://ofcss.com/2009/06/28/asp-net-mvc-best-practices-part-1.html" title="ASP.NET MVC 最佳实践（一）">ASP.NET MVC 最佳实践（一）</a></li><li>2009-04-30 -- <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html" title="VS2008 中 JS IntelliSense出错的解决">VS2008 中 JS IntelliSense出错的解决</a></li><li>2011-03-14 -- <a href="http://ofcss.com/2011/03/14/browser-rendering-optimizer-translation-extra.html" title="对《优化浏览器渲染》的补充【译】">对《优化浏览器渲染》的补充【译】</a></li><li>2011-03-10 -- <a href="http://ofcss.com/2011/03/10/css-border-tricks-with-collapsed-boxes-translation.html" title="CSS边框实现&ldquo;无图化&rdquo;设计【译】">CSS边框实现&ldquo;无图化&rdquo;设计【译】</a></li><li>2010-10-31 -- <a href="http://ofcss.com/2010/10/31/prevent-a-float-drop-in-ie6-translation.html" title="CSS技巧:如何避免IE6中的&quot;浮动下坠&quot;【译】">CSS技巧:如何避免IE6中的&quot;浮动下坠&quot;【译】</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2005体验感受</title>
		<link>http://ofcss.com/2005/12/03/visual-studio-2005-trial.html</link>
		<comments>http://ofcss.com/2005/12/03/visual-studio-2005-trial.html#comments</comments>
		<pubDate>Sat, 03 Dec 2005 03:01:00 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[所谓技术]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[vs2005]]></category>
		<category><![CDATA[软件]]></category>

		<guid isPermaLink="false">http://wukangrui.net/?p=27</guid>
		<description><![CDATA[<p>Visual Studio .Net 2003一直没有好好试试，只是拿它做了个.NET的个人通讯录自己用，这次去微软发布会现场看到的演示，感觉Visual Studio 2005有很大的改进，因为我在现场的时候试用了一下WEB开发功能，感觉很不错，很多工作一行代码都不用写就能实现的。 　　所以今天就装了Visual Studio 2005体验了一把。 　　VS2005安装的时候集成了.NET FrameWork2.0， .NET Compact FrameWork 1.0SP3和2.0，Device Emulator 1.0， Document Explorer 2005， SQL SERVER 2005 Express Edition和Native Client等相关工具，比2003方便易用得多，而且安装过程也比2003快，还没有那么多重启，界面也很漂亮。 [align=center][/align] 　　或许是因为英文版的关系，VS2005+MSDN+SQL Server 2005安装完以后比2003占用的空间小了很多，不过不知道是不是我的机器还是系统的问题，启动后，建立工程，修改配置等等操作都比2003慢。 　　装完以后还没来得及更细致地探索VS2005，小小地试用了一下，用它建立了一个.NET 站点，写了个手机用的小程序，感觉很爽，最欣慰的是： 　　1. VS 2005自带了WEB SERVER，所以无需IIS即可本机调试WEB站点，而且调试功能比IIS和VS.NET2003要强大得多得多； 　　2. VS 2005建立的页面默认是XHTML 1.0 &#8230; <a href="http://ofcss.com/2005/12/03/visual-studio-2005-trial.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p>Visual Studio .Net 2003一直没有好好试试，只是拿它做了个.NET的个人通讯录自己用，这次去微软发布会现场看到的演示，感觉Visual Studio 2005有很大的改进，因为我在现场的时候试用了一下WEB开发功能，感觉很不错，很多工作一行代码都不用写就能实现的。</p>
<p>　　所以今天就装了Visual Studio 2005体验了一把。</p>
<p>　　VS2005安装的时候集成了.NET FrameWork2.0， .NET Compact FrameWork 1.0SP3和2.0，Device Emulator 1.0， Document Explorer 2005， SQL SERVER 2005 Express Edition和Native Client等相关工具，比2003方便易用得多，而且安装过程也比2003快，还没有那么多重启，界面也很漂亮。</p>
<p>[align=center]<img src="attachments/month_0512/720051242442.PNG">[/align]</p>
<p>　　或许是因为英文版的关系，VS2005+MSDN+SQL Server 2005安装完以后比2003占用的空间小了很多，不过不知道是不是我的机器还是系统的问题，启动后，建立工程，修改配置等等操作都比2003慢。</p>
<p>　　装完以后还没来得及更细致地探索VS2005，小小地试用了一下，用它建立了一个.NET 站点，写了个手机用的小程序，感觉很爽，最欣慰的是：</p>
<p>　　1. VS 2005自带了WEB SERVER，所以无需IIS即可本机调试WEB站点，而且调试功能比IIS和VS.NET2003要强大得多得多；</p>
<p>　　2. VS 2005建立的页面默认是XHTML 1.0 Transitional规范，符合WEB标准，HTML Editor也改善非常多，提供了50多种WEB 控件，非常方便。</p>
<p>　　3. 利用VS2005的智能设备开发界面，很轻松就可以写出手机或者PDA的应用程序，而且本身集成了相关智能设备的模拟器，其中的 SmartPhone 2003模拟器长得好像多普达的界面，我正好用的是多普达智能手机，太高兴了：）</p>
<p>　　4.Visual Studio .Net 2003的工程，我升级了两个到2005，都是全自动完成，而且Error 0， Warning 0，这下可以放心了。</p>
<p>　　微软把Visual Studio .NET 2003中的“.NET”去掉，直接命名为Visual Studio 2005，可见他们对这套产品的信心，第一步体验的结果，也的确感觉非常不错。</p>
<p>　　很多人应该还在等中文版，网上也有人利用SQL Server 2005 CTP中的语言包来制作出VS2005的简体中文版，其实感觉还是应该用英文版好，本身程序员多多少少都还是会点英语的吧，而且一款开发软件，其实真正用到的英语也很少而且很简单，软件本身又是多语言支持的，用英文版适应以后，肯定会比用中文版感觉舒服得多的。</p>
<p>　　这个礼拜要给研究生处做一套WEB程序，很小但是很多特性都适合用XML和.NET来做，我决定用VS2005来开发，正好是个熟悉软件和练习的好机会：）</p>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2010-04-14 -- <a href="http://ofcss.com/2010/04/14/vs2010-rtm-avaliable-on-msdn.html" title="Visual Studio 2010 Ultimate RTM 版开放MSDN下载">Visual Studio 2010 Ultimate RTM 版开放MSDN下载</a></li><li>2011-03-07 -- <a href="http://ofcss.com/2011/03/07/ie8-compatibility-settings.html" title="IE8/9兼容性设置">IE8/9兼容性设置</a></li><li>2010-04-04 -- <a href="http://ofcss.com/2010/04/04/vspaste-customization-with-net-reflector.html" title="VSPaste 的持续改造">VSPaste 的持续改造</a></li><li>2009-06-17 -- <a href="http://ofcss.com/2009/06/17/regular-expression-in-dreamweaver.html" title="Dreamweaver中的正则表达式">Dreamweaver中的正则表达式</a></li><li>2009-05-24 -- <a href="http://ofcss.com/2009/05/24/sql-express-2008-x64-integration-with-visual-studio-2008-sp1.html" title="Visual Studio 2008 搭配64位SQL Server的问题解决方案">Visual Studio 2008 搭配64位SQL Server的问题解决方案</a></li><li>2009-04-30 -- <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html" title="VS2008 中 JS IntelliSense出错的解决">VS2008 中 JS IntelliSense出错的解决</a></li><li>2009-04-16 -- <a href="http://ofcss.com/2009/04/16/tencent-qq-2009-rtm-released.html" title="QQ2009正式版发布">QQ2009正式版发布</a></li><li>2009-04-13 -- <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html" title="[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html" title="[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html" title="[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述">[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2005/12/03/visual-studio-2005-trial.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

