<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>David Szabo's [MSFT] blog : .net</title><link>http://blogs.msdn.com/dszabo/archive/tags/.net/default.aspx</link><description>Tags: .net</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Playing with DLINQ</title><link>http://blogs.msdn.com/dszabo/archive/2007/06/19/playing-with-dlinq.aspx</link><pubDate>Tue, 19 Jun 2007 11:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3400387</guid><dc:creator>dszabo</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dszabo/comments/3400387.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dszabo/commentrss.aspx?PostID=3400387</wfw:commentRss><description>&lt;P&gt;Today, I was playing with DLINQ and would like to share my findings with you. First of all, if you never heard of LINQ or want a basic intro, I suggest starting with the following&amp;nbsp;3 short videos (in order):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://download.microsoft.com/download/4/7/0/4703eba2-78c4-4b09-8912-69f6c38d3a56/languageenhancements.wmv" mce_href="http://download.microsoft.com/download/4/7/0/4703eba2-78c4-4b09-8912-69f6c38d3a56/languageenhancements.wmv"&gt;&lt;STRONG&gt;C# 3.0 Language Enhancements in action&lt;/STRONG&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://download.microsoft.com/download/4/7/0/4703eba2-78c4-4b09-8912-69f6c38d3a56/linq.wmv" mce_href="http://download.microsoft.com/download/4/7/0/4703eba2-78c4-4b09-8912-69f6c38d3a56/linq.wmv"&gt;&lt;STRONG&gt;C# 3.0 LINQ in action&lt;/STRONG&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://download.microsoft.com/download/4/7/0/4703eba2-78c4-4b09-8912-69f6c38d3a56/dlinq.wmv" mce_href="http://download.microsoft.com/download/4/7/0/4703eba2-78c4-4b09-8912-69f6c38d3a56/dlinq.wmv"&gt;&lt;STRONG&gt;C# 3.0 DLinq in action&lt;/STRONG&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;First of all, I generated a C# class&amp;nbsp;file representing my SQL database tables by using a built-in SDK tool. The class is generated from my SQL database, called PfRep: I started an Orcas command prompt and stepped into the &lt;EM&gt;C:\Program Files\Microsoft Visual Studio 9.0\SDK\v3.5\Bin&lt;/EM&gt; folder, then ran the following command:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;sqlmetal /server:local host /database:PfRep /code /pluralize C:\blabla\PfRep.cs&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This creates a .CS file with the class structure discovered from the database tables.&lt;/P&gt;
&lt;P&gt;(by the way, the .CS file can be generated by a Visual Studio designer as well - by adding a "Linq to SQL File" file to the project&amp;nbsp;- sqlmetal is good for re-generating the structure if it has changed.)&lt;/P&gt;
&lt;P&gt;The first thing that's a bit weird is that the&amp;nbsp;generated file&amp;nbsp;contains modified table names. For example, I have the following tables in my PfRep database:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Folder&lt;/LI&gt;
&lt;LI&gt;ContentIndex&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;that (in PfRep.cs) were transformed to the following class names:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Folder&lt;STRONG&gt;&lt;FONT color=#ff0000&gt;s&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;ContentIndex&lt;STRONG&gt;&lt;FONT color=#ff0000&gt;es&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;I guess, it doesn't want the programmer&amp;nbsp;to mix up the classes (table definitions) with the property methods used to retrieve the records from the tables - or something like that. Let's write some easy code to run a query:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;PfRep&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; pfRep = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;PfRep&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"database=PfRep;server=dszabo1"&lt;/SPAN&gt;);&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;var&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; bigFolders =&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;from&lt;/SPAN&gt; folder &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; pfRep.Folders&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;where&lt;/SPAN&gt; folder.ItemCount &amp;gt; 1000&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;select&lt;/SPAN&gt; folder;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;foreach&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Folder&lt;/SPAN&gt; folder &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; bigFolders)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(folder.FolderKey + &lt;SPAN style="COLOR: #a31515"&gt;" "&lt;/SPAN&gt; + folder.FolderTree.FolderTreeName);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.ReadLine();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;What it does, it queries the Folder table for records with an item count larger than 1,000. Then it iterates through the results, looks up a referenced&amp;nbsp;record (in the FolderTree table, which is referenced by Folder through the FolderTreeID property) and dumps out these data.&lt;/P&gt;
&lt;P&gt;I was curious how does it spend the expensive transaction "fees" against SQL Server. :)&amp;nbsp; It turns out that it's pretty clever. Here's what I captured with SQL Profiler. First, it queries for all the Folder records with an ItemCount larger than 1,000:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;exec&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: maroon"&gt;sp_executesql&lt;/SPAN&gt; N&lt;SPAN style="COLOR: red"&gt;'SELECT [t0].[FolderID], [t0].[FolderTreeID], [t0].[FolderName], [t0].[FolderKey], [t0].[Indexed], [t0].[ItemCount], [t0].[ParentFolderID], [t0].[ActionPlanID], [t0].[OwnerName], [t0].[OwnerEmail], [t0].[Note]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;FROM [Folder] AS [t0]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;WHERE [t0].[ItemCount] &amp;gt; @p0'&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: gray; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;N&lt;SPAN style="COLOR: red"&gt;'@p0 int'&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;@p0&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;1000&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;then when in the loop, it queries for the FolderTree record associated with the Folder record:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;exec&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: maroon"&gt;sp_executesql&lt;/SPAN&gt; N&lt;SPAN style="COLOR: red"&gt;'SELECT [t0].[FolderTreeID], [t0].[FolderTreeName], [t0].[DateCreated], [t0].[FolderTreeUrl]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;FROM [FolderTree] AS [t0]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;WHERE [t0].[FolderTreeID] = @p0'&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: gray; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;N&lt;SPAN style="COLOR: red"&gt;'@p0 int'&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;@p0&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;It checks whether the given FolderTree record was already retrieved and it doesn't&amp;nbsp;run the query&amp;nbsp;twice if already got the record - I'm wondering where does it store the results though ... and how.&lt;/P&gt;
&lt;P&gt;sp_executesql is a good choice of running the queries, in my example, it's especially useful when running the FolderTree query (in the loop). Here's how it works:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;"&lt;EM&gt;&lt;STRONG&gt;sp_executesql&lt;/STRONG&gt; can be used instead of stored procedures to execute a Transact-SQL statement a number of times when the change in parameter values to the statement is the only variation. Because the Transact-SQL statement itself remains constant and only the parameter values change, &lt;FONT color=#ff0000&gt;&lt;STRONG&gt;the Microsoft® SQL Server™ query optimizer is likely to reuse the execution plan&lt;/STRONG&gt;&lt;/FONT&gt; it generates for the first execution.&lt;/EM&gt;" &lt;A title=http://msdn2.microsoft.com/en-us/library/aa933299(SQL.80).aspx href="http://msdn2.microsoft.com/en-us/library/aa933299(SQL.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa933299(SQL.80).aspx"&gt;http://msdn2.microsoft.com/en-us/library/aa933299(SQL.80).aspx&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sounds good, isn't it? I'm still very curious about how is the cached data stored, it could be an important question by Customers on large database projects. After some debugging and reverse-engineering, it turns out that the data is stored by using the&amp;nbsp;type of the underlying entity (FolderTree in my case) and is indexed by a special generic collection.&lt;/P&gt;
&lt;P&gt;Have fun with LINQ! :)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3400387" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dszabo/archive/tags/.net/default.aspx">.net</category></item><item><title>How to run a SQL database installer from your .net application</title><link>http://blogs.msdn.com/dszabo/archive/2007/05/28/how-to-run-a-sql-database-installer-from-your-net-application.aspx</link><pubDate>Mon, 28 May 2007 13:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2942377</guid><dc:creator>dszabo</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/dszabo/comments/2942377.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dszabo/commentrss.aspx?PostID=2942377</wfw:commentRss><description>&lt;P&gt;Even if the question itself is very obvious, I got too many problems while implementing it. Here's the situation: I have a WinForms app (C#), I want to offer the user with creating a SQL database and a couple of database objects (SPs, tables) at the first time he/she runs the application.&lt;/P&gt;
&lt;P&gt;The CREATE scripts are in a .sql file. It was generated with SQL Management Studio. If I read the file and pass it over to the SqlCommand object (as a string), it fails. If the file were just to contain CREATE TABLE statements, it would work, but ADO.NET doesn't like the CREATE PROC statements. If it's only CREATE PROC statements, it still fails. So, the principle is that every CREATE PROC has to run seperately. CREATE TABLEs can run together. So, what I did was, I was breaking the script to separate statements and ran them one by one by using the SqlCommand object. GO commands can be used to split up the&amp;nbsp;file to multiple parts if there's no "GO" word in your script.&amp;nbsp;Here it is:&lt;/P&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000 size=2&gt;// Break the SQL script to statements&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#008000 size=2&gt;// (delimited by the GO command).&lt;BR&gt;// Without doing this, it doesn't work. NOTE: it's important that&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#008000 size=2&gt;// the SQL script shouldn't contain *ANY* GO word except the ones&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#008000 size=2&gt;// used to delimit, otherwise it won't work. We are using GO&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#008000 size=2&gt;// because OSQL also understands GO - so the script remains&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#008000 size=2&gt;// compatible. Another solution would be to use a&lt;BR&gt;//&amp;nbsp;commented delimiter.&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;[] delimitedSqlCommand = databaseScript.Split(&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; new&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;[1] { &lt;/FONT&gt;&lt;FONT face="Courier New" color=#a31515 size=2&gt;"GO"&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; }, &lt;/FONT&gt;&lt;FONT face="Courier New" color=#2b91af size=2&gt;StringSplitOptions&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;.None);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#008000 size=2&gt;// Creates the db objects&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;foreach&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; sqlCommand &lt;/FONT&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;in&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; delimitedSqlCommand)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlCommand&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; command = &lt;/FONT&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" color=#2b91af size=2&gt;SqlCommand&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;(&lt;BR&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#000000&gt;sqlCommand, masterConnection);&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command.CommandType = &lt;/FONT&gt;&lt;FONT face="Courier New" color=#2b91af size=2&gt;CommandType&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;.Text;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command.ExecuteNonQuery();&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2942377" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dszabo/archive/tags/.net/default.aspx">.net</category></item><item><title>.net Framework 3.0 Installer Crashes</title><link>http://blogs.msdn.com/dszabo/archive/2007/01/29/net-framework-3-0-installer-crashes.aspx</link><pubDate>Mon, 29 Jan 2007 15:36:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1551417</guid><dc:creator>dszabo</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dszabo/comments/1551417.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dszabo/commentrss.aspx?PostID=1551417</wfw:commentRss><description>&lt;p&gt;Today, I installed the .NET Framework 3.0 Redistributable Package from &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=10cc340b-f857-4a14-83f5-25634c3bf043&amp;amp;DisplayLang=en"&gt;here&lt;/a&gt;&amp;nbsp;at a Customer's site, on a Windows Server 2003 SP1.&amp;nbsp;After the installer started and I accepted the licence agreements, a minute later the installer crashed while tried to download some more data from the internet. It turns out that due to my limited rights on the Customer's firewall, the installer couldn't download the required content thus&amp;nbsp;causing the crash. So, make sure that you have a right to download application/octet-stream content types before running the installer.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1551417" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dszabo/archive/tags/.net/default.aspx">.net</category></item><item><title>How .net stores dates/how to debug them</title><link>http://blogs.msdn.com/dszabo/archive/2006/11/16/How-.net-stores-dates_2F00_how-to-debug-them.aspx</link><pubDate>Fri, 17 Nov 2006 01:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1089244</guid><dc:creator>dszabo</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dszabo/comments/1089244.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dszabo/commentrss.aspx?PostID=1089244</wfw:commentRss><description>&lt;P&gt;I was debugging an application and had to check a DateTime variable’s actual value. I was expecting something like member variables holding year, month, day, hour, etc values on the object and it will be an easy one to debug, but that was not the case, so I had to find out how to check the actual date value of a DateTime variable and learn how dates are stored in the .net framework 2.0.&lt;/P&gt;
&lt;P&gt;First of all, as you might already know, dumping out an object with SOS can be done with the !do (or !DumpObject) command. If you are not familiar with debugging .net, using WinDbg and using the SOS debugger extension, you can find a good starter at&amp;nbsp;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslayer/default.aspx" mce_href="http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslayer/default.aspx"&gt;http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslayer/default.aspx&lt;/A&gt;, you can check the reference of the SOS extension at &lt;A href="http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslayer/default.aspx" mce_href="http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslayer/default.aspx"&gt;http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslayer/default.aspx&lt;/A&gt;, then if you are still interested, you'll&amp;nbsp;find really good articles at Doug's (&lt;A href="http://blogs.msdn.com/dougste" mce_href="http://blogs.msdn.com/dougste"&gt;http://blogs.msdn.com/dougste&lt;/A&gt;) and Tess' (&lt;A href="http://blogs.msdn.com/tess" mce_href="http://blogs.msdn.com/tess"&gt;http://blogs.msdn.com/tess&lt;/A&gt;) blog. So, returning back to the subject, this is what you get when dumping out a DateTime variable:&lt;/P&gt;&lt;PRE&gt;&lt;P&gt;0:000&amp;gt; !do 01481d74&lt;BR&gt;Name: System.DateTime&lt;BR&gt;MethodTable: 790ff4c4&lt;BR&gt;EEClass: 790ff424&lt;BR&gt;Size: 16(0x10) bytes&lt;BR&gt;&amp;nbsp;(E:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)&lt;BR&gt;Fields:&lt;BR&gt;Field&amp;nbsp;&amp;nbsp; Offset&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type VT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Attr&amp;nbsp;&amp;nbsp;&amp;nbsp; Value Name&lt;BR&gt;&lt;STRONG&gt;40000f4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.UInt64&amp;nbsp; 0 instance &lt;/STRONG&gt;&lt;STRONG&gt;630992916000000000 dateData&lt;BR&gt;&lt;/STRONG&gt;40000f0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Int32[]&amp;nbsp; 0&amp;nbsp;&amp;nbsp; shared&amp;nbsp;&amp;nbsp; static DaysToMonth365&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt; Domain:Value&amp;nbsp; 002401d8:01481cf4 &amp;lt;&amp;lt;&lt;BR&gt;40000f1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 34&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Int32[]&amp;nbsp; 0&amp;nbsp;&amp;nbsp; shared&amp;nbsp;&amp;nbsp; static DaysToMonth366&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt; Domain:Value&amp;nbsp; 002401d8:01481d34 &amp;lt;&amp;lt;&lt;BR&gt;40000f2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 28&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.DateTime&amp;nbsp; 1&amp;nbsp;&amp;nbsp; shared&amp;nbsp;&amp;nbsp; static MinValue&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt; Domain:Value&amp;nbsp; 002401d8:01481cd4 &amp;lt;&amp;lt;&lt;BR&gt;40000f3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.DateTime&amp;nbsp; 1&amp;nbsp;&amp;nbsp; shared&amp;nbsp;&amp;nbsp; static MaxValue&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt; Domain:Value&amp;nbsp; 002401d8:01481ce4 &amp;lt;&amp;lt;&lt;/P&gt;

&lt;/PRE&gt;
&lt;P&gt;The actual date value is&amp;nbsp;stored&amp;nbsp;in the UInt64 (long)&amp;nbsp;member variable called &lt;STRONG&gt;dateData&lt;/STRONG&gt;, which&amp;nbsp;stores the&amp;nbsp;ticks representing the date value. In my example, it is&amp;nbsp;630992916000000000. That's OK so far, but how can we get the date out from this? To convert it back without using your calculator or writing an expensive algorythm, you have to use the following DateTime constructor:&lt;/P&gt;&lt;PRE&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; DateTime(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;long&lt;/FONT&gt;&lt;FONT size=2&gt; ticks)&lt;/FONT&gt;&lt;/P&gt;&lt;/PRE&gt;
&lt;P&gt;or the following static method on the DateTime class:&lt;/P&gt;&lt;PRE&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;static&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DateTime&lt;/FONT&gt;&lt;FONT size=2&gt; FromBinary(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;long&lt;/FONT&gt;&lt;FONT size=2&gt; dateData)&lt;/FONT&gt;
&lt;/P&gt;&lt;/PRE&gt;
&lt;P&gt;Code that does the job:&lt;/P&gt;&lt;PRE&gt;&lt;P&gt;&lt;FONT color=#008080 size=2&gt;DateTime&lt;/FONT&gt;&lt;FONT size=2&gt; dateValue = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DateTime&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;STRONG&gt;630992916000000000&lt;/STRONG&gt;);&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#008080 size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(dateValue);&lt;/FONT&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1089244" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dszabo/archive/tags/.net/default.aspx">.net</category><category domain="http://blogs.msdn.com/dszabo/archive/tags/debugging/default.aspx">debugging</category></item><item><title>Exceptions are expensive!</title><link>http://blogs.msdn.com/dszabo/archive/2006/11/09/exceptions-are-expensive.aspx</link><pubDate>Thu, 09 Nov 2006 09:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1042967</guid><dc:creator>dszabo</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/dszabo/comments/1042967.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dszabo/commentrss.aspx?PostID=1042967</wfw:commentRss><description>&lt;P&gt;Hey! Don't we all use Exceptions in managed code to indicate the caller that something is wrong? That's a really bad habit! - "Hey maaaan, it's the 21st century, passing back HRESULTs is over!" - not yet, you'll see it:&amp;nbsp;did you know that if your caller can systematically force your code to throw an exception (by passing wrong parameters, etc), your application&amp;nbsp;could be DOSed down? It's just a matter of the amount of threads running on the defender's box and the power of the server your code running at. To demonstrate this thingy, I hammered together a small app:&lt;/P&gt;
&lt;P&gt;The following is a function that can work in two different ways:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Returning an exception, simulating a function that communicates back to its caller by throwing exceptions on deterministic inputs. MyOwnException is just a class inherited from the ApplicationException class&lt;/LI&gt;
&lt;LI&gt;Returning an integer number, simulating a function that works in an "old-fashioned" HRESULT-way&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;&lt;P&gt;static int TesterMethod(bool throwException)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (throwException)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new MyOwnException();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 1;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;/PRE&gt;
&lt;P&gt;(HRESULT is representing an alternative way of passing back the result of a function as a variable or pointer, it's not neccessarily should be the old-fashioned&amp;nbsp;HRESULT, it could be a structure or class&amp;nbsp;containing information about&amp;nbsp;what happened)&lt;/P&gt;
&lt;P&gt;... and here's the function that will drive this baby: it's simple: there's a stopwatch we use to measure time, and we call the function in both ways 1,000 times:&lt;/P&gt;&lt;PRE&gt;&lt;P&gt;static void Main(string[] args)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Stopwatch stopWatch = Stopwatch.StartNew();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // PHASE I: DOING THE EXCEPTION-TEST&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Reset and start the stopwatch&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stopWatch.Reset();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stopWatch.Start();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Call the function 1,000 times, an exception will be&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp; thrown at every call&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; 1000; i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TesterMethod(true);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (MyOwnException)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Do something to handle ...&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Stop the watch and show the time elapsed&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stopWatch.Stop();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("Exception: " + stopWatch.Elapsed);&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // PHASE II: DOING THE "HRESULT" TEST&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Reset and start the stopwatch again&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stopWatch.Reset();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stopWatch.Start();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Calling the function 1,000 times again, but now in&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp; the HRESULT-way&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int retVal = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; 1000; i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retVal = TesterMethod(false);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Stop the stopwatch and display the results&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stopWatch.Stop();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("HRESULT " + stopWatch.Elapsed);&lt;/P&gt;
&lt;/PRE&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;Surprise!&lt;/P&gt;&lt;PRE&gt;&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Exception: 00:00:03.1247094&lt;BR&gt;HRESULT:&amp;nbsp;&amp;nbsp; 00:00:00.0000287&lt;/STRONG&gt;&lt;BR&gt;&lt;/P&gt;&lt;/PRE&gt;
&lt;P mce_keep="true"&gt;I hope that you noticed the seconds part, not only the milliseconds part! After some time, I was rethinking the whole thing, because it seemed to be too much of a difference, then I found that I made a mistake when measuring the performance: I was running the code from the Visual Studio IDE, meaning that I was debugging the process, which slows down 1st chance exceptions, so a big part of this difference was due to the operating system informing the debugger about the 1st chance exceptions. Release compiled the project, ran it outside the debugger and got a much better performance for exceptions, but still a huge difference:&lt;/P&gt;&lt;PRE&gt;&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Exception: 00:00:00.2039267&lt;BR&gt;HRESULT:&amp;nbsp;&amp;nbsp; 00:00:00.0000058&lt;/STRONG&gt;&lt;/P&gt;&lt;/PRE&gt;
&lt;P&gt;This is all about performance and security. One can say that these are just milliseconds per one thousand cycles. That's true for one thread, but think about an ASP.net application or a service accepting huge amount of TCP connections, with 25 worker threads per processor. If there's a function inside that can be forced from outside to throw an exception, this could be a big performance impact on your service. So, think twice before throwing an exception.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1042967" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dszabo/archive/tags/.net/default.aspx">.net</category></item></channel></rss>