﻿<?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>BlogJava-jinfeng_wang-随笔分类-.Net</title><link>http://www.blogjava.net/jinfeng_wang/category/6905.html</link><description>G-G-S,D-D-U!</description><language>zh-cn</language><lastBuildDate>Tue, 03 Jul 2007 20:50:48 GMT</lastBuildDate><pubDate>Tue, 03 Jul 2007 20:50:48 GMT</pubDate><ttl>60</ttl><item><title>how to write __FILE__ and __LINE__ in C#</title><link>http://www.blogjava.net/jinfeng_wang/archive/2007/07/03/127829.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Tue, 03 Jul 2007 06:16:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2007/07/03/127829.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/127829.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2007/07/03/127829.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/127829.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/127829.html</trackback:ping><description><![CDATA[class SomeClass<br>{<br>public int DoSomething()<br>{<br>ReportError("Here's an error message");<br>return 0;<br>}<br><br>private void ReportError(string Message)<br>{<br>// Get the frame one step up the call tree<br><a href="http://www.dotnet247.com/247reference/System/Diagnostics/StackFrame.aspx"><u><font color=#0000ff>StackFrame</font></u></a> CallStack = new <a href="http://www.dotnet247.com/247reference/System/Diagnostics/StackFrame.aspx"><u><font color=#0000ff>StackFrame</font></u></a>(1, true);<br><br>// These will now show the file and line number of the ReportError<br>call in the DoSomething() method<br>string SourceFile = CallStack.GetFileName(),<br>int SourceLine = CallStack.GetFileLineNumber(),<br>MyWriteToFile("Error: " + Message + " - File: " + SourceFile + "<br>Line: " + SourceLine.ToString());<br>}<br>}<br>
<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/127829.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2007-07-03 14:16 <a href="http://www.blogjava.net/jinfeng_wang/archive/2007/07/03/127829.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VSS 分支管理 （很恶心的操作顺序）</title><link>http://www.blogjava.net/jinfeng_wang/archive/2007/01/29/96523.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Mon, 29 Jan 2007 07:58:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2007/01/29/96523.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/96523.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2007/01/29/96523.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/96523.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/96523.html</trackback:ping><description><![CDATA[Sharing/Branching in VSS（zz)<br /><a href="http://blogs.vertigosoftware.com/ericc/archive/2005/12/05/1716.aspx">http://blogs.vertigosoftware.com/ericc/archive/2005/12/05/1716.aspx</a><br /><br /><br /><p><font face="Verdana" size="2">Recently I was tasked to share/branch a complex source tree in <a href="http://msdn.microsoft.com/vstudio/previous/ssafe/">Visual SourceSafe 6.0</a> to do some changes with our project. For some reason, I found it very hard to do and I kept getting this error:</font></p><p><font face="Verdana" size="2"><img src="http://blogs.vertigosoftware.com/photos/ericc/images/1717/original.aspx" /></font></p><p><font face="Verdana" size="2">What the heck does "A project cannot be shared under a descendant" mean? After some testing, it turns out the reason for this error is because VSS attempts to add the folder you specified <strong>to itself</strong>. That is why this is a recursive error: you are adding a folder to the folder you are recursively scanning. I tried specifying a path (ie. <font face="Courier New">$/ProjectA-Copied</font>), but it refuses to recognize the full path and keeps wanting to add to itself (<font face="Courier New">$/ProjectA/ProjectA-Copied</font>). </font><font face="Verdana" size="2">For the life of me, I just couldn't get VSS to share to another location. </font></p><p><font face="Verdana" size="2">After asking around some people, <a href="http://blogs.vertigosoftware.com/paul/default.aspx">Paul </a>(thanks!) told me that the problem is when you select Share on a project (aka folder) in VSS Explorer, <strong>you are selecting the destination project, not the source</strong>. Boy... great user experience isn't it?</font></p><p><font face="Verdana" size="2">Armed with this key piece of knowledge, I created my destination project, selected Share on the destination project, in the share dialog selected the source project, and finally was able to successfully share that source project to the destination project.</font></p><p><font face="Verdana" size="2">Also if you are branching after sharing and you have a project with lots of files, I recommend you use the <strong>Branch after share</strong> check box: </font></p><p><font face="Verdana" size="2"></font><img src="http://blogs.vertigosoftware.com/photos/ericc/images/1718/original.aspx" /></p><p><font face="Verdana" size="2">If you share without branching in one step, then you will have to manually go into the destination project and <strong>branch all the files individually</strong>. Nope, you cannot branch on the project level!</font></p><p><font face="Verdana" size="2">And finally, yes we're using Visual SourceSafe, yes I know it sucks, and finally (what I'm most happy about) yes we will be moving to <a href="http://msdn.microsoft.com/vstudio/teamsystem/team/default.aspx">Team Foundation Server </a>and <a href="http://msdn.microsoft.com/vstudio/products/vsts/suite/default.aspx">Visual Studio Team Suite</a>!<br /><br /><br /></font></p><img src ="http://www.blogjava.net/jinfeng_wang/aggbug/96523.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2007-01-29 15:58 <a href="http://www.blogjava.net/jinfeng_wang/archive/2007/01/29/96523.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ADO.NET Connection Status Map</title><link>http://www.blogjava.net/jinfeng_wang/archive/2006/06/03/50173.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Sat, 03 Jun 2006 13:35:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2006/06/03/50173.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/50173.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2006/06/03/50173.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/50173.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/50173.html</trackback:ping><description><![CDATA[
		<img src="http://www.blogjava.net/images/blogjava_net/jinfeng_wang/6626/r_ConnectionStatus.JPG" />
<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/50173.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2006-06-03 21:35 <a href="http://www.blogjava.net/jinfeng_wang/archive/2006/06/03/50173.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Checked Exception VS UnChecked Excetion (续2)</title><link>http://www.blogjava.net/jinfeng_wang/archive/2006/06/03/50170.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Sat, 03 Jun 2006 13:22:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2006/06/03/50170.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/50170.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2006/06/03/50170.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/50170.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/50170.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal">
				<span style="font-family: &quot;ＭＳ 明朝&quot;;" lang="ZH-CN">　　</span>
				<span style="font-family: SimSun;" lang="ZH-CN">假设我的团队正在开发一个库程序，由于某种原因，现在希望能够得到所有最外层</span>
				<span style="" lang="EN-US">API</span>
				<span style="font-family: SimSun;" lang="ZH-CN">所抛出的所有异常的类型、各自的信息、并且能够附上各种异常所出现的原因和解决办法。如果开发过程中内部使用的是</span>
				<span style="" lang="EN-US">Unchecked
Exception</span>
				<span style="font-family: SimSun;" lang="ZH-CN">，那么对于这个任务简直就麻烦了。没办法，开发人员一个个的自我进行检查然后统计吧，但是往往这样的统计总会有漏网之鱼。现在的</span>
				<span style="" lang="EN-US">MSDN</span>
				<span style="font-family: SimSun;" lang="ZH-CN">中的异常信息糟糕的很，最底层的公有库的异常信息内容可能完整一点，但是上层的库的异常信息糟糕的不行，根本不能完整的报全所有出错的可能性。</span>
				<span style="" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-indent: 21pt;">
				<span style="font-family: SimSun;" lang="ZH-CN">你可以想象的出，一个库函数的异常信息不完整，对于他的用户来说，是多么不友好的事情。假设</span>
				<span style="" lang="EN-US">MSDN</span>
				<span style="font-family: SimSun;" lang="ZH-CN">中</span>
				<span style="" lang="EN-US">File.Open()</span>
				<span style="font-family: SimSun;" lang="ZH-CN">会抛出</span>
				<span style="" lang="EN-US">IOException</span>
				<span style="font-family: SimSun;" lang="ZH-CN">，你的程序就很难想到很规矩的对</span>
				<span style="" lang="EN-US">IOException</span>
				<span style="font-family: SimSun;" lang="ZH-CN">做了</span>
				<span style="" lang="EN-US">catch</span>
				<span style="font-family: SimSun;" lang="ZH-CN">，然后提示用户检查相应位置的文件是否存在</span>
				<span style="" lang="EN-US">/</span>
				<span style="font-family: SimSun;" lang="ZH-CN">被打开等。别指望</span>
				<span style="" lang="EN-US">MSDN</span>
				<span style="font-family: SimSun;" lang="ZH-CN">的那些信息能够对终端用户有多大的帮助，太多不懂计算机的人在傻呆呆的握着鼠标了。再加上</span>
				<span style="" lang="EN-US">MicroSoft</span>
				<span style="font-family: SimSun;" lang="ZH-CN">的提示信息本身就存在着“答非所问”，“莫名其妙”的事情，用户看到这些情况就更不知道怎么解决问题了。再加上自己的应用程序中会弹出一个个“蹩脚”的运行时错误的错误框，真的不是一个很如意的创作。</span>
				<span style="" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal">
				<span style="" lang="EN-US">
						<span style=""> </span>
						<span style=""> </span>
						<span style=""> </span>
						<span style=""> </span>
				</span>
				<span style="font-family: SimSun;" lang="ZH-CN">但是，如果使用的是</span>
				<span style="" lang="EN-US">Checked Exception</span>
				<span style="font-family: SimSun;" lang="ZH-CN">，这时候编译器会强迫你的外部接口的异常相当的完整，最起码可以做到比</span>
				<span style="" lang="EN-US">MSDN</span>
				<span style="font-family: SimSun;" lang="ZH-CN">的异常类型齐整。</span>
				<span style="" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal">
				<span style="" lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal">
				<span style="" lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal">
				<span style="" lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal">
				<span style="" lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/50170.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2006-06-03 21:22 <a href="http://www.blogjava.net/jinfeng_wang/archive/2006/06/03/50170.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>数据库驱动程序的测试需要注意的问题</title><link>http://www.blogjava.net/jinfeng_wang/archive/2006/05/28/48597.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Sun, 28 May 2006 07:52:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2006/05/28/48597.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/48597.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2006/05/28/48597.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/48597.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/48597.html</trackback:ping><description><![CDATA[
		<div>
				<font face="MS UI Gothic" size="2">
						<font color="#ff0000">1. 不要用TestCase的构造函数初始化Fixture，而要用<br />setUp()和tearDown()方法。</font>
				</font>
		</div>
		<div>
				<font face="MS UI Gothic" size="2">
						<font color="#ff0000">
								<br />
						</font>2. 不要依赖或假定测试运行的顺序，因为JUnit利用<br />Vector保存测试方法。所以不同的平台会按不同的<br />顺序从Vector中取出测试方法。 <br /><br /><font color="#ff0000"></font></font>
		</div>
		<div>
				<font face="MS UI Gothic" size="2">
						<font color="#ff0000">3. 避免编写有副作用的TestCase。例如：如果随后的<br />测试依赖于某些特定的交易数据，就不要提交交易数<br />据。简单的会滚就可以了。</font>
						<br />
				</font>
		</div>
		<div>
				<font face="MS UI Gothic" size="2">
						<font color="#ff0000">
								<br />  对于我们来说，有时是必须要提交，以至于有副作用的。</font>
				</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">  例如：在执行“插入“后，数据库显然会多出一条数<br />据来。那么必须在随后每个测试自己消除自己的副<br />作用。</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">  在这里，就是自己“再删除刚插入的数据”。（这时候<br />需要考虑到这个善后的工作不能自己就不能有副作用，</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">  删除多了其他的数据）。</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">
				</font> </div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">  这里的副作用还指“影响到周围环境”，因为我们现<br />在工作的人比较多，所以最好大家的测试服务器能够<br />分开来，</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2"> 例如一个人一个Database实例（可以建得稍微小一<br />点）或者一个人一个数据库，</font>
				<font face="MS UI Gothic" color="#ff0000" size="2">  注意将这些个人之间<br />有区别的内容用常量在每个人自己的所有程序中公<br />用。而不是分布在各个位置。</font>
				<font face="MS UI Gothic" color="#ff0000" size="2">  否则以后要改换测试<br />服务器，所有的程序都需要改动。</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">
				</font> </div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">  为了保证测试程序能够很容易的到处执行，请保证<br />大家的数据库服务器的测试数据全部一致。</font>
				<font face="MS UI Gothic" color="#ff0000" size="2"> 否则，<br />就不能做到很容易得拿到FJ也可以很容易的运行，<br />所以需要准备“测试数据集“。</font>
				<font face="MS UI Gothic" color="#ff0000" size="2">包括：Schema ,table ，<br />stored procedure等数据库对象的结构一致，</font>
				<font face="MS UI Gothic" color="#ff0000" size="2"> 还包<br />括数据库的数据内容保持一致。</font>
		</div>
		<font face="MS UI Gothic" size="2">
				<div>
						<br />4. 当继承一个测试类时，记得调用父类的setUp()和<br />tearDown()方法。 </div>
				<div>
						<br />5. 将测试代码和工作代码放在一起，一边同步编译<br />和更新。（使用Ant中有支持junit的task.） </div>
				<div>
						<br />6. 测试类和测试方法应该有一致的命名方案。如在<br />工作类名前加上test从而形成测试类名。 </div>
				<div>
						<font color="#ff0000">可能这里我们需要改动，将函数名和我们的测试用<br />例的编号一致起来。</font>
				</div>
				<div>
						<br />7. 确保测试与时间无关，不要依赖使用过期的数据<br />进行测试。导致在随后的维护过程中很难重现测试。 </div>
				<div>
						<br />8. 如果你编写的软件面向国际市场，编写测试时要<br />考虑国际化的因素。不要仅用母语的Locale进行测试。 </div>
				<div>
						<br />9. 尽可能地利用JUnit提供地assert/fail方法以及<br />异常处理的方法，可以使代码更为简洁。 </div>
				<div> </div>
				<div>
						<font color="#ff0000">这个内容有其关键，assert语句的好坏直接影响<br />到测试的正确性。</font>
						<font color="#ff0000">因为assert就是用于当前测试<br />项的正确性的。</font>
				</div>
				<div>
						<br />10.测试要尽可能地小，执行速度快。 <br /><br /><br />==========<br />1）将所有的数据库的测试数据用ODBC程序自动<br />生成的。 <font face="MS UI Gothic" size="2">用户可以简单的</font><font face="MS UI Gothic" size="2">修改ConnectionString，<br />然后运行程序，就可以创建生成数</font><font face="MS UI Gothic" size="2">据库/数据库<br />表/存储结构</font><font face="MS UI Gothic" size="2">，并且自动插入数据。<br /></font><div><font face="MS UI Gothic" size="2"></font> </div><div><font face="MS UI Gothic" size="2">   2）为了保证多个测试人员的不干扰，建议分别<br />各自单独使用自己的数据</font><font face="MS UI Gothic" size="2">库。否则会因为一个自<br />己的错误，影响别人的工作。</font></div><div><font face="MS UI Gothic" size="2"></font> </div><div><font face="MS UI Gothic" size="2">   3）在自己的程序中，所有涉及环境的内容都用<br />单独放到一个类中，用static</font><font face="MS UI Gothic" size="2">常量共享使用（这样<br />就便于很容易的更换环境再进行测试，做到很容<br />易的移植</font><font face="MS UI Gothic" size="2">测试环境）。</font></div><div><font face="MS UI Gothic" size="2"></font> </div><div><font face="MS UI Gothic" size="2">   4）关于数据库表结构，我建议测试表中含有一<br />个主键，我们在插入数据的时</font><font face="MS UI Gothic" size="2">候，保证测试用例，<br />测试用例程序，测试用例程序中的数据，这三者<br />的编号一</font><font face="MS UI Gothic" size="2">致起来。便于出现问题时，可以排除数据。</font></div></div>
		</font>
<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/48597.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2006-05-28 15:52 <a href="http://www.blogjava.net/jinfeng_wang/archive/2006/05/28/48597.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>数据库驱动程序测试的建议</title><link>http://www.blogjava.net/jinfeng_wang/archive/2006/05/28/48596.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Sun, 28 May 2006 07:32:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2006/05/28/48596.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/48596.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2006/05/28/48596.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/48596.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/48596.html</trackback:ping><description><![CDATA[
		<div>
				<font face="MS UI Gothic" size="2">
						<font color="#ff0000">1. 不要用TestCase的构造函数初始化Fixture，而要用<br />setUp()和tearDown()方法。</font>
				</font>
		</div>
		<div>
				<font face="MS UI Gothic" size="2">
						<font color="#ff0000">
								<br />
						</font>2. 不要依赖或假定测试运行的顺序，因为JUnit利用<br />Vector保存测试方法。所以不同的平台会按不同的<br />顺序从Vector中取出测试方法。 <br /><br /><font color="#ff0000"></font></font>
		</div>
		<div>
				<font face="MS UI Gothic" size="2">
						<font color="#ff0000">3. 避免编写有副作用的TestCase。例如：如果随后的<br />测试依赖于某些特定的交易数据，就不要提交交易<br />数据。简单的会滚就可以了。<br /></font>
						<br />
				</font>
		</div>
		<div>
				<font face="MS UI Gothic" size="2">
						<font color="#ff0000">  对于我们来说，有时是必须要提交，以至于有副作用的。</font>
				</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">  例如：在执行“插入“后，数据库显然会多出一条数据来。<br />那么必须在随后每个测试自己消除自己的副作用。</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">  在这里，就是自己“再删除刚插入的数据”。（这时候需要<br />考虑到这个善后的工作不能自己就不能有副作用，</font>
				<font face="MS UI Gothic" color="#ff0000" size="2">  删除<br />多了其他的数据）。</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">
				</font> </div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">  这里的副作用还指“影响到周围环境”，因为我们现在工<br />作的人比较多，所以最好大家的测试服务器能够分开来，</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2"> 例如一个人一个Database实例（可以建得稍微小一点）或<br />者一个人一个数据库，</font>
				<font face="MS UI Gothic" color="#ff0000" size="2">  注意将这些个人之间有区别的内<br />容用常量在每个人自己的所有程序中公用。而不是分布在<br />各个位置。</font>
				<font face="MS UI Gothic" color="#ff0000" size="2">  否则以后要改换测试服务器，所有的程序都需<br />要改动。</font>
		</div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">
				</font> </div>
		<div>
				<font face="MS UI Gothic" color="#ff0000" size="2">  为了保证测试程序能够很容易的到处执行，请保证大家<br />的数据库服务器的测试数据全部一致。</font>
				<font face="MS UI Gothic" color="#ff0000" size="2"> 否则，就不能做到<br />很容易得拿到FJ也可以很容易的运行，所以需要准备“测<br />试数据集“。</font>
				<font face="MS UI Gothic" color="#ff0000" size="2">包括：Schema ,table ，stored procedure等数据<br />库对象的结构一致，</font>
				<font face="MS UI Gothic" color="#ff0000" size="2"> 还包括数据库的数据内容保持一致。</font>
		</div>
		<font face="MS UI Gothic" size="2">
				<div>
						<br />4. 当继承一个测试类时，记得调用父类的setUp()和tearDown()方法。 </div>
				<div>
						<br />5. 将测试代码和工作代码放在一起，一边同步编译和更新。<br />（使用Ant中有支持junit的task.） </div>
				<div>
						<br />6. 测试类和测试方法应该有一致的命名方案。如在工作类<br />名前加上test从而形成测试类名。 </div>
				<div>
						<font color="#ff0000">可能这里我们需要改动，将函数名和我们的测试用例的编号一致起来。</font>
				</div>
				<div>
						<br />7. 确保测试与时间无关，不要依赖使用过期的数据进行测试。<br />导致在随后的维护过程中很难重现测试。 </div>
				<div>
						<br />8. 如果你编写的软件面向国际市场，编写测试时要考虑国际<br />化的因素。不要仅用母语的Locale进行测试。 </div>
				<div>
						<br />9. 尽可能地利用JUnit提供地assert/fail方法以及异常处理的<br />方法，可以使代码更为简洁。 </div>
				<div> </div>
				<div>
						<font color="#ff0000">这个内容有其关键，assert语句的好坏直接影响到测试的正确性。</font>
				</div>
				<div>
						<font color="#ff0000">因为assert就是用于当前测试项的正确性的。</font>
				</div>
				<div>
						<br />10.测试要尽可能地小，执行速度快。 <br /><br />=============<br /> 1）将所有的数据库的测试数据程序自动生成的。 
<div><font face="MS UI Gothic" size="2">用户可以简单的</font><font face="MS UI Gothic" size="2">修改ConnectionString，然后运行程序，<br />就可以创建生成数</font><font face="MS UI Gothic" size="2">据库/数据库表/存储结构</font><font face="MS UI Gothic" size="2">，并且自动<br />插入数据。 <br /></font><font face="MS UI Gothic" size="2"></font></div><div><font face="MS UI Gothic" size="2"><br />   2）为了保证多个测试人员的不干扰，建议分别各自<br />单独使用自己的数据</font><font face="MS UI Gothic" size="2">库。否则会因为一个自己的错误，<br />影响别人的工作。</font></div><div><font face="MS UI Gothic" size="2"></font> </div><div><font face="MS UI Gothic" size="2">   3）在自己的程序中，所有涉及环境的内容都用单独<br />放到一个类中，用static</font><font face="MS UI Gothic" size="2">常量共享使用（这样就便于很<br />容易的更换环境再进行测试，做到很容易的移植</font><font face="MS UI Gothic" size="2">测试<br />环境）。</font></div><div><font face="MS UI Gothic" size="2"></font> </div><div><font face="MS UI Gothic" size="2">   4）关于数据库表结构，我建议测试表中含有一个主键，<br />我们在插入数据的时</font><font face="MS UI Gothic" size="2">候，保证测试用例，测试用例程序，<br />测试用例程序中的数据，这三者的编号一</font><font face="MS UI Gothic" size="2">致起来。便于<br />出现问题时，可以排除数据。</font></div></div>
		</font>
<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/48596.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2006-05-28 15:32 <a href="http://www.blogjava.net/jinfeng_wang/archive/2006/05/28/48596.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Checked Exception VS UnChecked Excetion (续)</title><link>http://www.blogjava.net/jinfeng_wang/archive/2006/05/12/45911.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Fri, 12 May 2006 12:21:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2006/05/12/45911.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/45911.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2006/05/12/45911.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/45911.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/45911.html</trackback:ping><description><![CDATA[
		<p>上篇：<a href="/jinfeng_wang/archive/2006/05/11/45726.html">http://www.blogjava.net/jinfeng_wang/archive/2006/05/11/45726.html</a><br /><br />先来回复两个回帖：<br />"你可以把IO等异常转化成你类库中中定义的异常。当然你定义的异常是Checked Exception 还是 UnChecked Excetion 那你自己定了。 "<br /><br />假设我按照这条建议去做了，那么我可以抛出XXXLibException。假设我的异常采用的是CheckedException，那么客户程序员可以捕捉它。但是对于不同的出错原因（例如不同的原因，包括无权限、硬盘满、U盘被拔了等等，导致无法正常写日志文件），程序都是捕捉XXXLibException，那么客户程序员就无法根据不同的异常去做相应的处理（例如提示用户修改权限、直接启用备用目录，直接退出程序）。总之，如果异常类型不同，客户程序可以根据“异常类型”做不同的工作（编译器＋工具可以实现自动代码生成）；但是如果全部合并为一个异常，那么客户程序只能根据“ExceptionMessage”尝试着做不同的工作（恰恰目前没有办法完成自动编码）。<br /><br /><br /><br />"要知道 JDK 的 FileWriter 是可以抛出 IOException 的子类的，只要文档足够详细，Java代码中也可以只去捕捉更明细的异常， 也可以就捕捉并重新抛出包装过的异常（甚至是RuntimException），除非呆板地去捕获每个异常，不然代码怎么会丑陋呢？"<br /><br />RuntiomeException，也就是UncheckedException（类于.NET的Exception），它不会要求客户代码强行捕捉异常，据此我写了下面的一个程序：<br />private void button1_Click(object sender, System.EventArgs e)<br />  {<br />   throw new Exception("s");<br />  }<br />     我只试了.NET的程序，出现的界面大家自己试 。因为UncheckedException没有要求客户程序去捕捉（客户程序员不能自觉的发现库中抛出的各种异常），让最终用户直接面对这样的异常，是一个道德的事情么？<br /></p>
<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/45911.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2006-05-12 20:21 <a href="http://www.blogjava.net/jinfeng_wang/archive/2006/05/12/45911.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Checked Exception  VS UnChecked  Excetion</title><link>http://www.blogjava.net/jinfeng_wang/archive/2006/05/11/45726.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Thu, 11 May 2006 13:18:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2006/05/11/45726.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/45726.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2006/05/11/45726.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/45726.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/45726.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b>
						<span lang="EN-US">1</span>
				</b>
				<b>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span>
						<span lang="EN-US">.NET Framework IO Interface<span style="mso-spacerun: yes">  </span>and<span style="mso-spacerun: yes">  </span>JDK IO Interface<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b>
						<span lang="EN-US">1.1</span>
				</b>
				<b>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">．</span>
						<span lang="EN-US">.NET Framework 1.1<o:p></o:p></span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">   </span>public StreamWriter(<span style="mso-spacerun: yes">    </span>string path<span style="mso-spacerun: yes">  </span>);</span>
		</p>
		<h4 style="MARGIN: 12pt 0cm 4.8pt -13.5pt">
				<span style="FONT-SIZE: 8pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">异常</span>
				<span lang="EN-US" style="FONT-SIZE: 8pt">
						<o:p>
						</o:p>
				</span>
		</h4>
		<p>
		</p>
		<table style="BORDER-RIGHT: #999999 0.75pt solid; BORDER-TOP: #999999 0.75pt solid; BACKGROUND: #999999; BORDER-LEFT: #999999 0.25pt solid; WIDTH: 105.8%; BORDER-BOTTOM: #999999 0.25pt solid; mso-cellspacing: 0cm" cellspacing="0" cellpadding="0" width="105%" bgcolor="#999999" border="1">
				<tbody>
						<tr style="HEIGHT: 19.3pt">
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 38.9%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; HEIGHT: 19.3pt; BACKGROUND-COLOR: transparent" valign="top" width="38%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt; TEXT-ALIGN: center" align="center">
												<b>
														<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">异常类型</span>
												</b>
												<b>
														<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
																<o:p>
																</o:p>
														</span>
												</b>
										</p>
								</td>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 61.1%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; HEIGHT: 19.3pt; BACKGROUND-COLOR: transparent" valign="top" width="61%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt; TEXT-ALIGN: center" align="center">
												<b>
														<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">条件</span>
												</b>
												<b>
														<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
																<o:p>
																</o:p>
														</span>
												</b>
										</p>
								</td>
						</tr>
						<tr style="HEIGHT: 13.35pt">
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 38.9%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; HEIGHT: 13.35pt; BACKGROUND-COLOR: transparent" valign="top" width="38%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
														<a href="http://msdn.microsoft.com/library/CHS/cpref/html/frlrfsystemunauthorizedaccessexceptionclasstopic.asp">UnauthorizedAccessException</a>
												</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 61.1%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; HEIGHT: 13.35pt; BACKGROUND-COLOR: transparent" valign="top" width="61%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">访问被拒绝。</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
						</tr>
						<tr style="HEIGHT: 15.15pt">
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 38.9%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; HEIGHT: 15.15pt; BACKGROUND-COLOR: transparent" valign="top" width="38%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
														<a href="http://msdn.microsoft.com/library/CHS/cpref/html/frlrfsystemargumentexceptionclasstopic.asp">ArgumentException</a>
												</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 61.1%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; HEIGHT: 15.15pt; BACKGROUND-COLOR: transparent" valign="top" width="61%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<i>
														<span lang="EN-US" style="FONT-FAMILY: Verdana">path</span>
												</i>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
												</span>
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">为空字符串</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">("")</span>
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">。</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
						</tr>
						<tr>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 38.9%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; BACKGROUND-COLOR: transparent" valign="top" width="38%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
														<a href="http://msdn.microsoft.com/library/CHS/cpref/html/frlrfsystemargumentnullexceptionclasstopic.asp">ArgumentNullException</a>
												</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 61.1%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; BACKGROUND-COLOR: transparent" valign="top" width="61%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<i>
														<span lang="EN-US" style="FONT-FAMILY: Verdana">path</span>
												</i>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
												</span>
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">为空引用（</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">Visual Basic </span>
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中为</span>
												<span style="FONT-FAMILY: Verdana">
														<b>
																<span lang="EN-US">Nothing</span>
														</b>
												</span>
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">）。</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
						</tr>
						<tr>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 38.9%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; BACKGROUND-COLOR: transparent" valign="top" width="38%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
														<a href="http://msdn.microsoft.com/library/CHS/cpref/html/frlrfsystemiodirectorynotfoundexceptionclasstopic.asp">DirectoryNotFoundException</a>
												</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 61.1%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; BACKGROUND-COLOR: transparent" valign="top" width="61%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">指定的路径无效，比如在未映射的驱动器上。</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
						</tr>
						<tr>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 38.9%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; BACKGROUND-COLOR: transparent" valign="top" width="38%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
														<a href="http://msdn.microsoft.com/library/CHS/cpref/html/frlrfsystemiopathtoolongexceptionclasstopic.asp">PathTooLongException</a>
												</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 61.1%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; BACKGROUND-COLOR: transparent" valign="top" width="61%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">指定的路径、文件名或者两者都超出了系统定义的最大长度。例如，在基于</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">Windows </span>
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的平台上，路径必须小于</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">248 </span>
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">个字符，文件名必须小于</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">260 </span>
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">个字符。</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
						</tr>
						<tr>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 38.9%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; BACKGROUND-COLOR: transparent" valign="top" width="38%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
														<a href="http://msdn.microsoft.com/library/CHS/cpref/html/frlrfsystemioioexceptionclasstopic.asp">IOException</a>
												</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 61.1%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; BACKGROUND-COLOR: transparent" valign="top" width="61%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<i>
														<span lang="EN-US" style="FONT-FAMILY: Verdana">path</span>
												</i>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
												</span>
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">包含不正确或无效的文件名、目录名或卷标的语法。</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
						</tr>
						<tr>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 38.9%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; BACKGROUND-COLOR: transparent" valign="top" width="38%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
														<a href="http://msdn.microsoft.com/library/CHS/cpref/html/frlrfsystemsecuritysecurityexceptionclasstopic.asp">SecurityException</a>
												</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
								<td style="BORDER-RIGHT: #999999; PADDING-RIGHT: 0.75pt; BORDER-TOP: #999999; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; BORDER-LEFT: #999999; WIDTH: 61.1%; PADDING-TOP: 0.75pt; BORDER-BOTTOM: #999999; BACKGROUND-COLOR: transparent" valign="top" width="61%">
										<p class="MsoNormal" style="MARGIN: 7.2pt 0cm 3.6pt">
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">调用方没有所要求的权限。</span>
												<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: Verdana">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
						</tr>
				</tbody>
		</table>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b>
						<span lang="EN-US">1.2 JDK 1.4.2 :<o:p></o:p></span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">public FileWriter(String fileName)<span style="mso-spacerun: yes">  </span>throws IOException</span>
		</p>
		<pre>
				<span lang="EN-US">Constructs a FileWriter object given a file name. </span>
		</pre>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b>
						<span lang="EN-US">Parameters:</span>
				</b>
				<span lang="EN-US">
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 36pt">
				<code>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 黑体">fileName</span>
				</code>
				<span lang="EN-US">- String The system-dependent filename. </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b>
						<span lang="EN-US">Throws:</span>
				</b>
				<span lang="EN-US">
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 36pt">
				<code>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 黑体">
								<a title="class in java.io" href="file:///D:JDK_DOC%25201.4docsapijavaioIOException.html">IOException</a>
						</span>
				</code>
				<span lang="EN-US">- if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b>
						<span lang="EN-US">2</span>
				</b>
				<b>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、解析</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">
				<span lang="EN-US">.NET</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">Excetpion</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是</span>
				<span lang="EN-US">Unchecked</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">异常，客户端不要求去</span>
				<span lang="EN-US">Check</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码，但是</span>
				<span lang="EN-US">JAVA</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的绝大部分</span>
				<span lang="EN-US">Checked</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">异常，它要求客户端的代码检测异常。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt; mso-char-indent-count: 2.07; mso-char-indent-size: 10.5pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">假设一个这样的场景，方法</span>
				<span lang="EN-US">OutMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">调用</span>
				<span lang="EN-US">InnerMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，而内部方法</span>
				<span lang="EN-US">InnerMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">抛出的异常</span>
				<span lang="EN-US">InnerException</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt; mso-char-indent-count: 2.07; mso-char-indent-size: 10.5pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对于</span>
				<span lang="EN-US">Java</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">CheckedException</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，或者</span>
				<span lang="EN-US">OutMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">去抛出</span>
				<span lang="EN-US">InnerException</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，或者</span>
				<span lang="EN-US">OutMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">捕捉</span>
				<span lang="EN-US">InnerException</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（然后做处理）。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">再来观察一下</span>
				<span lang="EN-US">JDK</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">FileWriter</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的异常声明，我没有详细测试其在各种可能出错情况下抛出的</span>
				<span lang="EN-US">IOException</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的消息，但是其分类远远不如</span>
				<span lang="EN-US">.NET</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">StreamWriter</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。假设</span>
				<span lang="EN-US">Java</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">想照抄</span>
				<span lang="EN-US">.NET</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">StreamWriter</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，对于</span>
				<span lang="EN-US">Java</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的使用者来说，无异于恶梦。外部的代码需要捕获如此多的异常消息（不捕捉就会在</span>
				<span lang="EN-US">OutMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">抛出一大堆的异常，问题继续传播下去，这是</span>
				<span lang="EN-US">CheckException</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的一个弱点）。也许正是出于这样的问题，所以此处</span>
				<span lang="EN-US">Java</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口的异常声明比较简单。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">那么假设我是一个库设计者，正在用到了</span>
				<span lang="EN-US">IO</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。如果我使用</span>
				<span lang="EN-US">.NET</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行开发，对于</span>
				<span lang="EN-US">IOException</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来说，我是否有必要捕捉呢？捕捉的目的是为了“处理”，那么对于库设计者，显然这时候需要通知其“客户程序员”出错的原因，所以这里的库设计者的行为最好就是“不处理”。如果处理，那只能是“</span>
				<span lang="EN-US">catch</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、再</span>
				<span lang="EN-US">throw</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">”。那么这样的处理显然是无意义的，因为原始异常已经足以提醒客户程序员出错的原因了。如果捕捉，那代码会特别的丑陋（直接</span>
				<span lang="EN-US">catch Exception</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的行为是不可取的）。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">
				<span lang="EN-US">CheckedException</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的另外一个缺点就是“将</span>
				<span lang="EN-US">Exceotion</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">加入了</span>
				<span lang="EN-US">Interface</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的规格声明“。假设</span>
				<span lang="EN-US">OutMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">调用了</span>
				<span lang="EN-US">InnerMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，此时</span>
				<span lang="EN-US">InnerMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的设计者需要增加一个异常，那么会直接影响到</span>
				<span lang="EN-US">OutMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。当然这里的</span>
				<span lang="EN-US">InnerMethod</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的设计者此时已经做了“修改接口声明“的行为。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"> </p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">
				<span lang="EN-US">
						<br />   随后待续...... <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p> </p>
<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/45726.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2006-05-11 21:18 <a href="http://www.blogjava.net/jinfeng_wang/archive/2006/05/11/45726.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>测试、构建和重构(zz)</title><link>http://www.blogjava.net/jinfeng_wang/archive/2006/04/26/43358.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Wed, 26 Apr 2006 08:52:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2006/04/26/43358.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/43358.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2006/04/26/43358.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/43358.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/43358.html</trackback:ping><description><![CDATA[
		<div class="entrylistTitle">测试、构建和重构</div>
		<div class="entrylistDescription">
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl00_TitleUrl" href="http://www.cnblogs.com/confach/archive/2005/06/20/177817.html" target="_blank">NUnit2.0详细使用方法</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl01_TitleUrl" href="http://www.cnblogs.com/excel/archive/2005/06/17/176100.html" target="_blank">重构啊重构</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl02_TitleUrl" href="http://www.cnblogs.com/snowwolf/archive/2004/06/18/16644.html" target="_blank">.Net Code Cover</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl03_TitleUrl" href="http://www.cnblogs.com/william_fire/archive/2004/11/15/63867.html" target="_blank">让代码更具有可测试性</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl04_TitleUrl" href="http://www.cnblogs.com/anf/archive/2005/03/20/122342.html" target="_blank">NMock --- 从零开始</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl05_TitleUrl" href="http://www.cnblogs.com/jiezhi/archive/2005/04/28/146779.html" target="_blank">Unit Test : rules,design and strategy</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl06_TitleUrl" href="http://blog.joycode.com/musicland/archive/2005/04/16/48690.aspx" target="_blank">Concurrent connection limit</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl07_TitleUrl" href="http://www.cnblogs.com/iaxes/articles/121158.html" target="_blank">Log4Net Appender 之 ADONetAppender</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl08_TitleUrl" href="http://www.cnblogs.com/dahuzizyd/archive/2005/03/04/112566.html" target="_blank">Bug管理的流程和几个重点</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl09_TitleUrl" href="http://blog.joycode.com/ghj/articles/44720.aspx" target="_blank">把单元测试代码跟项目代码放在一个工程中</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl10_TitleUrl" href="http://www.cnblogs.com/java_aix/archive/2005/02/10/103717.html" target="_blank">Subversion配置安装教程（三） </a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl11_TitleUrl" href="http://www.cnblogs.com/java_aix/archive/2005/02/09/103500.html" target="_blank">Subversion配置安装教程（二） </a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl12_TitleUrl" href="http://www.cnblogs.com/java_aix/archive/2005/02/08/103399.html" target="_blank">Subversion配置安装教程（一）</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl13_TitleUrl" href="http://www.cnblogs.com/william_fire/articles/102245.html" target="_blank">敏捷（AM）：TDD(Test Driven Development）实践与变化--&gt;TAD（Test Assist Development)</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl14_TitleUrl" href="http://blog.joycode.com/uestc95/archive/2005/01/14/43057.aspx" target="_blank">如何在*.CS文件中加入版本跟踪信息？</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl15_TitleUrl" href="http://www.cnblogs.com/xchunyu/archive/2005/01/12/90425.html" target="_blank">推荐一个关于"架构"的演示文稿(PPT)</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl16_TitleUrl" href="http://blog.joycode.com/oldsidney/archive/2005/01/06/42468.aspx" target="_blank">什麼是 LoadRunner？ </a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl17_TitleUrl" href="http://www.cnblogs.com/dudu/archive/2004/12/18/78838.html" target="_blank">推荐一个不错的VS.NET集成单元测试工具TestDriven.NET</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl18_TitleUrl" href="http://www.cnblogs.com/bigtall/archive/2004/11/24/68126.html" target="_blank">实战dailybuild-cc.net的配置</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl19_TitleUrl" href="http://www.cnblogs.com/netcobra/archive/2004/11/24/68204.html" target="_blank">[翻译] NMock 两分钟教程</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl20_TitleUrl" href="http://www.cnblogs.com/netcobra/archive/2004/11/24/68199.html" target="_blank">[翻译] NMock 简介</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl21_TitleUrl" href="http://www.cnblogs.com/william_fire/archive/2004/11/15/64111.html" target="_blank">测试驱动开的的实例</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl22_TitleUrl" href="http://www.cnblogs.com/William_Fire/archive/2004/11/15/63867.html" target="_blank">让代码更具有可测试性</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl23_TitleUrl" href="http://www.cnblogs.com/rickie/archive/2004/11/08/61311.html" target="_blank">重构（Refactoring）技巧读书笔记 之三 </a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl24_TitleUrl" href="http://pfzhou.cnblogs.com/pvistely/archive/2004/11/11/62600.html" target="_blank">第一次用CVS后的流程小结（其实VSS也一样）</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl25_TitleUrl" href="http://pfzhou.cnblogs.com/airforce1st/archive/2004/10/22/55303.html" target="_blank">我也再补充一个NANT使用注意事项</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl26_TitleUrl" href="http://pfzhou.cnblogs.com/rickie/archive/2004/10/04/48859.aspx" target="_blank">重构（Refactoring）技巧读书笔记 之二</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl27_TitleUrl" href="http://pfzhou.cnblogs.com/rickie/archive/2004/09/25/46577.aspx" target="_blank">重构（Refactoring）技巧读书笔记 之一</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl28_TitleUrl" href="http://blog.csdn.net/ycw/archive/2004/09/05/95076.aspx" target="_blank">Bugzilla简明使用手则</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl29_TitleUrl" href="http://pfzhou.cnblogs.com/ccBoy/archive/2004/08/31/38140.aspx" target="_blank">Daily Build 的链接</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl30_TitleUrl" href="http://pfzhou.cnblogs.com/muddle/archive/2004/04/20/6673.aspx" target="_self">Test-Driven Development In .NET 部分译文</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl31_TitleUrl" href="http://pfzhou.cnblogs.com/feidao/archive/2004/06/19/17050.aspx" target="_blank">有关于Refactor(重构)与Source(源)的比较</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl32_TitleUrl" href="http://pfzhou.cnblogs.com/coolbug/archive/2004/07/26/27367.aspx" target="_blank">终于完成了DailyBuild</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl33_TitleUrl" href="http://pfzhou.cnblogs.com/ccBoy/archive/2004/07/26/27363.aspx" target="_blank">用MSBuild.... DailyBuild和软件开发流程的东东</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl34_TitleUrl" href="http://pfzhou.cnblogs.com/coolbug/archive/2004/07/27/27735.aspx" target="_blank">DailyBuild全攻略</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl35_TitleUrl" href="http://pfzhou.cnblogs.com/unruledboy/archive/2004/08/13/33227.aspx" target="_blank">关于Peer Review、代码评审和测试驱动等</a>
				</h5>
		</div>
		<div class="post">
				<h5>
						<a id="FavoriteList1_Favorites_ctl36_TitleUrl" href="http://pfzhou.cnblogs.com/jobs/archive/2004/08/13/33065.aspx" target="_blank">测试开发驱动实践</a>
				</h5>
		</div>
<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/43358.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2006-04-26 16:52 <a href="http://www.blogjava.net/jinfeng_wang/archive/2006/04/26/43358.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> the difference between SqlConnection.IDisposable.Disp­­ose() and SqlConnection.Dispose()</title><link>http://www.blogjava.net/jinfeng_wang/archive/2006/01/23/28985.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Mon, 23 Jan 2006 01:35:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2006/01/23/28985.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/28985.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2006/01/23/28985.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/28985.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/28985.html</trackback:ping><description><![CDATA[<P><A href="http://groups.google.com/group/microsoft.public.dotnet.framework.adonet/browse_frm/thread/eca73047adca7edb/12f1ae6ae176afe1?lnk=raot#12f1ae6ae176afe1">http://groups.google.com/group/microsoft.public.dotnet.framework.adonet/browse_frm/thread/eca73047adca7edb/12f1ae6ae176afe1?lnk=raot#12f1ae6ae176afe1</A><BR><BR><BR><BR>1. <A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A> <BR>&nbsp;1月20日 上午9时56分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： <A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A> - 查找此作者的帖子&nbsp; <BR>日期：19 Jan 2006 17:56:57 -0800 <BR>当地时间：2006年1月20日(星期五) 上午9时56分&nbsp; <BR>主题：the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 删除 | 报告滥用行为&nbsp; </P>
<P>hi, I have a question about the difference between <BR>SqlConnection.IDisposable.Dispose()&nbsp; and&nbsp; SqlConnection.Dispose(). Both <BR>&nbsp;of them realize the function of releasing the connection to the <BR>ConnectionPool?&nbsp; Do they have the same effection source code?&nbsp; If they <BR>are different, who can tell me the differences? If they are same, why <BR>MS gives the SqlConnection.IDisposable.Dispose, but&nbsp; only <BR>SqlConnection.Dispose() method? </P>
<P><BR>In the MSDN, there are following description about the <BR>SqlConnection.IDisposable.Dispose Method: <BR>&nbsp; "This member supports the .NET Framework infrastructure and is not <BR>intended to be used directly from your code."&nbsp; what's the meaning of <BR>it? </P>
<P><BR>If the user has called the SqlConnection.IDisposable.Dispose() in the <BR>client application, what probem results in?&nbsp; and if there are some <BR>problem becomes, then why did MS give us such a method? </P>
<P><BR>in the same, who can tell me the using of <BR>"SqlConnection.ICloneable.Clone ", <BR>"SqlConnection.IDbConnection.BeginTransaction" and <BR>"SqlConnection.IDbConnection.CreateCommand"? </P>
<P><BR>Anybody can help me to solve my question? thanks a lot. </P>
<P><BR>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P><BR>&nbsp;&nbsp; 2. Cor Ligthert [MVP] <BR>&nbsp;1月20日 下午3时10分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "Cor Ligthert [MVP]" &lt;<A href="mailto:notmyfirstn...@planet.nl">notmyfirstn...@planet.nl</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：Fri, 20 Jan 2006 08:10:00 +0100 <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 报告滥用行为&nbsp; </P>
<P>JinFeng, </P>
<P><BR>Both of them are removing the connectionstring from the connectionobject. <BR>They both have nothing to do direct with the ConnectionPool, although you <BR>should close a connection either by close or dispose to let the <BR>ConnectionPool do its job. </P>
<P><BR>Every Interface can be used to get its members (in the implementing <BR>contract) from the implementing class. Therefore it is an interface. A good <BR>programmer start the name of his interfaces all with a capital I. </P>
<P><BR>I hope that this gives an idea </P>
<P><BR>Cor </P>
<P><BR>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P><BR>&nbsp;&nbsp; 3. <A href="mailto:jinfeng_Wang@msn.com">jinfeng_Wang@msn.com</A> <BR>&nbsp;1月20日 下午5时52分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>" &lt;<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：20 Jan 2006 01:52:12 -0800 <BR>当地时间：2006年1月20日(星期五) 下午5时52分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 删除 | 报告滥用行为&nbsp; </P>
<P>hello, Cor . thanks for you answer. but it's not what i want. </P>
<P><BR>please read the following URL and look at the left frame: <BR><A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre</A>... </P>
<P><BR>there are two methods in the SQLConnection: <BR>&nbsp;"Dispose"&nbsp; and&nbsp; "SqlConnection.IDisposable.Dispose" Method. </P>
<P><BR>and in MSDN , the description about the <BR>"SqlConnection.IDisposable.Dispose" is:&nbsp; "This member supports the .NET <BR>Framework infrastructure and is not intended to be used directly from <BR>your code". <BR>can you help to tell me, what's the meaning of the above setence? MS <BR>advice me that i should not call the <BR>"SqlConnection.IDisposable.Dispose", yeah? </P>
<P><BR>if there is a client code, like this&nbsp; (copied from&nbsp; MSDN, and i have <BR>modified it): <BR>public void ReadMyData() <BR>{ <BR>&nbsp;&nbsp;&nbsp; String&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myConnString = "Persist Security Info=False;User <BR>ID=sa;Initial Catalog=Northwind;Data Source=DTK-S-SVR;User <BR>ID=sa;Pwd=sa"; <BR>&nbsp;&nbsp; string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders"; <BR>&nbsp;&nbsp; SqlConnection myConnection = new SqlConnection(myConnString); <BR>&nbsp;&nbsp; SqlCommand myCommand = new SqlCommand(mySelectQuery,myConnection); <BR>&nbsp;&nbsp; myConnection.Open(); <BR>&nbsp;&nbsp; SqlDataReader myReader; <BR>&nbsp;&nbsp; myReader = myCommand.ExecuteReader(); <BR>&nbsp;&nbsp; while (myReader.Read()) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(myReader.GetInt32(0) + ", " + <BR>myReader.GetString(1)); <BR>&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp; myReader.Close(); </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp; //myConnection.Close();&nbsp; // old source code. <BR>&nbsp;&nbsp;&nbsp;&nbsp; IDisposable disposable =myConnection as IDisposable;&nbsp;&nbsp; // new <BR>source code. <BR>&nbsp;&nbsp;&nbsp;&nbsp; disposable.Dispose();&nbsp;&nbsp; // new source code. </P>
<P><BR>} </P>
<P><BR>will it cause some problem when cast the myConnection&nbsp; to IDisposable <BR>and call&nbsp; disposable.Dispose() ? <BR>Does the "new souce code" have the same effect as the "old source code" <BR>?? <BR>if they are, why MS implements the method of "IDisposable.Disp&shy;ose()" <BR>explicity. I means: there is only the SqlConnection.Dispose() method. </P>
<P>if there is no problem here, then can you why MS said that "This member <BR>supports the .NET Framework infrastructure and is not intended to be <BR>used directly from your code."?? <BR>if there is some problem, then why MS does not make the methods of <BR>SqlConnection.IDisposable.Disp&shy;&shy;ose() and SqlConnection.Dispose() <BR>shared the same source code? and why MS tell us that there exists a <BR>"SqlConnection.IDisposable.Disp&shy;&shy;ose()" method, but warn us not to <BR>call it?? </P>
<P><BR>in the same, how about the "SqlConnection.ICloneable.Clone ", <BR>"SqlConnection.IDbConnection.BeginTransaction" and <BR>"SqlConnection.IDbConnection.CreateCommand"? </P>
<P><BR>i do not whether you have understand my question for my poor english <BR>and expression. <BR>can you help me? anyway, thanks to all of you. </P>
<P><BR>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P><BR>&nbsp;&nbsp; 4. Cor Ligthert [MVP] <BR>&nbsp;1月20日 下午6时29分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "Cor Ligthert [MVP]" &lt;<A href="mailto:notmyfirstn...@planet.nl">notmyfirstn...@planet.nl</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：Fri, 20 Jan 2006 11:29:36 +0100 <BR>当地时间：2006年1月20日(星期五) 下午6时29分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 报告滥用行为&nbsp; </P>
<P>JinFeng, </P>
<P><BR>Both Frans and me are not first language English speakers (AFAIK is Frans <BR>born where the native language is Fries and I where it is Dutch). In my <BR>opinion should you never excuse you for your English in these newsgroups. <BR>Almost everybody, no matter how good he can speak a language, will make <BR>errors in email messages (even in his own). I assume that you are using the <BR>English version of Visual Studio so that tells enough. </P>
<P><BR>I thought that the protected dispose is used by component (don't mix this up <BR>with the rest from what I write about component). If you open a form or a <BR>component (by the designer), than you see the implementation of IDisposable <BR>direct. That part is used to do the most of the disposing. </P>
<P><BR>Nice pages about Idisposable are these new ones </P>
<P><BR><A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre</A>... </P>
<P><BR><A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre</A>... </P>
<P><BR>As I said, be aware that if you use a form or a component the code is <BR>already in the designer created part. </P>
<P><BR>However as long discussions has be done in this newsgroup. Disposing and <BR>Closing have the same effect on the connection pool. </P>
<P><BR>I hope this gives some information. </P>
<P><BR>Cor </P>
<P><BR>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P><BR>&nbsp;&nbsp; 5. Frans Bouma [C# MVP] <BR>&nbsp;1月20日 下午4时22分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "Frans Bouma [C# MVP]" &lt;<A href="mailto:perseus.usenetNOS...@xs4all.nl">perseus.usenetNOS...@xs4all.nl</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：Fri, 20 Jan 2006 00:22:50 -0800 <BR>当地时间：2006年1月20日(星期五) 下午4时22分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 报告滥用行为&nbsp; </P>
<P>&nbsp;</P>
<P><BR>- 隐藏被引用文字 -<BR>- 显示引用的文字 -</P>
<P><A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A> wrote: <BR>&gt; hi, I have a question about the difference between <BR>&gt; SqlConnection.IDisposable.Dispose()&nbsp; and&nbsp; SqlConnection.Dispose(). <BR>&gt; Both&nbsp; of them realize the function of releasing the connection to the <BR>&gt; ConnectionPool?&nbsp; Do they have the same effection source code?&nbsp; If they <BR>&gt; are different, who can tell me the differences? If they are same, why <BR>&gt; MS gives the SqlConnection.IDisposable.Dispose, but&nbsp; only <BR>&gt; SqlConnection.Dispose() method? </P>
<P>&gt; In the MSDN, there are following description about the <BR>&gt; SqlConnection.IDisposable.Dispose Method: <BR>&gt;&nbsp;&nbsp; "This member supports the .NET Framework infrastructure and is not <BR>&gt; intended to be used directly from your code."&nbsp; what's the meaning of <BR>&gt; it? </P>
<P><BR>&gt; If the user has called the SqlConnection.IDisposable.Dispose() in the <BR>&gt; client application, what probem results in?&nbsp; and if there are some <BR>&gt; problem becomes, then why did MS give us such a method? </P>
<P><BR>&gt; in the same, who can tell me the using of <BR>&gt; "SqlConnection.ICloneable.Clone ", <BR>&gt; "SqlConnection.IDbConnection.BeginTransaction" and <BR>&gt; "SqlConnection.IDbConnection.CreateCommand"? </P>
<P><BR>&gt; Anybody can help me to solve my question? thanks a lot. </P>
<P>&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what does 'SqlConnection.IDisposable.Dispose' mean? 'IDisposable' <BR>isn't a property or something of SqlConnection. 'Dispose()' is a method <BR>in Component, the base class of SqlConnection. SqlConnection overrides <BR>Dispose(true), which is called from Dispose(), and therefore whatever <BR>Dispose() you call, it doesnt matter. </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FB </P>
<P><BR>-- <BR>------------------------------------------------------------------------ <BR>Get LLBLGen Pro, productive O/R mapping for .NET: <A href="http://www.llblgen.com">http://www.llblgen.com</A> <BR>My .NET blog: <A href="http://weblogs.asp.net/fbouma">http://weblogs.asp.net/fbouma</A> <BR>Microsoft MVP (C#) <BR>------------------------------------------------------------------------ </P>
<P><BR>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P><BR>&nbsp;&nbsp; 6. <A href="mailto:jinfeng_Wang@msn.com">jinfeng_Wang@msn.com</A> <BR>&nbsp;1月20日 下午5时55分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>" &lt;<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：20 Jan 2006 01:55:46 -0800 <BR>当地时间：2006年1月20日(星期五) 下午5时55分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 删除 | 报告滥用行为&nbsp; </P>
<P>FB, i know that 'IDisposable'&nbsp; is not one property of the <BR>SQLConnection. please read my answer to Cor. <BR>'SqlConnection.IDisposable.Dispose'&nbsp; is copied from MSDN.&nbsp;&nbsp;&nbsp; :-) <BR>I think it means that SQLConnection has implemnt the Dispose() method <BR>of the IDisposable explicity. </P>
<P><BR>I want to know the difference between the two method of <BR>SqlConnection.IDisposable.Disp&shy;&shy;ose() and SqlConnection.Dispose(). </P>
<P><BR>Thanks to you!!! thanks! </P>
<P><BR>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P><BR>&nbsp;&nbsp; 7. Frans Bouma [C# MVP] <BR>&nbsp;1月21日 下午6时54分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "Frans Bouma [C# MVP]" &lt;<A href="mailto:perseus.usenetNOS...@xs4all.nl">perseus.usenetNOS...@xs4all.nl</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：Sat, 21 Jan 2006 02:54:24 -0800 <BR>当地时间：2006年1月21日(星期六) 下午6时54分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 报告滥用行为&nbsp; </P>
<P>&nbsp;</P>
<P><A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A> wrote: <BR>&gt; FB, i know that 'IDisposable'&nbsp; is not one property of the <BR>&gt; SQLConnection. please read my answer to Cor. <BR>&gt; 'SqlConnection.IDisposable.Dispose'&nbsp; is copied from MSDN.&nbsp;&nbsp;&nbsp; :-) <BR>&gt; I think it means that SQLConnection has implemnt the Dispose() method <BR>&gt; of the IDisposable explicity. </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I thought that it meant that, but checking SqlConnection in reflector <BR>I couldn't find IDisposable explicit implementations :D Hence my <BR>question :) </P>
<P><BR>&gt; I want to know the difference between the two method of <BR>&gt; SqlConnection.IDisposable.Disp&shy;&shy;ose() and SqlConnection.Dispose(). </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I have no idea. </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FB </P>
<P><BR>-- <BR>------------------------------------------------------------------------ <BR>Get LLBLGen Pro, productive O/R mapping for .NET: <A href="http://www.llblgen.com">http://www.llblgen.com</A> <BR>My .NET blog: <A href="http://weblogs.asp.net/fbouma">http://weblogs.asp.net/fbouma</A> <BR>Microsoft MVP (C#) <BR>------------------------------------------------------------------------ </P>
<P><BR>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P><BR>&nbsp;&nbsp; 8. <A href="mailto:jinfeng_Wang@msn.com">jinfeng_Wang@msn.com</A> <BR>&nbsp;1月23日 上午9时17分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>" &lt;<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：22 Jan 2006 17:17:00 -0800 <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 删除 | 报告滥用行为&nbsp; </P>
<P>:-) </P>
<P><BR>copied from Reflector: </P>
<P><BR>System.Data.SqlClient.SqlConnection.System.Data.IDbConnection.BeginTransact&shy;ion() <BR>: IDbTransaction <BR>IDbTransaction IDbConnection.BeginTransaction() <BR>{ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.BeginTransaction(); </P>
<P>&nbsp;</P>
<P>} </P>
<P><BR>I think that the disposable is same as here . <BR>but, but&nbsp; why MS does such a foolish action :-( </P>
<P>this folliwing is copied from MSDN&nbsp; in the <BR>SqlConnection.IDbConnection.BeginTransaction Method (): <BR>"This member supports the .NET Framework infrastructure and is not <BR>intended to be used directly from your code." <BR>faint to death. ~ </P>
<P><BR>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P><BR>&nbsp;&nbsp; 9. William (Bill) Vaughn <BR>&nbsp;1月22日 上午2时55分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "William \(Bill\) Vaughn" &lt;<A href="mailto:billvaRemoveT...@nwlink.com">billvaRemoveT...@nwlink.com</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：Sat, 21 Jan 2006 10:55:46 -0800 <BR>当地时间：2006年1月22日(星期日) 上午2时55分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 报告滥用行为&nbsp; </P>
<P>Ok... if you're that curious, use Reflector to walk through the .Net <BR>Framework code to see what it does. You must have a lot more time on your <BR>hands that we do. </P>
<P><BR>Frankly, it does not matter what they do. You don't need to call <BR>them--either of them. As long as you use Close on the Connection you're <BR>fine. Sure, you can call Dispose if you want to, but it won't help the <BR>problem you're trying to solve. </P>
<P><BR>-- <BR>____________________________________ <BR>William (Bill) Vaughn <BR>Author, Mentor, Consultant <BR>Microsoft MVP <BR>INETA Speaker <BR><A href="http://www.betav.com/blog/billva">www.betav.com/blog/billva</A> <BR><A href="http://www.betav.com">www.betav.com</A> <BR>Please reply only to the newsgroup so that others can benefit. <BR>This posting is provided "AS IS" with no warranties, and confers no rights. <BR>__________________________________ </P>
<P><BR>"Frans Bouma [C# MVP]" &lt;<A href="mailto:perseus.usenetNOS...@xs4all.nl">perseus.usenetNOS...@xs4all.nl</A>&gt; wrote in message <BR><A href="news:xn0ehgc512v14b001@news.microsoft.com">news:xn0ehgc512v14b001@news.microsoft.com</A>... </P>
<P>&nbsp;</P>
<P>- 隐藏被引用文字 -<BR>- 显示引用的文字 -</P>
<P>&gt; <A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A> wrote: </P>
<P>&gt;&gt; hi, I have a question about the difference between <BR>&gt;&gt; SqlConnection.IDisposable.Dispose()&nbsp; and&nbsp; SqlConnection.Dispose(). <BR>&gt;&gt; Both&nbsp; of them realize the function of releasing the connection to the <BR>&gt;&gt; ConnectionPool?&nbsp; Do they have the same effection source code?&nbsp; If they <BR>&gt;&gt; are different, who can tell me the differences? If they are same, why <BR>&gt;&gt; MS gives the SqlConnection.IDisposable.Dispose, but&nbsp; only <BR>&gt;&gt; SqlConnection.Dispose() method? </P>
<P><BR>&gt;&gt; In the MSDN, there are following description about the <BR>&gt;&gt; SqlConnection.IDisposable.Dispose Method: <BR>&gt;&gt;&nbsp;&nbsp; "This member supports the .NET Framework infrastructure and is not <BR>&gt;&gt; intended to be used directly from your code."&nbsp; what's the meaning of <BR>&gt;&gt; it? </P>
<P><BR>&gt;&gt; If the user has called the SqlConnection.IDisposable.Dispose() in the <BR>&gt;&gt; client application, what probem results in?&nbsp; and if there are some <BR>&gt;&gt; problem becomes, then why did MS give us such a method? </P>
<P><BR>&gt;&gt; in the same, who can tell me the using of <BR>&gt;&gt; "SqlConnection.ICloneable.Clone ", <BR>&gt;&gt; "SqlConnection.IDbConnection.BeginTransaction" and <BR>&gt;&gt; "SqlConnection.IDbConnection.CreateCommand"? </P>
<P><BR>&gt;&gt; Anybody can help me to solve my question? thanks a lot. </P>
<P><BR>&gt; what does 'SqlConnection.IDisposable.Dispose' mean? 'IDisposable' <BR>&gt; isn't a property or something of SqlConnection. 'Dispose()' is a method <BR>&gt; in Component, the base class of SqlConnection. SqlConnection overrides <BR>&gt; Dispose(true), which is called from Dispose(), and therefore whatever <BR>&gt; Dispose() you call, it doesnt matter. </P>
<P><BR>&gt; FB </P>
<P><BR>&gt; -- <BR>&gt; ------------------------------------------------------------------------ <BR>&gt; Get LLBLGen Pro, productive O/R mapping for .NET: <A href="http://www.llblgen.com">http://www.llblgen.com</A> <BR>&gt; My .NET blog: <A href="http://weblogs.asp.net/fbouma">http://weblogs.asp.net/fbouma</A> <BR>&gt; Microsoft MVP (C#) <BR>&gt; ------------------------------------------------------------------------ </P>
<P>&nbsp;</P>
<P>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P><BR>&nbsp;&nbsp; 10. Frans Bouma [C# MVP] <BR>&nbsp;1月22日 下午6时52分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "Frans Bouma [C# MVP]" &lt;<A href="mailto:perseus.usenetNOS...@xs4all.nl">perseus.usenetNOS...@xs4all.nl</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：Sun, 22 Jan 2006 02:52:11 -0800 <BR>当地时间：2006年1月22日(星期日) 下午6时52分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 报告滥用行为&nbsp; </P>
<P>&nbsp;</P>
<P>William (Bill) Vaughn wrote: <BR>&gt; Ok... if you're that curious, use Reflector to walk through the .Net <BR>&gt; Framework code to see what it does. You must have a lot more time on <BR>&gt; your hands that we do. </P>
<P>&gt; Frankly, it does not matter what they do. You don't need to call <BR>&gt; them--either of them. As long as you use Close on the Connection <BR>&gt; you're fine. Sure, you can call Dispose if you want to, but it won't <BR>&gt; help the problem you're trying to solve. </P>
<P>&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; On a side note: not all ADO.NET providers' connection objects can <BR>live without a Dispose call. For example the Firebird .NET provider and <BR>the ODP.NET providers do need a call to Dispose to properly clean up. <BR>(especially firebird, for cleaning up on the server side!). </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FB, who still couldn't find an explicit IDisposable implementation on <BR>SqlConnection... </P>
<P><BR>-- <BR>------------------------------------------------------------------------ <BR>Get LLBLGen Pro, productive O/R mapping for .NET: <A href="http://www.llblgen.com">http://www.llblgen.com</A> <BR>My .NET blog: <A href="http://weblogs.asp.net/fbouma">http://weblogs.asp.net/fbouma</A> <BR>Microsoft MVP (C#) <BR>------------------------------------------------------------------------ </P>
<P><BR>回复 <BR>&nbsp;<BR>11. <A href="mailto:jinfeng_Wang@msn.com">jinfeng_Wang@msn.com</A> <BR>&nbsp;1月23日 上午8时55分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>" &lt;<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：22 Jan 2006 16:55:26 -0800 <BR>当地时间：2006年1月23日(星期一) 上午8时55分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 删除 | 报告滥用行为&nbsp; </P>
<P>thanks all of you. </P>
<P><BR>If i was just a client programmer, i think all the information from you <BR>and MSDN is enough. <BR>but,...&nbsp; now i am trying&nbsp; to develop one new .NET Data Provider for own <BR>database. <BR>so i want&nbsp; to know what has happened in SQL .NET Data Provider. <BR>it give me a dozens of puzzling interface. <BR>here is "SqlConnection.IDisposable.Disp&shy;&shy;ose() " and <BR>"SqlConnection.Dispose()". </P>
<P><BR>In fact, the SQLConnection is inherited from Compnent, which has <BR>implemented the IDisposable. <BR>This is very like the question of "deadly diamond", that one Class <BR>inherits one Interface from TWO path. <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDisposable <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <BR>Component&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDBConnection <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; / <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLConnection </P>
<P><BR>if there is no difference between the <BR>SqlConnection.IDisposable.Disp&shy;&shy;ose() and SqlConnection.Dispose(), <BR>then MS has no need to implement the <BR>SqlConnection.IDisposable.Disp&shy;&shy;ose() explicitly. But, it has done <BR>it, that means there are some differences between them. What's that? <BR>MSDN has not told us, it just warn us not to call&nbsp; the <BR>SqlConnection.IDisposable.Disp&shy;&shy;ose() in the client program.&nbsp;&nbsp;&nbsp; :( </P>
<P><BR>In the&nbsp; Oracle® Data Provider for .NET, <BR>&nbsp;&nbsp;&nbsp;&nbsp; public sealed class OracleConnection : Component, IDbConnection, <BR>ICloneable <BR>but, OracleConnection has not implement the <BR>IDbConnection.IDisposable.Disposable() explicity. </P>
<P><BR>MS, :-( </P>
<P><BR>&nbsp;14. Frans Bouma [C# MVP] <BR>&nbsp;1月23日 下午5时54分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "Frans Bouma [C# MVP]" &lt;<A href="mailto:perseus.usenetNOS...@xs4all.nl">perseus.usenetNOS...@xs4all.nl</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：Mon, 23 Jan 2006 01:54:56 -0800 <BR>当地时间：2006年1月23日(星期一) 下午5时54分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 报告滥用行为&nbsp; </P>
<P>&nbsp;</P>
<P><A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A> wrote: <BR>&gt; If i was just a client programmer, i think all the information from <BR>&gt; you and MSDN is enough. <BR>&gt; but,...&nbsp; now i am trying&nbsp; to develop one new .NET Data Provider for <BR>&gt; own database. </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; there are guidelines for that if I'm not mistaken. And I think you <BR>should relax a little. I work with a lot of ADO.NET providers and none <BR>of them works the same as the others. So 'what should be done' is what <BR>you think is the easiest for your users :). </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So, 'Close()' should clean up, and for example connection.Dispose() <BR>should also dispose commands, parameters etc. </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; In general derive a class from DbConnection, and override the specific <BR>methods to add your own code. </P>
<P>&nbsp;</P>
<P>&gt; so i want&nbsp; to know what has happened in SQL .NET Data Provider. <BR>&gt; it give me a dozens of puzzling interface. <BR>&gt; here is "SqlConnection.IDisposable.Disp&shy;&shy;ose() " and <BR>&gt; "SqlConnection.Dispose()". </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Have you looked into the code with reflector ? I think you should do <BR>that. :) </P>
<P>&nbsp;</P>
<P>- 隐藏被引用文字 -<BR>- 显示引用的文字 -</P>
<P>&gt; In fact, the SQLConnection is inherited from Compnent, which has <BR>&gt; implemented the IDisposable. <BR>&gt; This is very like the question of "deadly diamond", that one Class <BR>&gt; inherits one Interface from TWO path. <BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDisposable <BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \ <BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <BR>&gt; Component&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDBConnection <BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; / <BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLConnection </P>
<P>&gt; if there is no difference between the <BR>&gt; SqlConnection.IDisposable.Disp&shy;&shy;ose() and SqlConnection.Dispose(), <BR>&gt; then MS has no need to implement the <BR>&gt; SqlConnection.IDisposable.Disp&shy;&shy;ose() explicitly. But, it has done <BR>&gt; it, that means there are some differences between them. What's that? <BR>&gt; MSDN has not told us, it just warn us not to call&nbsp; the <BR>&gt; SqlConnection.IDisposable.Disp&shy;&shy;ose() in the client program.&nbsp;&nbsp;&nbsp; :( </P>
<P>&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I looked up the page, and I can only get to that page through the <BR>index. So I think it's a mistake in the MSDN. As said by others in this <BR>thread, look at the code through reflector first, then come back here <BR>with questions. </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Also, inherited interfaces are simply type definitions, not <BR>implementations. So 1 routine can serve the Dispose() method of <BR>multiple interfaces. </P>
<P>&nbsp;</P>
<P>&gt; In the&nbsp; Oracle® Data Provider for .NET, <BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public sealed class OracleConnection : Component, IDbConnection, <BR>&gt; ICloneable <BR>&gt; but, OracleConnection has not implement the <BR>&gt; IDbConnection.IDisposable.Disposable() explicity. </P>
<P>&gt; MS, :-( </P>
<P>&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Neither has sqlconnection!!! Look into the code! Just because it's an <BR>error in the MSDN doesn't mean it's true. Why do you ignore what we <BR>said and keep believing an errorous page in the msdn? </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FB </P>
<P><BR>-- <BR>------------------------------------------------------------------------ <BR>Get LLBLGen Pro, productive O/R mapping for .NET: <A href="http://www.llblgen.com">http://www.llblgen.com</A> <BR>My .NET blog: <A href="http://weblogs.asp.net/fbouma">http://weblogs.asp.net/fbouma</A> <BR>Microsoft MVP (C#) <BR>------------------------------------------------------------------------ </P>
<P><BR>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P>&nbsp;<BR>&nbsp;&nbsp; 15. <A href="mailto:jinfeng_Wang@msn.com">jinfeng_Wang@msn.com</A> <BR>&nbsp;1月23日 下午10时15分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>" &lt;<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：23 Jan 2006 06:15:59 -0800 <BR>当地时间：2006年1月23日(星期一) 下午10时15分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 删除 | 报告滥用行为&nbsp; </P>
<P>:-) </P>
<P><BR>MSDN Error？ <BR>why the MS make such an Error . <BR>I have said that&nbsp; now i am developing one .NET Data Provider for my own <BR>database, so i should know the everything what have happened in the SQL <BR>.NET&nbsp; Data Provider, and learning something from the MS's code. </P>
<P><BR>now i have realized why MS&nbsp; give us such a SQL .NET&nbsp; Data Provider. <BR>wait a minute, and i&nbsp; will write it clearly. </P>
<P><BR>回复 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P>&nbsp;<BR>&nbsp;&nbsp; 16. <A href="mailto:jinfeng_Wang@msn.com">jinfeng_Wang@msn.com</A> <BR>&nbsp;1月23日 下午11时10分&nbsp;&nbsp; 显示选项 </P>
<P>新闻论坛：microsoft.public.dotnet.framework.adonet <BR>发件人： "<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>" &lt;<A href="mailto:jinfeng_W...@msn.com">jinfeng_W...@msn.com</A>&gt; - 查找此作者的帖子&nbsp; <BR>日期：23 Jan 2006 07:10:37 -0800 <BR>当地时间：2006年1月23日(星期一) 下午11时10分&nbsp; <BR>主题：Re: the difference between SqlConnection.IDisposable.Disp&shy;ose() and SqlConnection.Dispose() <BR>回复 | 答复作者 | 转发 | 打印 | 显示个别帖子 | 显示原始邮件 | 删除 | 报告滥用行为&nbsp; </P>
<P>firstly, let's take a look at the following code. </P>
<P><BR>///-------------- <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public interface myInterface <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object getobject(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public class MyImplement : myInterface <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public String getobject()&nbsp;&nbsp;&nbsp; //override. <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "str"; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }///--------------- <BR>the code above can not be compiled, the compiler will have give us an <BR>error.&nbsp; Because the method of MyImplement.getobject() has a wrong <BR>return type, which is "String", but the method of <BR>MyInterface.getobject() declared that the return type is "Object:. Here <BR>the compiler take the "return type" into the "override" compile <BR>progregess. If MyImplement.getobject() returns "String",&nbsp; this is not <BR>the implementation of MyInterface.getobject(). </P>
<P><BR>now let's take a look at another code. <BR>///--------------- <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public class AnotherImplement <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public object getobject() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new object(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string getobject()&nbsp; //overload <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new string(""); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>///--------------- <BR>Here I want to overload the method of "getobject()", but the compiler <BR>give us an error. Here the compiler DOES NOT take the "return type" <BR>into the "overload" compile progregess (DIFFERENCE WITH THE OVERRIDE). </P>
<P><BR>Now let's go back to the IDBConnection and SQLConnection. <BR>In the interface of IDbConnection, it declares one method of <BR>"createcomand". <BR>///---------- <BR>IDbConnection { <BR>&nbsp;&nbsp;&nbsp; .... <BR>&nbsp;&nbsp;&nbsp; IDbCommand CreateCommand(); <BR>&nbsp;&nbsp; .... </P>
<P><BR>} </P>
<P><BR>///---------- <BR>When design the interface of IDBConnection, the designer does not <BR>what's kind of "Command" will be returned, for example <BR>"SQLCommand","OracleCommand". so in the IDbConnection.CreateCommand(), <BR>it only return an interface of "IDbCommand". </P>
<P>Now we are design the SQLConnection which implements the interface of <BR>"IDbConnection". if in the SQLConnection, it only write : <BR>///--------- <BR>&nbsp; SQLConnection:IDbConnection { <BR>&nbsp;&nbsp; .... <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCommand&nbsp; CreateCommand() { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ........ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp; .... <BR>&nbsp;} <BR>///--------- <BR>the compiler will give us an error, because&nbsp; the "return type" is <BR>SQLCommand, but not IDbCommand(defined in the IDbConnection). THE <BR>COMPILER TAKE THE RETURN TYPE INTO THE COMPILE PROGRESS. so we must <BR>give another definition of "IDbConnection.CreateCommand()". </P>
<P><BR>if we write the code as follows: <BR>///--------- <BR>&nbsp; SQLConnection:IDbConnection { <BR>&nbsp;&nbsp; .... <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCommand&nbsp; CreateCommand() { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ........ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDBCommand CreateCommand() { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....... <BR>&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp; .... <BR>&nbsp;} <BR>///--------- <BR>The compiler will give us an error. THE COMPILER DOES NOT TAKE THE <BR>RETURN TYPE INTO THE COMPILE PROGRESS. </P>
<P><BR>so the SQLConnection have to implement&nbsp; the <BR>IDbConncection.CreateCommand explicyly. <BR>///-------- <BR>&nbsp;&nbsp; SQLConnection:IDbConnection { <BR>&nbsp;&nbsp; .... <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCommand&nbsp; CreateCommand() { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ........ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDBCommand&nbsp; IDbConnection.CreateCommand() { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.CreateCommand(); <BR>&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp; .... <BR>&nbsp;} <BR>///--------- <BR>The above is the&nbsp; SQLConnection. </P>
<P><BR>============BUT============ <BR>The MSDN told us the "we should call the <BR>SQLConnection.IDbConnection.CreateCommand() in the client program". <BR>that is, "we should use the SQLConnection.CreateCommand() in the client <BR>program." <BR>THIS will result a foolish result. In the client pogram, we will write <BR>such a code: <BR>///------------ <BR>&nbsp;&nbsp; void doSomething() { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SqlConnection&nbsp; conn = new SqlConnection(connectionString); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SqlCommand command = conn.CreateCommand(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; We MUST have call <BR>SqlConnection.CreateCommand(), <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; not <BR>SqlConnection.IDbConnection.CreateCommand(), <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; which is suggested by MSDN. <BR>&nbsp;&nbsp; } <BR>///------------ <BR>The above client code has violated the programming rule: "PROGRAMMING <BR>TO INTERFACE". <BR>According to the MSDN, we can not "PROGRAM TO IDbCommand". <BR>The action of&nbsp; "SqlConnection.CreateCommand()"&nbsp; is difference with&nbsp; the <BR>action of"IDbConnection.CreeateCommand()". </P>
<P><BR>Now if i want to shift to the Oracle database.&nbsp;&nbsp; All of the client code <BR>must be modified, because the above is "PROGRAM TO SqlCommand".&nbsp; :-( <BR>What a foolish ADO.NET FrameWork. </P>
<P><BR>I am a java programmer. If i design the SQLConnection, i will give a <BR>such a implemention: <BR>///-------- <BR>&nbsp;&nbsp; SQLConnection:IDbConnection { <BR>&nbsp;&nbsp; .... <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDBCommand&nbsp; CreateCommand() { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ........ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SqlCommand&nbsp; CreateSqlCommand() { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ........ <BR>&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp; .... <BR>&nbsp;} <BR>///--------- <BR>If the client programmer want to "PROGRAM TO SqlCommand",&nbsp; he will call <BR>the method of SqlConnection.CreateSqlCommand().&nbsp; If the client <BR>programmer want to "PROGRAMM TO IDbConnection", he will call the <BR>SqlConnection.CreateCommand(). Now The action of <BR>"SqlConnection.CreateCommand()"&nbsp; is same as&nbsp;&nbsp; the action <BR>of"IDbConnection.CreeateCommand()". <BR>Because the client code is "PROGRAM TO IDbCommand", so if the client <BR>program shifts to Oracle database, the client code will not have to <BR>modify all the code. </P>
<P><BR>回复 <BR>&nbsp;<BR></P><img src ="http://www.blogjava.net/jinfeng_wang/aggbug/28985.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2006-01-23 09:35 <a href="http://www.blogjava.net/jinfeng_wang/archive/2006/01/23/28985.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>EBCDIC Encoding with .NET (zz)</title><link>http://www.blogjava.net/jinfeng_wang/archive/2006/01/18/28559.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Wed, 18 Jan 2006 11:58:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2006/01/18/28559.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/28559.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2006/01/18/28559.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/28559.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/28559.html</trackback:ping><description><![CDATA[<H1>EBCDIC Encoding with .NET</H1>
<P>After reading a post on the C# newsgroup asking for a EBCDIC to ASCII converter, and seeing one solution, I decided to write my own implementation. This page describes the implementation and its limitations, and a bit about EBCDIC itself. </P>
<H2>EBCDIC</H2>
<P>Unfortunately it appears to be fairly tricky to get hold of many concrete specifications of EBCDIC. This is what I've managed to glean from various websites: </P>
<UL>
<LI>Introduced by IBM, EBCDIC is an encoding mostly used on mainframes. 
<LI>Like "OEM", EBCDIC isn't a single character encoding: there are many EBCDIC encodings, suited to different cultures. 
<LI>It is primarily a single-byte encoding, ie each character is encoded as a single byte. However, there are two characters, "shift out" and "shift in" (0x0e and 0x0f respectively) which are used to change between this an a double-byte character set (DBCS). As far as I can tell, a single EBCDIC encoding doesn't specify which DBCS is to be used - in other words, you really need even more information before you can tell what's going on. Presumably the DBCS in question can't have any pairs beginning with byte 0x0f, as otherwise it would be confused with the "shift in" flag. </LI></UL>
<P>If you have any more information, particularly about the DBCS aspect, please mail me at <A href="mailto:skeet@pobox.com">skeet@pobox.com</A>. </P>
<H2>My EBCDIC Encoding implementation</H2>
<P>I managed to get hold of details of 47 EBCDIC encodings from <A href="http://std.dkuug.dk/i18n/charmaps/">http://std.dkuug.dk/i18n/charmaps/</A>. To be honest, I don't really know what DKUUG is, so I'm really just hoping that the maps are accurate - they seem to be quite reasonable though. Each encoding has a name and several have aliases, although I currently ignore this aliasing. </P>
<P>My implementation consists of three projects, described below, of which only the middle one is of any interest to most people. 
<DL>
<DT>A character map reader 
<DD>This simply finds all of the files whose names begin with "EBCDIC-" in the current directory, reads them all in (warning of any oddities in the encoding, such as any non-zero byte having two distinct meanings) and writes a resource file out, <CODE>ebcdic.dat</CODE>. This is a console applicion built from a single C# source file. 
<DT>An encoding library 
<DD>This is a library built from two C# source files and the <CODE>ebcdic.dat</CODE> file generated by the reader. This library is all most users will need. More details are provided below. 
<DT>A test program 
<DD>This is a console application built from a single C# source file and requiring the library described above. Currently it just displays the encoded version of "hello" and then decodes it. </DD></DL>
<P></P>
<H2>Using The Encoding Library</H2>
<P>The encoding library is very simple to use, as the encoding class (<CODE>JonSkeet.Ebcdic.EbcdicEncoding</CODE>) is a subclass of the standard .NET <CODE>System.Text.Encoding</CODE> class. To obtain an instance of the appropriate encoding, use <CODE>EbcdicEncoding.GetEncoding (String)</CODE> passing it the name of the encoding you wish to use (eg <CODE>EBCDIC-US</CODE>). You can find out the list of names of available encodings using the <CODE>EbcdicEncoding.AllNames</CODE> property, which returns the names as an array of strings. </P>
<P>Once you have obtained an <CODE>EbcdicEncoding</CODE> instance, use it like any other <CODE>Encoding</CODE>: call <CODE>GetString</CODE>, <CODE>GetBytes</CODE> etc. The encoding does not save any state between requests, and can safely be used by many threads simultaneously. There is no need (or indeed facility) to release encoding resources when it is no longer needed. All encodings are created on the first use of the <CODE>EbcdicEncoding</CODE> class, and maintained until the application domain is unloaded. </P>
<H2>Sample Code</H2>
<P>The following is a sample program to convert a file from EBCDIC-US to ASCII. It should be easy to see how to modify it to convert the other way, or to use a different encoding (eg from EBCDIC-UK, or to UTF-8). </P>
<TABLE class=code>
<TBODY>
<TR>
<TD><PRE><SPAN class=Namespace>using</SPAN> System;
<SPAN class=Namespace>using</SPAN> System.IO;
<SPAN class=Namespace>using</SPAN> System.Text;
<SPAN class=Namespace>using</SPAN> JonSkeet.Ebcdic;

<SPAN class=Modifier>public</SPAN> <SPAN class=ReferenceType>class</SPAN> ConvertFile
{
    <SPAN class=Modifier>public</SPAN> <SPAN class=Modifier>static</SPAN> <SPAN class=ValueType>void</SPAN> Main(<SPAN class=ReferenceType>string</SPAN>[] args)
    {
        <SPAN class=Statement>if</SPAN> (args.Length != 2)
        {
            Console.WriteLine 
                (<SPAN class=String>"Usage: ConvertFile &lt;ebcdic file (input)&gt; &lt;ascii file (output)&gt;"</SPAN>);
            <SPAN class=Statement>return</SPAN>;
        }
        
        <SPAN class=ReferenceType>string</SPAN> inputFile = args[0];
        <SPAN class=ReferenceType>string</SPAN> outputFile = args[1];

        Encoding inputEncoding = EbcdicEncoding.GetEncoding (<SPAN class=String>"EBCDIC-US"</SPAN>);
        Encoding outputEncoding = Encoding.ASCII;
        
        <SPAN class=Statement>try</SPAN>
        {
            <SPAN class=InlineComment>// Create the reader and writer with appropriate encodings.</SPAN>
            <SPAN class=Namespace>using</SPAN> (StreamReader inputReader = 
                      <SPAN class=Keyword>new</SPAN> StreamReader (inputFile, inputEncoding))
            {
                <SPAN class=Namespace>using</SPAN> (StreamWriter outputWriter = 
                           <SPAN class=Keyword>new</SPAN> StreamWriter (outputFile, <SPAN class=Keyword>false</SPAN>, outputEncoding))
                {
                    <SPAN class=InlineComment>// Create an 8K-char buffer</SPAN>
                    <SPAN class=ValueType>char</SPAN>[] buffer = <SPAN class=Keyword>new</SPAN> <SPAN class=ValueType>char</SPAN>[8192];
                    <SPAN class=ValueType>int</SPAN> len=0;
                    
                    <SPAN class=InlineComment>// Repeatedly read into the buffer and then write it out</SPAN>
                    <SPAN class=InlineComment>// until the reader has been exhausted.</SPAN>
                    <SPAN class=Statement>while</SPAN> ( (len=inputReader.Read (buffer, 0, buffer.Length)) &gt; 0)
                    {
                        outputWriter.Write (buffer, 0, len);
                    }
                }
            }
        }
        <SPAN class=InlineComment>// Not much in the way of error handling here - you may well want</SPAN>
        <SPAN class=InlineComment>// to do better handling yourself!</SPAN>
        <SPAN class=Statement>catch</SPAN> (IOException e)
        {
            Console.WriteLine (<SPAN class=String>"Exception during processing: {0}"</SPAN>, e.Message);
        }
    }
}    
</PRE></TD></TR></TBODY></TABLE>
<H2>Limitations</H2>
<P>Due to the lack of available information about the DBCS aspect of EBCDIC, this encoding class makes no effort whatsoever to simulate proper shifting. Shift out and shift in are merely encoded/decoded to/from their equivalent Unicode characters, and bytes between them are treated as if the shift had not taken place. (This means that a decoded byte array is always a string of the same length as the byte array, and vice versa). </P>
<P>Any byte not recognised to be from the specific encoding being used is decoded to the question mark character, '?'. Any character not recognised to be in the set of characters encoded by the specific encoding being used is encoded to the byte representing the question mark character, or to byte zero if the question mark character is not in the character set either. </P>
<P>The library doesn't currently have a strong-name, so can't be placed in the GAC. You may, however, download the source and modify </P>
<H2>Licence</H2>
<P>This was just an interesting half-day project. I have no desire to make any money out of this code whatsoever, but I hope it's interesting and useful to others. So, feel free to use it. If you have any questions about it, or just find it useful and wish to let me know, please mail me at <A href="mailto:skeet@pobox.com">skeet@pobox.com</A>. You may use this code in commercial projects, either in binary or source form. You may change the namespace and the class names to suit your company, and modify the code if you wish. I'd rather you didn't try to pass it off as your own work, and specifically you may not sell just this code - at least not without asking me first. I make no claims whatsoever about this code - it comes with no warranty, not even the implied warranty of fitness for purpose, so don't sue me if it breaks something. (Mail me instead, so we can try to stop it from happening again.) </P>
<H2>Downloads</H2>
<UL>
<LI><A href="http://www.yoda.arachsys.com/csharp/ebcdic/source.zip">Source code and VS.NET 2003 solution</A> (zip file, 20K, also contains instructions for building from the command line. 
<LI><A href="http://www.yoda.arachsys.com/csharp/ebcdic/debug.zip">Debug version of the encoding library</A> as built by VS.NET 2003 (zip file, 11K, contains the DLL and PDB files) 
<LI><A href="http://www.yoda.arachsys.com/csharp/ebcdic/release.zip">Release version of the encoding library</A> as built by VS.NET 2003 (zip file, 6K, contains just the DLL) </LI></UL>
<H2>History </H2>
<UL>
<LI>August 31st 2003, v1.0.0.1 - no in-code changes, just made the XML documentation build correctly. 
<LI>August 28th 2003, v1.0.0.1 - slight tweaking to remove unnecessary (and probably counterproductive) efficiency measure. No functional changes. 
<LI>May 21st 2003, v1.0.0.0 - initial implementation. </LI></UL><img src ="http://www.blogjava.net/jinfeng_wang/aggbug/28559.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2006-01-18 19:58 <a href="http://www.blogjava.net/jinfeng_wang/archive/2006/01/18/28559.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Code-Page Identifiers(zz from msdn)</title><link>http://www.blogjava.net/jinfeng_wang/archive/2006/01/18/28540.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Wed, 18 Jan 2006 09:59:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2006/01/18/28540.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/28540.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2006/01/18/28540.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/28540.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/28540.html</trackback:ping><description><![CDATA[<H3><A name=_win32_code_page_identifiers></A>Code-Page Identifiers</H3>
<TABLE class=data>
<TBODY>
<TR vAlign=top>
<TH class=data align=left width="17%">Identifier</TH>
<TH class=data align=left width="83%">Name</TH></TR>
<TR vAlign=top>
<TD class=data width="17%">037</TD>
<TD class=data width="83%">IBM EBCDIC - U.S./Canada</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">437</TD>
<TD class=data width="83%">OEM - United States</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">500</TD>
<TD class=data width="83%">IBM EBCDIC - International </TD></TR>
<TR vAlign=top>
<TD class=data width="17%">708</TD>
<TD class=data width="83%">Arabic - ASMO 708</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">709</TD>
<TD class=data width="83%">Arabic - ASMO 449+, BCON V4</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">710</TD>
<TD class=data width="83%">Arabic - Transparent Arabic</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">720</TD>
<TD class=data width="83%">Arabic - Transparent ASMO</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">737</TD>
<TD class=data width="83%">OEM - Greek (formerly 437G)</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">775</TD>
<TD class=data width="83%">OEM - Baltic</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">850</TD>
<TD class=data width="83%">OEM - Multilingual Latin I</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">852</TD>
<TD class=data width="83%">OEM - Latin II</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">855</TD>
<TD class=data width="83%">OEM - Cyrillic (primarily Russian)</TD></TR>
<TR vAlign=top>
<TD class=data width="17%">857