<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Word Entropy</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/shitals/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/shitals/feed.xml</link>
    <description>Blog of Shital Shah (shitals) on .Net, machine learning, life at Microsoft, physics, mathematics and such stuff</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:27:47 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>BadImageFormatException - This assembly is built by a runtime newer than the currently loaded</title>
      <link>https://docs.microsoft.com/archive/blogs/shitals/badimageformatexception-this-assembly-is-built-by-a-runtime-newer-than-the-currently-loaded</link>
      <pubDate>Mon, 23 Apr 2012 22:49:22 GMT</pubDate>
      <dc:creator><![CDATA[Shital Shah]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shitals/2012/04/23/badimageformatexception-this-assembly-is-built-by-a-runtime-newer-than-the-currently-loaded/</guid>
      <description><![CDATA[Strange thing happened today. I upgraded one of the internal tool to .Net 4.0 without any issues but...]]></description>
      <content:encoded><![CDATA[<p>Strange thing happened today. I upgraded one of the internal tool to .Net 4.0 without any issues but as soon as I attempt to debug/run the binary, I’ll see this exception:</p>  <p><font face="Courier New">System.BadImageFormatException was unhandled     <br />Message: Could not load file or assembly SomeTool.exe' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.</font>    <br /></p>  <p>Normally you see this exception if the machine doesn’t have right run time installed. But this was obviously not the case. Changing build to x86 or x64 didn’t made any difference either. Next I ran peverify.exe which happily reported that there was nothing wrong with the binary image. Finally I needed to pull out the big guns, ask fuslogvw, which would show me if there are any dependent assembly binding that was failing. But that also didn’t produce any boom sounds.</p>  <p>So the last resort was to just meditate over the issue for few minutes. And that works. In a sign of enlightenment I saw app.config buried along with bunch of files and it had these lines:</p>  <p><font face="Courier New">&lt;?xml version=&quot;1.0&quot;?&gt;     <br />&lt;configuration&gt;      <br />&lt;startup&gt;&lt;supportedRuntime version=&quot;<font color="#ff0000">v2.0.50727</font>&quot;/&gt;&lt;/startup&gt;&lt;/configuration&gt;</font></p>  <p>Aha! Apparently the app.config doesn’t get updated (may be because it was in TFS?) when VS did the 4.0 upgrade. As app.config didn’t had anything else, just deleting this file solved the issue. I do wonder how many people come across this gotcha. </p>]]></content:encoded>
    </item>
    <item>
      <title>A Day in SQL Tuning</title>
      <link>https://docs.microsoft.com/archive/blogs/shitals/a-day-in-sql-tuning</link>
      <pubDate>Wed, 27 Jan 2010 01:11:27 GMT</pubDate>
      <dc:creator><![CDATA[Shital Shah]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shitals/2010/01/27/a-day-in-sql-tuning/</guid>
      <description><![CDATA[Today I got in to some heavy weight TSQL tuning. This time the target was a legendary sproc that was...]]></description>
      <content:encoded><![CDATA[<p>Today I got in to some heavy weight TSQL tuning. This time the target was a legendary sproc that was taking 3 mins and now I’m about to call it a day when this giant SP is eating only 16 sec. Not excellent but not bad at this point. Here are some notes…</p>  <ul>   <li>Apparently resetting identity using <span style="line-height: 115%; font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes">DBCC</span><span style="line-height: 115%; font-family: &quot;Courier New&quot;; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes"> CHECKIDENT can be</span> expensive operation if you are also deleting all items from the table. One way to reduce time is use TRUNCATE TABLE before <span style="line-height: 115%; font-family: &#39;Courier New&#39;; color: blue; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes">DBCC</span><span style="line-height: 115%; font-family: &#39;Courier New&#39;; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes"> CHECKIDENT.</span></li>    <li><span style="line-height: 115%; font-family: &#39;Courier New&#39;; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes">I prefer table variables instead of temp tables but one place temp tables are required is if you have lots of data in them and want index!</span></li>    <li><span style="line-height: 115%; font-family: &#39;Courier New&#39;; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes">Data Tuning Wizard would come out with zero suggestions on many occasions but it does not mean there are no <strong>significant</strong> optimizations possible. The best way to “guess” possible index is to have index for all columns used in join <em>and</em> use INCLUDE clause that has columns accessed in SELECT. This last thing does attracts even the least interested query plans to use the index :).</span></li>    <li><span style="line-height: 115%; font-family: &#39;Courier New&#39;; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes">If you have temp tables, it’s usually better to create index after you have inserted data instead of before.</span></li>    <li><span style="line-height: 115%; font-family: &#39;Courier New&#39;; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes"></span><span style="line-height: 115%; font-family: &#39;Courier New&#39;; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes">If you have complex sproc, SQL Server Profiler will spit out thousands of trace lines during the run. A quick way to pin point the SQL statements needing performance tuning is to use File &gt; Save As to put the trace results in to a table. You can use then following query that immediately surfaces culprits. Notice that statements which run in WHILE loop might take less time individually but collectively their duration sum may be higher. Below query would reveal this culprits immediately.       <br />        <br /></span><span style="color: blue">select </span><span style="color: magenta">SUBSTRING</span><span style="color: gray">(</span>TextData<span style="color: gray">, </span>1<span style="color: gray">, </span>4000<span style="color: gray">), </span><span style="color: magenta">SUM</span><span style="color: gray">(</span>duration<span style="color: gray">), </span><span style="color: magenta">COUNT</span><span style="color: gray">(</span>1<span style="color: gray">)       <br /></span><span style="color: blue">from </span>[SavedTrace]<span style="color: gray">       <br /></span><span style="color: blue">group by </span><span style="color: magenta">SUBSTRING</span><span style="color: gray">(</span>TextData<span style="color: gray">, </span>1<span style="color: gray">, </span>4000<span style="color: gray">)       <br /></span><span style="color: blue">order by </span>2 <span style="color: blue">desc</span></li>   <a href="http://11011.net/software/vspaste"></a></ul>  <p><span style="line-height: 115%; font-family: &#39;Courier New&#39;; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes"></span></p>  <p><span style="line-height: 115%; font-family: &#39;Courier New&#39;; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes">One of the big performance hits occur when you must process individual rows one at a time instead of in set. For instance, let’s say you have a table with a column that has comma delimited values. Now you want to split these values in each cell and create a new table which would have N rows for each row in original table – one for each spitted value. The Internet is littered with dozen ways to split strings in TSQL, some even uses CTEs (not a good idea because there are lots of gotchas like max recursion limit). So far the best way is to use SQL CLR with code like below. Its as fast as any native TSQL juggling, if not faster. However most important thing here is not SQL CLR but how you use this table valued function and here’s the secret: The best bang for the performance you would get is using CROSS APPLY (or OUTER APPLY) with table valued UDF.</span></p>  <p><span style="line-height: 115%; font-family: &#39;Courier New&#39;; font-size: 10pt; mso-bidi-language: hi; mso-no-proof: yes"></span></p>  <pre class="code"><span style="color: blue">public partial class </span><span style="color: #2b91af">UtilityFunctions
</span>{
    [Microsoft.SqlServer.Server.<span style="color: #2b91af">SqlFunction</span>(FillRowMethodName = <span style="color: #a31515">&quot;FillRow&quot;</span>, TableDefinition=<span style="color: #a31515">&quot;StringPart nvarchar(max)&quot;</span>, 
        IsDeterministic=<span style="color: blue">true</span>, IsPrecise=<span style="color: blue">true</span>, SystemDataAccess=<span style="color: #2b91af">SystemDataAccessKind</span>.None)]
    <span style="color: blue">public static </span><span style="color: #2b91af">IEnumerable </span>ClrSplitString(<span style="color: #2b91af">SqlString </span>sqlStringToSplit, <span style="color: #2b91af">SqlChars </span>delimiter, <span style="color: #2b91af">SqlBoolean </span>removeEmptyEntries)
    {
        <span style="color: blue">if </span>(!<span style="color: blue">string</span>.IsNullOrEmpty(sqlStringToSplit.Value))
        {
            <span style="color: blue">return </span>sqlStringToSplit.Value.Split(delimiter.Value
                , (<span style="color: #2b91af">StringSplitOptions</span>)(removeEmptyEntries ?
                        <span style="color: #2b91af">StringSplitOptions</span>.RemoveEmptyEntries : <span style="color: #2b91af">StringSplitOptions</span>.None));
        }
        <span style="color: blue">else
        </span>{
            <span style="color: blue">return null</span>;
        }
    }

    <span style="color: blue">public static void </span>FillRow(<span style="color: blue">object </span>obj, <span style="color: blue">out </span><span style="color: #2b91af">SqlString </span>splittedString)
    {
        <span style="color: blue">if </span>(obj != <span style="color: blue">null</span>)
            splittedString = <span style="color: blue">new </span><span style="color: #2b91af">SqlString</span>((<span style="color: blue">string</span>)obj);
        <span style="color: blue">else
            </span>splittedString = <span style="color: #2b91af">SqlString</span>.Null;
    }
}</pre>
<a href="http://11011.net/software/vspaste"></a>]]></content:encoded>
    </item>
    <item>
      <title>Test Results Windows and Exception has been thrown by the target of an invocation</title>
      <link>https://docs.microsoft.com/archive/blogs/shitals/test-results-windows-and-exception-has-been-thrown-by-the-target-of-an-invocation</link>
      <pubDate>Thu, 31 Dec 2009 15:29:45 GMT</pubDate>
      <dc:creator><![CDATA[Shital Shah]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shitals/2009/12/31/test-results-windows-and-exception-has-been-thrown-by-the-target-of-an-invocation/</guid>
      <description><![CDATA[Just a note… if you are getting “Exception has been thrown by the target of an invocation” message...]]></description>
      <content:encoded><![CDATA[<p>Just a note… if you are getting “Exception has been thrown by the target of an invocation” message when opening Test Results window in Visual Studio 2008 then it’s most likely because you have an open solution in offline mode that was bound to some TFS instance. A bug that can waste lots of your time if you didn’t knew about it!</p>]]></content:encoded>
    </item>
    <item>
      <title>What to do on dreaded error CS0003: Out of memory</title>
      <link>https://docs.microsoft.com/archive/blogs/shitals/what-to-do-on-dreaded-error-cs0003-out-of-memory</link>
      <pubDate>Thu, 31 Dec 2009 01:36:33 GMT</pubDate>
      <dc:creator><![CDATA[Shital Shah]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shitals/2009/12/31/what-to-do-on-dreaded-error-cs0003-out-of-memory/</guid>
      <description><![CDATA[I’ve spent way too much of time today (again!) on this error so here’s blog post for future reminder...]]></description>
      <content:encoded><![CDATA[<p>I’ve spent way too much of time today (again!) on this error so here’s blog post for future reminder to me!</p>  <p>If you are generating or working with very large proxies then you might see following error:</p>  <p><code>Exception: InvalidOperationException      <br />Message: Unable to generate a temporary class (result=1).       <br />error CS0001: Internal compiler error (0xc00000fd)       <br />error CS0003: Out of memory</code></p>  <p>This error typically occurs when .Net infrastructure attempts to generate *XmlSerializers.dll on the fly. To do this csc.exe is spawned off and if your proxy is too large then it might error out with a message like above. This seems to be a bug in csc and reportedly it might get fixed in .Net 4.0.</p>  <p>Meanwhile, here’s how you can workaround it:</p>  <p>First make sure all your classes that are derived from SoapHttpClientProtocol (i.e. the proxy classes) are decorated with WebServiceBindingAttribute. If you have a whole class hierarchy that derives from SoapHttpClientProtocol then all classes in that hierarchy must be decorated.</p>  <p>Next, for all the projects that contains classes derived from SoapHttpClientProtocol, turn “Generate serialization assembly” option on Build page to ON. Remember you will need to do this for Debug as well as Release mode or your code will fail in production.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/shitals/WindowsLiveWriter/WhattodoondreadederrorCS0003Outofmemory_12FB/clip_image002_2.jpg" original-url="http://blogs.msdn.com/blogfiles/shitals/WindowsLiveWriter/WhattodoondreadederrorCS0003Outofmemory_12FB/clip_image002_2.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/shitals/WindowsLiveWriter/WhattodoondreadederrorCS0003Outofmemory_12FB/clip_image002_thumb.jpg" original-url="http://blogs.msdn.com/blogfiles/shitals/WindowsLiveWriter/WhattodoondreadederrorCS0003Outofmemory_12FB/clip_image002_thumb.jpg" width="382" height="47" /></a></p>  <p>Now you are set. The *XmlSerializers.dll will be generated and signed+versioned automatically (if your project is signed and versioned) when you do build and csc.exe won’t get spawned to cause above error.</p>  <p>Few more things to keep in mind:</p>  <ul>   <li>One of the “popular” workaround in some forums is to switch IIS app pool for WCF to 32-bit. I wouldn’t advise this because you loose all the advantage of 64-bit, primarily, access to all the memory available on server.</li>    <li>Above error often occurs for <strong>Microsoft Dynamics CRM</strong> proxies if you have tons of entities and attributes.</li>    <li>If your code is running as plugin then you might have <strong>plugin</strong> DLLs hosted at different location than main app exe. An example of this is Microsoft Dynamics CRM plugins that gets hosted by CRM Async service. In this case, you need to copy the *XmlSerializer.dll generated after the build to same location as host exe otherwise it won’t be found by .Net infrastructure!</li>    <li>If you are using Visual Studio integrated debugging feature for WCF services then you must <strong>run Visual Studio as Administrator</strong> or above error will pop its ugly head when you are debugging.</li> </ul>  <p>If above steps doesn’t solve your problem then you might have to dig deeper using techniques described <a href="http://blog.bits-in-motion.com/2009/11/xmlserializers-moduleversionid-ilmerge.html">here</a>, watching binding errors from fuslogvw or attempt to generate Xml serilizer DLL manually using sgen. </p>]]></content:encoded>
    </item>
    <item>
      <title>Silencing Exceptions in a Little Better Way</title>
      <link>https://docs.microsoft.com/archive/blogs/shitals/silencing-exceptions-in-a-little-better-way</link>
      <pubDate>Mon, 07 Dec 2009 15:54:35 GMT</pubDate>
      <dc:creator><![CDATA[Shital Shah]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shitals/2009/12/07/silencing-exceptions-in-a-little-better-way/</guid>
      <description><![CDATA[Some of the most disastrous code usually takes the following form  try
{
    //some...]]></description>
      <content:encoded><![CDATA[<p>Some of the most disastrous code usually takes the following form</p>  <pre class="code"><span style="color: blue">try
</span>{
    <span style="color: green">//some code
</span>}
<span style="color: blue">catch
</span>{ }</pre>
Silencing exceptions is almost never good but sometime the problem is minor and you don’t want want to blow up and call for an exit. However wouldn’t it be better if exceptions don’t remain silent and scream for your attention when you are debugging and behave less aggressively otherwise?

<p>How about if we can replace above code with following:</p>

<pre class="code">IgnoreExceptionButNotIfDebugging(() =&gt;
{
    <span style="color: green">//some code
</span>});</pre>

<p>Better.</p>

<p>The mysterious IgnoreExceptionButNotIfDebugging is a simple method that takes lambda and it would look like below:</p>

<p>&#160;</p>

<pre class="code"><span style="color: blue">public static void </span>IgnoreExceptionButNotIfDebugging(<span style="color: #2b91af">Action </span>codeBlockToExecute)
{
    <span style="color: blue">try
    </span>{
        codeBlockToExecute();
    }
    <span style="color: blue">catch </span>(<span style="color: #2b91af">Exception </span>ex)
    {
        <span style="color: blue">if </span>(<span style="color: #2b91af">Debugger</span>.IsAttached)
            <span style="color: #2b91af">Debugger</span>.Break();

        <span style="color: #2b91af">Trace</span>.Write(<span style="color: #a31515">&quot;Exception occured: &quot; </span>+ ex.Message);

        <span style="color: #2b91af">EventLog</span>.WriteEntry(<span style="color: #a31515">&quot;MyApp&quot;</span>, ex.Message, <span style="color: #2b91af">EventLogEntryType</span>.Warning);

<span style="color: blue">#if </span>DEBUG
            <span style="color: blue">throw</span>;
<span style="color: blue">#endif
    </span>}
}</pre>

<p>Now you can surround any of your code by IgnoreExceptionButNotIfDebugging and make sure things don’t remain silent when you are debugging!</p>]]></content:encoded>
    </item>
    <item>
      <title>Lightweight DataTable Serialization</title>
      <link>https://docs.microsoft.com/archive/blogs/shitals/lightweight-datatable-serialization</link>
      <pubDate>Fri, 04 Dec 2009 08:32:07 GMT</pubDate>
      <dc:creator><![CDATA[Shital Shah]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shitals/2009/12/04/lightweight-datatable-serialization/</guid>
      <description><![CDATA[We all know untyped data structures like DataTable and DataSet should not be passed around but...]]></description>
      <content:encoded><![CDATA[<p>We all know untyped data structures like DataTable and DataSet should not be passed around but sometimes - just sometimes - you got to do it because it makes sense and because it’s the most cost effective way to meet your goals. However passing things like DataTable over WCF can kill performance because of huge serialization overhead in both space and time. </p>  <p>So if you really had to go ahead with this crazy idea of sending DataTable over WCF then here’s the somewhat more efficient serialization technique you can use. The basic idea is to use binary serialization of DataTable and pass that serialized data as byte array along with the schema information so the client can reconstruct it on other end. It’s needless to say that doing this would invariably restrict your WCF clients to .Net so you might also want to include other web method for other clients.</p>  <p>&#160;</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3583085e-c1d1-4497-9f94-a2ac7ebe3b01" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> LightWeightSerialize(<span style="color:#2b91af">DataTable</span> myDataTable, <span style="color:#0000ff">out</span> <span style="color:#0000ff">byte</span>[] serializedTableData, <span style="color:#0000ff">out</span> <span style="color:#0000ff">string</span> tableSchema)<br> {<br> &#160;&#160;&#160;&#160;<span style="color:#008000">//Get all row values as jagged object array</span><br> &#160;&#160;&#160;&#160;<span style="color:#0000ff">object</span>[][] tableItems = <span style="color:#0000ff">new</span> <span style="color:#0000ff">object</span>[myDataTable.Rows.Count][];<br> &#160;&#160;&#160;&#160;<span style="color:#0000ff">for</span> (<span style="color:#0000ff">int</span> rowIndex = 0; rowIndex &lt; myDataTable.Rows.Count; rowIndex++)<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tableItems[rowIndex] = myDataTable.Rows[rowIndex].ItemArray;<br> <br> &#160;&#160;&#160;&#160;<span style="color:#008000">//binary serialize jagged object array</span><br> &#160;&#160;&#160;&#160;<span style="color:#2b91af">BinaryFormatter</span> serializationFormatter = <span style="color:#0000ff">new</span> <span style="color:#2b91af">BinaryFormatter</span>();<br> &#160;&#160;&#160;&#160;<span style="color:#2b91af">MemoryStream</span> buffer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MemoryStream</span>();<br> &#160;&#160;&#160;&#160;serializationFormatter.Serialize(buffer, tableItems);<br> &#160;&#160;&#160;&#160;serializedTableData = buffer.ToArray();<br> <br> <br> &#160;&#160;&#160;&#160;<span style="color:#008000">//Get table schema</span><br> &#160;&#160;&#160;&#160;<span style="color:#2b91af">StringBuilder</span> tableSchemaBuilder = <span style="color:#0000ff">new</span> <span style="color:#2b91af">StringBuilder</span>();<br> &#160;&#160;&#160;&#160;myDataTable.WriteXmlSchema(<span style="color:#0000ff">new</span> <span style="color:#2b91af">StringWriter</span>(tableSchemaBuilder));<br> &#160;&#160;&#160;&#160;tableSchema = tableSchemaBuilder.ToString();<br> }</div> </div> </div>  <p>&#160;</p>  <p>And here’s the deserializer to go with it:</p>  <p>&#160;</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fa7bb90c-8fba-4e50-b14d-65447c187c1c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">DataTable</span> LightWeightDeserialize(<span style="color:#0000ff">byte</span>[] serializedTableData, <span style="color:#0000ff">string</span> tableSchema)<br> {<br> &#160;&#160;&#160;&#160;<span style="color:#2b91af">DataTable</span> table = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DataTable</span>();<br> &#160;&#160;&#160;&#160;table.ReadXmlSchema(<span style="color:#0000ff">new</span> <span style="color:#2b91af">StringReader</span>(tableSchema));<br> <br> &#160;&#160;&#160;&#160;<span style="color:#2b91af">BinaryFormatter</span> serializationFormatter = <span style="color:#0000ff">new</span> <span style="color:#2b91af">BinaryFormatter</span>();<br> &#160;&#160;&#160;&#160;<span style="color:#2b91af">MemoryStream</span> buffer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MemoryStream</span>(serializedTableData);<br> &#160;&#160;&#160;&#160;<span style="color:#0000ff">object</span>[][] itemArrayForRows = (<span style="color:#0000ff">object</span>[][]) serializationFormatter.Deserialize(buffer);<br> <br> &#160;&#160;&#160;&#160;table.MinimumCapacity = itemArrayForRows.Length;<br> &#160;&#160;&#160;&#160;table.BeginLoadData();<br> &#160;&#160;&#160;&#160;<span style="color:#0000ff">for</span> (<span style="color:#0000ff">int</span> rowIndex = 0; rowIndex &lt; itemArrayForRows.Length; rowIndex++)<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;table.Rows.Add(itemArrayForRows[rowIndex]);<br> &#160;&#160;&#160;&#160;table.EndLoadData();<br> <br> &#160;&#160;&#160;&#160;<span style="color:#0000ff">return</span> table;<br> }</div> </div> </div>  <p>&#160;</p>  <p>How efficient is this? It really depends on your data. For instance, with some of my test data with 10K rows I could get about 6X smaller payload size and 30% faster serialization. But as number of rows increases, the speed advantage diminishes compared to built-in XML serializer that you can access via ReadXml/WriteXml. For example, for a million row, above method still gives me 4X smaller payload but serialization is actually 3X slower than built-in XML serializer. So experiment before you go either way!</p>]]></content:encoded>
    </item>
    <item>
      <title>The Best Culture Invariant Format for DateTime</title>
      <link>https://docs.microsoft.com/archive/blogs/shitals/the-best-culture-invariant-format-for-datetime</link>
      <pubDate>Sun, 08 Nov 2009 17:35:41 GMT</pubDate>
      <dc:creator><![CDATA[Shital Shah]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shitals/2009/11/08/the-best-culture-invariant-format-for-datetime/</guid>
      <description><![CDATA[If you are looking to display how to display DateTime as text without causing confusion to users in...]]></description>
      <content:encoded><![CDATA[<p>If you are looking to display how to display DateTime as text without causing confusion to users in different countries then good choices is either &quot;o&quot; or &quot;r&quot;. The &quot;o&quot; format is in general more preferable as it also puts timezone offset.</p>  <p>&#160;</p>  <p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 8pt">long</span><span style="font-family: &quot;Courier New&quot;; font-size: 8pt"> t = <span style="color: #2b91af">DateTime</span>.Now.Ticks;      <br />&#160;</span><span style="font-family: &quot;Courier New&quot;; font-size: 8pt"><span style="color: #2b91af">Console</span>.WriteLine((<span style="color: blue">new</span> <span style="color: #2b91af">DateTime</span>(t)).ToString(<span style="color: #a31515">&quot;o&quot;</span>));      <br />&#160;</span><span style="font-family: &quot;Courier New&quot;; font-size: 8pt"><span style="color: #2b91af">Console</span>.WriteLine((<span style="color: blue">new</span> <span style="color: #2b91af">DateTime</span>(t, <span style="color: #2b91af">DateTimeKind</span>.Local)).ToString(<span style="color: #a31515">&quot;o&quot;</span>));      <br />&#160;</span><span style="font-family: &quot;Courier New&quot;; font-size: 8pt"><span style="color: #2b91af">Console</span>.WriteLine((<span style="color: blue">new</span> <span style="color: #2b91af">DateTime</span>(t, <span style="color: #2b91af">DateTimeKind</span>.Unspecified)).ToString(<span style="color: #a31515">&quot;o&quot;</span>));      <br />&#160;</span><span style="font-family: &quot;Courier New&quot;; font-size: 8pt"><span style="color: #2b91af">Console</span>.WriteLine((<span style="color: blue">new</span> <span style="color: #2b91af">DateTime</span>(t, <span style="color: #2b91af">DateTimeKind</span>.Utc)).ToString(<span style="color: #a31515">&quot;o&quot;</span>));      <p></p>   </span>    <p></p> </p>  <p>&#160;</p>  <p>Prints followings when actual date time is 2009-11-08T17:16:13.7791953 PST:   <br />2009-11-08T17:16:13.7791953    <br />2009-11-08T17:16:13.7791953-08:00    <br />2009-11-08T17:16:13.7791953    <br />2009-11-08T17:16:13.7791953Z</p>  <p>   <br />If you use &quot;r&quot; instead it would print followings:    <br />Sun, 08 Nov 2009 17:26:02 GMT    <br />Sun, 08 Nov 2009 17:26:02 GMT    <br />Sun, 08 Nov 2009 17:26:02 GMT    <br />Sun, 08 Nov 2009 17:26:02 GMT</p>]]></content:encoded>
    </item>
    <item>
      <title>Find Path of a Command Line Tool</title>
      <link>https://docs.microsoft.com/archive/blogs/shitals/find-path-of-a-command-line-tool</link>
      <pubDate>Thu, 29 Oct 2009 16:06:45 GMT</pubDate>
      <dc:creator><![CDATA[Shital Shah]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shitals/2009/10/29/find-path-of-a-command-line-tool/</guid>
      <description><![CDATA[Many times you work on different machines, execute a command line tool but often wonder where that...]]></description>
      <content:encoded><![CDATA[<p>Many times you work on different machines, execute a command line tool but often wonder where that tool is actually installed. One way to figure this out is to look at all environment PATH variables and search them manually in same order as Windows does. But you don’t have to because luckily there is a little known built-in command called WHERE that does that for you:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/shitals/WindowsLiveWriter/FindPathofaCommandLineTool_E24B/image_8.png" original-url="http://blogs.msdn.com/blogfiles/shitals/WindowsLiveWriter/FindPathofaCommandLineTool_E24B/image_8.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/shitals/WindowsLiveWriter/FindPathofaCommandLineTool_E24B/image_thumb_3.png" original-url="http://blogs.msdn.com/blogfiles/shitals/WindowsLiveWriter/FindPathofaCommandLineTool_E24B/image_thumb_3.png" width="644" height="92" /></a> </p>  <p>This is similar to Unix commands like WHICH and WHEREIS.</p>]]></content:encoded>
    </item>
    <item>
      <title>How to Right Align Address in Word Document</title>
      <link>https://docs.microsoft.com/archive/blogs/shitals/how-to-right-align-address-in-word-document</link>
      <pubDate>Fri, 09 Oct 2009 01:33:23 GMT</pubDate>
      <dc:creator><![CDATA[Shital Shah]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shitals/2009/10/09/how-to-right-align-address-in-word-document/</guid>
      <description><![CDATA[May be the silliest thing but how do you align address on the right side of a letter in Microsoft...]]></description>
      <content:encoded><![CDATA[<p>May be the silliest thing but how do you align address on the right side of a letter in Microsoft Word 2010? Select the text you need and then click on that little square in Ribbon bar:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_2.png" original-url="http://blogs.msdn.com/blogfiles/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_thumb.png" original-url="http://blogs.msdn.com/blogfiles/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_thumb.png" width="526" height="484" /></a> </p>  <p>Type amount of indentation you need. It’s typically 5” for letter size:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_4.png" original-url="http://blogs.msdn.com/blogfiles/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_thumb_1.png" original-url="http://blogs.msdn.com/blogfiles/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_thumb_1.png" width="644" height="473" /></a> </p>  <p></p>  <p>And you have right aligned address!</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_6.png" original-url="http://blogs.msdn.com/blogfiles/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_6.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_thumb_2.png" original-url="http://blogs.msdn.com/blogfiles/shitals/WindowsLiveWriter/HowtoRightAlignAddressinWordDocument_13D2F/image_thumb_2.png" width="644" height="303" /></a></p>]]></content:encoded>
    </item>
    <item>
      <title>Selecting Random Row From SQL Server Table</title>
      <link>https://docs.microsoft.com/archive/blogs/shitals/selecting-random-row-from-sql-server-table</link>
      <pubDate>Mon, 05 Oct 2009 20:08:25 GMT</pubDate>
      <dc:creator><![CDATA[Shital Shah]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shitals/2009/10/05/selecting-random-row-from-sql-server-table/</guid>
      <description><![CDATA[It is important to make sure your automated tests covers various real-world data combinations (for...]]></description>
      <content:encoded><![CDATA[<p>It is important to make sure your automated tests covers various real-world data combinations (for instance, some columns could be null or some rows could be duplicate). For perf testing you want to reduce effects of caching by not firing same SQL over and over. In these cases, ability to select a random row for your test could come in handy and here’s neat little trick to do it:</p>  <p><span style="font-family: &#39;Courier New&#39;; color: blue; font-size: 10pt; mso-no-proof: yes">select</span><span style="font-family: &#39;Courier New&#39;; font-size: 10pt; mso-no-proof: yes"> <span style="color: blue">top</span> 1 <span style="color: gray">*       <br /></span></span><span style="font-family: &#39;Courier New&#39;; color: blue; font-size: 10pt; mso-no-proof: yes">from</span><span style="font-family: &#39;Courier New&#39;; font-size: 10pt; mso-no-proof: yes"> <span style="color: blue">table       <br /></span></span><span style="line-height: 115%; font-family: &#39;Courier New&#39;; color: blue; font-size: 10pt; mso-no-proof: yes">order</span><span style="line-height: 115%; font-family: &#39;Courier New&#39;; font-size: 10pt; mso-no-proof: yes"> <span style="color: blue">by</span> <span style="color: fuchsia">newid</span><span style="color: gray">()</span></span></p>]]></content:encoded>
    </item>
  </channel>
</rss>