<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Random ramblings about Technology</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/martijnh/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/martijnh/feed.xml</link>
    <description />
    <lastBuildDate>Fri, 10 Apr 2015 20:53:25 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>SQL Server–HOW-TO: quickly retrieve accurate row count for table</title>
      <link>https://docs.microsoft.com/archive/blogs/martijnh/sql-serverhow-to-quickly-retrieve-accurate-row-count-for-table</link>
      <pubDate>Thu, 15 Jul 2010 13:24:00 GMT</pubDate>
      <dc:creator><![CDATA[martijnh1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martijnh/2010/07/15/sql-serverhow-to-quickly-retrieve-accurate-row-count-for-table/</guid>
      <description><![CDATA[Recently, I&rsquo;ve been involved in a very interesting project in which we need to perform...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: Calibri;" face="Calibri">Recently, I&rsquo;ve been involved in a very interesting project in which we need to perform operations on a table containing 3,000,000,000+ rows. For some tooling, I needed a quick and reliable way to count the number of rows contained within this table. Performing a simple </span></p>
<p style="line-height: normal; margin: 0in 0in 0pt;" class="MsoNormal"><span style="font-family: Calibri;" face="Calibri"><span style="font-size: small;" size="3"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt;">SELECT</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: fuchsia;">COUNT</span><span style="color: gray;">(*)</span> <span style="color: blue;">FROM</span> Transactions</span></span></span></p>
<p style="line-height: normal; margin: 0in 0in 0pt;" class="MsoNormal"></p>
<p><span style="font-family: Calibri;" face="Calibri">operation would do the trick on small tables with low IO, but what&rsquo;s the &lsquo;best&rsquo; way (quick and reliable) to perform this operation on large tables?</span></p>
<p><span style="font-family: Calibri;" face="Calibri">I searched and found different answers, which I note here so it might be of use to someone&hellip; (My table was called &lsquo;Transactions&rsquo;)</span></p>
<table style="width: 500px; border-collapse: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0cm 0cm 0cm 0cm;" class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes;">
<td style="border-bottom: #d4d0c8 1pt inset; border-left: #4f81bd 1pt solid; width: 4.42%; background: #4f81bd; border-top: #4f81bd 1pt solid; border-right: #d4d0c8 1pt inset; mso-border-top-alt: solid #4f81bd 1.0pt; mso-border-left-alt: solid #4f81bd 1.0pt; mso-border-bottom-alt: inset #d4d0c8 .75pt; mso-border-right-alt: inset #d4d0c8 .75pt; padding: 0cm;" valign="top" width="4%">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><b><span style="color: white; font-size: 12pt; mso-ascii-font-family: calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri; mso-fareast-language: nl;"><span style="font-family: Calibri;" face="Calibri">Index </span></span></b></p>
</td>
<td style="background: url('/controlpanel/blogs/posteditor.aspx/none') #4f81bd; padding: 0cm 5.4pt; border: 1px solid #f0f0f0; width: 30%; mso-border-top-alt: solid #4f81bd 1.0pt; mso-border-left-alt: solid #4f81bd 1.0pt; mso-border-bottom-alt: inset #d4d0c8 .75pt; mso-border-right-alt: inset #d4d0c8 .75pt;" valign="top">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: Calibri;" face="Calibri"><b><span style="color: white; font-size: 12pt; mso-ascii-font-family: calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri; mso-fareast-language: nl;">Query </span></b><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl;"></span></span></p>
</td>
<td style="border-bottom: #d4d0c8 1pt inset; padding-bottom: 0cm; padding-left: 5.4pt; width: 43.92%; padding-right: 5.4pt; background: #4f81bd; border-left-color: #f0f0f0; border-top: #4f81bd 1pt solid; border-right: #4f81bd 1pt solid; padding-top: 0cm; mso-border-top-alt: solid #4f81bd 1.0pt; mso-border-left-alt: inset #d4d0c8 .75pt; mso-border-bottom-alt: inset #d4d0c8 .75pt; mso-border-right-alt: solid #4f81bd 1.0pt;" valign="top" width="552">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: Calibri;" face="Calibri"><b><span style="color: white; font-size: 12pt; mso-ascii-font-family: calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri; mso-fareast-language: nl;">Comment</span></b><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl;"> </span></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="border-bottom: #4f81bd 1pt solid; border-left: #4f81bd 1pt solid; background-color: transparent; border-top-color: #f0f0f0; width: 4.42%; border-right: #d4d0c8 1pt inset; mso-border-top-alt: solid #4f81bd 1.0pt; mso-border-right-alt: inset #d4d0c8 .75pt; mso-border-alt: solid #4f81bd 1.0pt; padding: 0cm;" valign="top" width="4%">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: calibri; mso-fareast-language: nl; mso-bidi-theme-font: minor-latin;"><span style="font-family: Calibri;" face="Calibri">1 </span></span></p>
</td>
<td style="border-bottom: #4f81bd 1pt solid; padding-bottom: 0cm; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 51.66%; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: #d4d0c8 1pt inset; padding-top: 0cm; mso-border-top-alt: solid #4f81bd 1.0pt; mso-border-left-alt: solid #4f81bd 1.0pt; mso-border-right-alt: inset #d4d0c8 .75pt; mso-border-alt: solid #4f81bd 1.0pt;" valign="top" width="51%">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl;">SELECT</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl;"> <span style="color: fuchsia;">COUNT</span><span style="color: gray;">(*)</span> <span style="color: blue;">FROM</span> Transactions</span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl;"> </span></p>
</td>
<td style="border-bottom: #4f81bd 1pt solid; padding-bottom: 0cm; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 43.92%; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: #4f81bd 1pt solid; padding-top: 0cm; mso-border-top-alt: solid #4f81bd 1.0pt; mso-border-left-alt: inset #d4d0c8 .75pt;" valign="top" width="552">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: Calibri;" face="Calibri"><span style="font-size: 12pt; mso-ascii-font-family: calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">Performs a full table scan. </span><span style="font-size: 12pt; mso-ascii-font-family: calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri; mso-fareast-language: nl;">Slow on large tables.</span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl;"> </span></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="border-bottom: #d4d0c8 1pt inset; border-left: #4f81bd 1pt solid; background-color: transparent; border-top-color: #f0f0f0; width: 4.42%; border-right: #d4d0c8 1pt inset; mso-border-top-alt: inset #d4d0c8 .75pt; mso-border-left-alt: solid #4f81bd 1.0pt; mso-border-alt: inset #d4d0c8 .75pt; padding: 0cm;" valign="top" width="4%">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: calibri; mso-fareast-language: nl; mso-bidi-theme-font: minor-latin; mso-ansi-language: en-us;" lang="EN-US"><span style="font-family: Calibri;" face="Calibri">2 </span></span></p>
</td>
<td style="border-bottom: #d4d0c8 1pt inset; padding-bottom: 0cm; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 51.66%; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: #d4d0c8 1pt inset; padding-top: 0cm; mso-border-top-alt: inset #d4d0c8 .75pt; mso-border-left-alt: solid #4f81bd 1.0pt; mso-border-alt: inset #d4d0c8 .75pt;" valign="top" width="51%">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">SELECT</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> <span style="color: fuchsia;">CONVERT</span><span style="color: gray;">(</span><span style="color: blue;">bigint</span><span style="color: gray;">,</span> <span style="color: blue;">rows</span><span style="color: gray;">)</span> </span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"></span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">FROM</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> <span style="color: green;">sysindexes</span> </span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"></span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">WHERE</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> id <span style="color: gray;">=</span> <span style="color: fuchsia;">OBJECT_ID</span><span style="color: gray;">(</span><span style="color: red;">'Transactions'</span><span style="color: gray;">)</span> </span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"></span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: gray; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl;">AND</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl;"> indid <span style="color: gray;">&lt;</span> 2</span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl;"> </span></p>
</td>
<td style="border-bottom: #d4d0c8 1pt inset; padding-bottom: 0cm; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 43.92%; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: #4f81bd 1pt solid; padding-top: 0cm; mso-border-top-alt: inset #d4d0c8 .75pt; mso-border-left-alt: inset #d4d0c8 .75pt; mso-border-right-alt: solid #4f81bd 1.0pt; mso-border-alt: inset #d4d0c8 .75pt;" valign="top" width="552">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: Calibri;" face="Calibri"><span style="font-size: 12pt; mso-ascii-font-family: calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">Fast way to retrieve row count. Depends on statistics and is inaccurate.</span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span></span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: Calibri;" face="Calibri"><span style="font-size: 12pt; mso-ascii-font-family: calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">Run DBCC UPDATEUSAGE(Database) WITH COUNT_ROWS, which can take significant time for large tables.</span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="border-bottom: #4f81bd 1pt solid; border-left: #4f81bd 1pt solid; background-color: transparent; border-top-color: #f0f0f0; width: 4.42%; border-right: #d4d0c8 1pt inset; mso-border-top-alt: solid #4f81bd 1.0pt; mso-border-right-alt: inset #d4d0c8 .75pt; mso-border-alt: solid #4f81bd 1.0pt; padding: 0cm;" valign="top" width="4%">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: calibri; mso-fareast-language: nl; mso-bidi-theme-font: minor-latin; mso-ansi-language: en-us;" lang="EN-US"><span style="font-family: Calibri;" face="Calibri">3 </span></span></p>
</td>
<td style="border-bottom: #4f81bd 1pt solid; padding-bottom: 0cm; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 51.66%; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: #d4d0c8 1pt inset; padding-top: 0cm; mso-border-top-alt: solid #4f81bd 1.0pt; mso-border-left-alt: solid #4f81bd 1.0pt; mso-border-right-alt: inset #d4d0c8 .75pt; mso-border-alt: solid #4f81bd 1.0pt;" valign="top" width="51%">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">SELECT</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> <span style="color: fuchsia;">CAST</span><span style="color: gray;">(</span>p<span style="color: gray;">.</span><span style="color: blue;">rows</span> <span style="color: blue;">AS</span> <span style="color: blue;">float</span><span style="color: gray;">)</span></span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">FROM</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> <span style="color: green;">sys</span><span style="color: gray;">.</span><span style="color: green;">tables</span> <span style="color: blue;">AS</span> tbl </span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"></span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: gray; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">INNER</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> <span style="color: gray;">JOIN</span> <span style="color: green;">sys</span><span style="color: gray;">.</span><span style="color: green;">indexes</span> <span style="color: blue;">AS</span> idx <span style="color: blue;">ON</span> idx<span style="color: gray;">.</span><span style="color: fuchsia;">object_id</span> <span style="color: gray;">=</span> tbl<span style="color: gray;">.</span><span style="color: fuchsia;">object_id</span> <span style="color: gray;">and</span> idx<span style="color: gray;">.</span>index_id <span style="color: gray;">&lt;</span> 2</span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: gray; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">INNER</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> <span style="color: gray;">JOIN</span> <span style="color: green;">sys</span><span style="color: gray;">.</span><span style="color: green;">partitions</span> <span style="color: blue;">AS</span> p <span style="color: blue;">ON</span> p<span style="color: gray;">.</span><span style="color: fuchsia;">object_id</span><span style="color: gray;">=</span><span style="color: fuchsia;">CAST</span><span style="color: gray;">(</span>tbl<span style="color: gray;">.</span><span style="color: fuchsia;">object_id</span> <span style="color: blue;">AS</span> <span style="color: blue;">int</span><span style="color: gray;">)</span> </span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"></span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: gray; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">AND</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> p<span style="color: gray;">.</span>index_id<span style="color: gray;">=</span>idx<span style="color: gray;">.</span>index_id</span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">WHERE </span><span style="font-family: 'Courier New'; color: gray; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">((</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">tbl<span style="color: gray;">.</span>name<span style="color: gray;">=</span><span style="color: red;">N'Transactions'</span> </span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"></span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: gray; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">AND</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> <span style="color: fuchsia;">SCHEMA_NAME</span><span style="color: gray;">(</span>tbl<span style="color: gray;">.</span><span style="color: fuchsia;">schema_id</span><span style="color: gray;">)=</span><span style="color: red;">'dbo'</span><span style="color: gray;">))</span></span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span></p>
</td>
<td style="border-bottom: #4f81bd 1pt solid; padding-bottom: 0cm; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 43.92%; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: #4f81bd 1pt solid; padding-top: 0cm; mso-border-top-alt: solid #4f81bd 1.0pt; mso-border-left-alt: inset #d4d0c8 .75pt;" valign="top" width="552">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: Calibri;" face="Calibri"><span style="font-size: 12pt; mso-ascii-font-family: calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">The way the SQL management studio counts rows (look at table properties, storage, row count). </span><span style="font-size: 12pt; mso-ascii-font-family: calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri; mso-fareast-language: nl;">Very fast, but still an approximate number of rows.</span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl;"> </span></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 4; mso-yfti-lastrow: yes;">
<td style="border-bottom: #4f81bd 1pt solid; border-left: #4f81bd 1pt solid; background-color: transparent; border-top-color: #f0f0f0; width: 4.42%; border-right: #d4d0c8 1pt inset; mso-border-top-alt: inset #d4d0c8 .75pt; mso-border-left-alt: solid #4f81bd 1.0pt; mso-border-bottom-alt: solid #4f81bd 1.0pt; mso-border-right-alt: inset #d4d0c8 .75pt; padding: 0cm;" valign="top" width="4%">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: calibri; mso-fareast-language: nl; mso-bidi-theme-font: minor-latin; mso-ansi-language: en-us;" lang="EN-US"><span style="font-family: Calibri;" face="Calibri">4 </span></span></p>
</td>
<td style="border-bottom: #4f81bd 1pt solid; padding-bottom: 0cm; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 51.66%; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: #d4d0c8 1pt inset; padding-top: 0cm; mso-border-top-alt: inset #d4d0c8 .75pt; mso-border-left-alt: solid #4f81bd 1.0pt; mso-border-bottom-alt: solid #4f81bd 1.0pt; mso-border-right-alt: inset #d4d0c8 .75pt;" valign="top" width="51%">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">SELECT</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> <span style="color: fuchsia;">SUM</span><span style="color: blue;"> </span><span style="color: gray;">(</span>row_count<span style="color: gray;">)</span></span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">FROM</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> <span style="color: green;">sys</span><span style="color: gray;">.</span><span style="color: green;">dm_db_partition_stats</span></span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">WHERE</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> <span style="color: fuchsia;">object_id</span><span style="color: gray;">=</span><span style="color: fuchsia;">OBJECT_ID</span><span style="color: gray;">(</span><span style="color: red;">'Transactions'</span><span style="color: gray;">)</span>&nbsp;&nbsp;&nbsp; </span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"></span></p>
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: gray; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">AND</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span><span style="font-family: 'Courier New'; color: gray; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">(</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US">index_id<span style="color: gray;">=</span>0 <span style="color: gray;">or</span> index_id<span style="color: gray;">=</span>1<span style="color: gray;">);</span></span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span></p>
</td>
<td style="border-bottom: #4f81bd 1pt solid; padding-bottom: 0cm; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 43.92%; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: #4f81bd 1pt solid; padding-top: 0cm; mso-border-top-alt: inset #d4d0c8 .75pt; mso-border-left-alt: inset #d4d0c8 .75pt;" valign="top" width="552">
<p style="line-height: normal; margin: 0cm 0cm 0pt;" class="MsoNormal"><span style="font-size: 12pt; mso-ascii-font-family: calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"><span style="font-family: Calibri;" face="Calibri">Quick (although not as fast as method 2) operation and equally important, reliable.</span></span><span style="font-family: 'Times New Roman','serif'; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: nl; mso-ansi-language: en-us;" lang="EN-US"> </span></p>
</td>
</tr>
</tbody>
</table>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server 2008 R2 - generating INSERT statements for a table</title>
      <link>https://docs.microsoft.com/archive/blogs/martijnh/sql-server-2008-r2-generating-insert-statements-for-a-table</link>
      <pubDate>Thu, 24 Jun 2010 05:19:46 GMT</pubDate>
      <dc:creator><![CDATA[martijnh1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martijnh/2010/06/24/sql-server-2008-r2-generating-insert-statements-for-a-table/</guid>
      <description><![CDATA[Learned something new today. Maybe it’s well-known, but new to me, you can just run “C:\Program...]]></description>
      <content:encoded><![CDATA[<p>Learned something new today. Maybe it’s well-known, but new to me, you can just run “C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Publishing\1.4\SqlPubWiz.exe”. This nifty little tool can generate INSERT script very easily. Pictures tell the story :)</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:bd9da216-6119-43a0-a978-19dfec741f8b" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/2248.dbp_001-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/2248.dbp_5F00_001_2D00_8x6.png" title="" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/0763.dbp_001.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/0763.dbp_5F00_001.png" width="335" height="306" /></a></div>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:540bd78b-61d0-4ab3-8ae1-a8e61120b7f2" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/2728.dbp_002-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/2728.dbp_5F00_002_2D00_8x6.png" title="" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/2744.dbp_002.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/2744.dbp_5F00_002.png" width="335" height="306" /></a></div>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:6f170cec-29f5-4efb-afbc-ec43a0b32ebb" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/0216.dbp_003-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/0216.dbp_5F00_003_2D00_8x6.png" title="" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/0601.dbp_003.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/0601.dbp_5F00_003.png" width="335" height="306" /></a></div>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:c4d2b2f7-cf69-4bfa-b25b-39ffb9ab1072" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/4010.dbp_004-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/4010.dbp_5F00_004_2D00_8x6.png" title="" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/1780.dbp_004.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/1780.dbp_5F00_004.png" width="335" height="306" /></a></div>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:201f364e-aa74-49df-9371-37fff6d64503" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/0131.dbp_005-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/0131.dbp_5F00_005_2D00_8x6.png" title="" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/4846.dbp_005.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/4846.dbp_5F00_005.png" width="335" height="306" /></a></div>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:4ebb36f2-e2ec-498a-bba1-82c9f82c71c5" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/7802.dbp_006-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/7802.dbp_5F00_006_2D00_8x6.png" title="" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/0045.dbp_006.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/0045.dbp_5F00_006.png" width="335" height="306" /></a></div>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:41df9971-07d3-4677-9743-461f6e925a86" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/3386.dbp_007-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/3386.dbp_5F00_007_2D00_8x6.png" title="" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/2625.dbp_007.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/2625.dbp_5F00_007.png" width="335" height="306" /></a></div>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:7b016c2c-d2d9-40d9-a875-e28d1a16711e" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/3201.dbp_008-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/3201.dbp_5F00_008_2D00_8x6.png" title="" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/6443.dbp_008.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/6443.dbp_5F00_008.png" width="335" height="312" /></a></div>]]></content:encoded>
    </item>
    <item>
      <title>Reading MSMQ from within SSIS packages</title>
      <link>https://docs.microsoft.com/archive/blogs/martijnh/reading-msmq-from-within-ssis-packages</link>
      <pubDate>Thu, 10 Jun 2010 12:54:30 GMT</pubDate>
      <dc:creator><![CDATA[martijnh1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martijnh/2010/06/10/reading-msmq-from-within-ssis-packages/</guid>
      <description><![CDATA[Recently, I had to implement an SSIS package which imports some data into SQL Server from MSMQ. It...]]></description>
      <content:encoded><![CDATA[<p>Recently, I had to implement an SSIS package which imports some data into SQL Server from MSMQ. It turns out reading MSMQ from within an SSIS package is more difficult than it seems at first. I’ve documented how to get things working because I could find little other documentation.</p>  <p>When reading data from MSMQ, there’s multiple steps to take:</p>  <ul>   <li>Setting up a queue, if not yet available </li>    <li>Set up a connection with MSMQ by adding a connection manager to the SSIS package </li>    <li>Adding and configuring a Message Queue Task </li>    <li>Putting data onto the queue </li>    <li>Running the package to validate the data is read from the queue </li> </ul>  <h3>Setting up a queue</h3>  <p>In Windows Server (2008 R2 in my case), create a new queue. It doesn’t really matter whether this queue is transactional or not.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:229cb04c-4abc-4c0a-b6eb-eb7570a00d9f" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/1323.msmqqueue-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/1323.msmqqueue_2D00_8x6.png" title="The created queue" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/8512.msmqqueue_3.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/8512.msmqqueue_5F00_3.png" width="420" height="368" /></a></div>  <h3>Setting up a connection with MSMQ from within an SSIS package</h3>  <p>First things first, let’s start with setting up a connection manager for MSMQ. When creating a new SSIS package, this is the view you get:</p>  <p></p>  <p></p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:3579f335-96b8-476a-b32e-ef696bfca9ac" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/7041.connectionmanager-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/7041.connectionmanager_2D00_8x6.png" title="Adding a connection manager" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/1780.connectionmanager_18.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/1780.connectionmanager_5F00_18.png" width="580" height="297" /></a></div>  <p></p>  <p>In the “Connection Managers” area, right-click and choose “new connection”. From the list that is displayed, select the “MSMQ” type and click “Add”.</p>  <p>&#160;</p>  <p></p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:0de26ffd-4772-4fb1-8fbf-fe89286936dd" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/6560.msmqconnectionmanager-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/6560.msmqconnectionmanager_2D00_8x6.png" title="Choosing which connection manager to use" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/1207.msmqconnectionmanager_3.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/1207.msmqconnectionmanager_5F00_3.png" width="389" height="449" /></a></div>  <p></p>  <p>A new dialog pops up, in which you can configure the connection to be made. I choose “.\Private$\mh” (a local queue called “mh”). Click “Test” to ensure the connection can be made and click “OK”.</p>  <p></p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:381ddcf8-e139-47c1-9926-5aa7eb71b20c" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/5775.msmqconnectionmanagerconnection-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/5775.msmqconnectionmanagerconnection_2D00_8x6.png" title="Configuring the connection manager" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/1588.msmqconnectionmanagerconnection_5.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/1588.msmqconnectionmanagerconnection_5F00_5.png" width="420" height="297" /></a></div>  <p></p>  <p>The connection manager is set up.</p>  <h3>Adding a Message Queue Task</h3>  <p>Adding a Message Queue task to the Control Flow is easy, drag and drop it from the Toolbox on the left (press CTRL-ALT-X if it’s not displayed) to the Control Flow surface, like displayed below.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:312677e8-14fb-4955-8526-cbf8955e1229" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/3666.msmqtask-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/3666.msmqtask_2D00_8x6.png" title="Adding a Message Queue Task" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/7317.msmqtask_4.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/7317.msmqtask_5F00_4.png" width="580" height="397" /></a></div>  <p>To configure the Message Queue Task, double-click the Message Queue task’s icon on the left of the Task in the Control Flow. A new dialog pops up in which we’ll configure the task. Select the connection manager we set up previously for the “MSMQConnection” property within the dialog and change the default “Send message” value for the “Message” property to “Receive message”.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:023f4d85-28f4-4f25-98f5-866a984ab5e8" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/2538.msmqtaskconfig_01-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/2538.msmqtaskconfig_5F00_01_2D00_8x6.png" title="Setting general properties for the Message Queue Task" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/1884.msmqtaskconfig_01_8.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/1884.msmqtaskconfig_5F00_01_5F00_8.png" width="580" height="410" /></a></div>  <p>Change to the “Receive” configuration page by click “Receive” on the left-hand side of the dialog. Choose whether the message should be removed from the queue after it is read by SSIS. I’ve chosen not to timeout reading the queue. Set the “MessageType” property to “String message to variable”. </p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:1a7fe1a2-d552-402c-af3c-43eac42a588f" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/8838.msmqtaskconfig_02-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/8838.msmqtaskconfig_5F00_02_2D00_8x6.png" title="Setting the receive properties for the Message Queue Task" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/3808.msmqtaskconfig_02_4.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/3808.msmqtaskconfig_5F00_02_5F00_4.png" width="580" height="440" /></a></div>  <p>Click on the drop-down for the “Variable” property and choose “New variable&quot;. This will show a new dialog, in which a new variable can be defined. For this example, let’s use the information shown below and click “OK”.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:b8f0500d-230e-459a-9bdb-78d34d25ac9b" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/7711.msmqtaskconfig_02a-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/7711.msmqtaskconfig_5F00_02a_2D00_8x6.png" title="Creating a new variable in which the inbound message will be stored" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/0285.msmqtaskconfig_02a_3.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/0285.msmqtaskconfig_5F00_02a_5F00_3.png" width="580" height="554" /></a></div>  <p></p>  <p></p>  <p>After closing the dialog, we’ll be returned to the “Message Queue Task editor” dialog, which shows the newly created variable.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:f06eaae5-6649-4264-84db-01811c55afec" class="wlWriterEditableSmartContent"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/6661.msmqtaskconfig_02b-8x6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/6661.msmqtaskconfig_5F00_02b_2D00_8x6.png" title="" rel="thumbnail"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/77/64/metablogapi/2620.msmqtaskconfig_02b_3.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-77-64-metablogapi/2620.msmqtaskconfig_5F00_02b_5F00_3.png" width="580" height="411" /></a></div>  <p>The Message Queue Task is configured to read messages from the “.\Private$\mh” queue.</p>  <p></p>  <h3>Putting data onto the queue</h3>  <p><strong><font color="#ff0000">For SSIS to be able to read the queue, ensure you label everything you put onto the queue with the label ‘String message’. If you don’t the message will not be picked up by SSIS.</font></strong></p>  <h3>Validation the package</h3>  <p>Pressing F-5 (Debug) from within the Business Intelligence Development Studio will run the package, effectively picking up a message from the queue if there is any.</p>  <p>&#160;</p>  <p>HTH, happy trails!</p>]]></content:encoded>
    </item>
    <item>
      <title>TFS 2010 beta 2: connecting from Visual Studio 2008</title>
      <link>https://docs.microsoft.com/archive/blogs/martijnh/tfs-2010-beta-2-connecting-from-visual-studio-2008</link>
      <pubDate>Mon, 11 Jan 2010 02:52:59 GMT</pubDate>
      <dc:creator><![CDATA[martijnh1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martijnh/2010/01/11/tfs-2010-beta-2-connecting-from-visual-studio-2008/</guid>
      <description><![CDATA[Connecting to Team Foundation Server 2010 beta 2 from Visual Studio 2008 is easy: from Team...]]></description>
      <content:encoded><![CDATA[<p>Connecting to Team Foundation Server 2010 beta 2 from Visual Studio 2008 is easy: from Team Explorer, type the full URL in the "add server" dialog, e.g.:</p> <p><a href="https://mytfsserver:8080/tfs/defaultcollection">https://mytfsserver:8080/tfs/defaultcollection</a></p> <p>Please ensure you've (re-)installed Visual Studio 2008 SP1. If you installed Team Foundation Client after applying SP1, reinstall SP1.</p>]]></content:encoded>
    </item>
    <item>
      <title>Active Directory - Adding a user to a group from a non domain-joined computer throws PrincipalException</title>
      <link>https://docs.microsoft.com/archive/blogs/martijnh/active-directory-adding-a-user-to-a-group-from-a-non-domain-joined-computer-throws-principalexception</link>
      <pubDate>Wed, 06 Jan 2010 03:30:23 GMT</pubDate>
      <dc:creator><![CDATA[martijnh1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martijnh/2010/01/06/active-directory-adding-a-user-to-a-group-from-a-non-domain-joined-computer-throws-principalexception/</guid>
      <description><![CDATA[When using the new System.DirectoryServices.AccountManagement namespace, one might be inclined (as...]]></description>
      <content:encoded><![CDATA[<p>When using the new System.DirectoryServices.AccountManagement namespace, one might be inclined (as was I) to use the following code to add a user to a group (exception and comments handling removed):</p><pre class="code"><span style="color: blue">using </span>(<span style="color: #2b91af">GroupPrincipal </span>groupPrincipal = 
    <span style="color: #2b91af">GroupPrincipal</span>.FindByIdentity(
        domainContext, 
        System.DirectoryServices.AccountManagement.<span style="color: #2b91af">IdentityType</span>.Name, 
        groupName))
{
    <span style="color: blue">if </span>(groupPrincipal != <span style="color: blue">null</span>)
    {
        <span style="color: blue">using </span>(<span style="color: #2b91af">UserPrincipal </span>userPrincipal = 
            <span style="color: #2b91af">UserPrincipal</span>.FindByIdentity(
                domainContext, 
                System.DirectoryServices.AccountManagement.<span style="color: #2b91af">IdentityType</span>.UserPrincipalName, 
                UPN))
        {
            <span style="color: blue">if </span>(userPrincipal != <span style="color: blue">null</span>)
            {
                groupPrincipal.GroupScope = <span style="color: #2b91af">GroupScope</span>.Global;
                groupPrincipal.Members.Add(userPrincipal);
                groupPrincipal.Save();
            }
        }
    }
}
</pre>
<p>This works just fine if your machine is joined to the domain you're trying to provision. However, if your machine is not joined, the groupPrincipal.Save(); call throws a PrincipalException with an error code 1355 ("Information about the domain could not be retrieved (1355)").</p>
<p>Joining the domain solves this issue.</p>
<p>So what if joining the domain isn't an option?</p>
<p>In this case I found resorting to good old System.DirectoryServices fixes the issue, using the following code fragment:</p><pre class="code"><span style="color: blue">using </span>(<span style="color: #2b91af">UserPrincipal </span>userPrincipal =
    <span style="color: #2b91af">UserPrincipal</span>.FindByIdentity(domainContext, UPN))
{
    <span style="color: blue">if </span>(userPrincipal != <span style="color: blue">null</span>)
    {
        <span style="color: blue">using </span>(<span style="color: #2b91af">GroupPrincipal </span>groupPrincipal =
            <span style="color: #2b91af">GroupPrincipal</span>.FindByIdentity(domainContext, groupName))
        {
            <span style="color: blue">if </span>(groupPrincipal != <span style="color: blue">null</span>)
            {
                <span style="color: blue">if </span>(!userPrincipal.IsMemberOf(groupPrincipal))
                {
                    <span style="color: blue">string </span>userSid = <span style="color: blue">string</span>.Format(<span style="color: #a31515">"&lt;SID={0}&gt;"</span>, userPrincipal.ToSidString());
                    <span style="color: #2b91af">DirectoryEntry </span>groupDirectoryEntry =
                        (<span style="color: #2b91af">DirectoryEntry</span>)groupPrincipal.GetUnderlyingObject();
                    groupDirectoryEntry.Properties[<span style="color: #a31515">"member"</span>].Add(userSid);
                    groupDirectoryEntry.CommitChanges();
                }
            }
        }
    }
}</pre>
<p>ToSidString is an extension method which translates the "objectSid" property. Thanks to Richard for the way better implementation! (ignore "Enforce")</p><pre class="code"><span style="color: blue">public static string </span>ToSidString(<span style="color: blue">this </span><span style="color: #2b91af">Principal </span>principal)
{
    <span style="color: #2b91af">Enforce</span>.IsNotNull&lt;<span style="color: #2b91af">Principal</span>&gt;(principal, <span style="color: #a31515">"principal"</span>);

    <span style="color: #2b91af">SecurityIdentifier </span>sid = principal.Sid;
    <span style="color: blue">if </span>(sid == <span style="color: blue">null </span>|| sid.BinaryLength == 0)
    {
        <span style="color: blue">return null</span>;
    }

    <span style="color: blue">byte</span>[] buffer = <span style="color: blue">new byte</span>[sid.BinaryLength];
    sid.GetBinaryForm(buffer, 0);

    <span style="color: blue">string</span>[] hexBytes = <span style="color: #2b91af">Array</span>.ConvertAll(buffer, b =&gt; b.ToString(<span style="color: #a31515">"X2"</span>, <span style="color: #2b91af">NumberFormatInfo</span>.InvariantInfo));

    <span style="color: blue">return string</span>.Concat(hexBytes);
}
</pre><a href="https://11011.net/software/vspaste"></a><a href="https://11011.net/software/vspaste"></a><a href="https://11011.net/software/vspaste"></a>
<p>HTH!</p>]]></content:encoded>
    </item>
    <item>
      <title>Unity v1.2 - using enum values from configuration; writing and configuring a custom type converter</title>
      <link>https://docs.microsoft.com/archive/blogs/martijnh/unity-v1-2-using-enum-values-from-configuration-writing-and-configuring-a-custom-type-converter</link>
      <pubDate>Wed, 06 Jan 2010 00:34:24 GMT</pubDate>
      <dc:creator><![CDATA[martijnh1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martijnh/2010/01/06/unity-v1-2-using-enum-values-from-configuration-writing-and-configuring-a-custom-type-converter/</guid>
      <description><![CDATA[Recently, I used Unity v1.2, which in my opinion is a great product. I had difficulty, however, with...]]></description>
      <content:encoded><![CDATA[<p>Recently, I used Unity v1.2, which in my opinion is a great product. I had difficulty, however, with the configuration for a scenario I encountered. I needed an enum value to be passed to a constructor. Trying as I might, there was no way Unity was accepting my typeAlias, as such:</p><pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">unity</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">typeAliases</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">typeAlias 
      </span><span style="color: red">alias</span><span style="color: blue">=</span>"<span style="color: blue">contextType</span>" 
      <span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">System.DirectoryServices.AccountManagement.ContextType, 
            System.DirectoryServices.AccountManagement, Version=3.5.0.0, 
            Culture=neutral, PublicKeyToken=b77a5c561934e089</span>" <span style="color: blue">/&gt;
  &lt;/</span><span style="color: #a31515">typeAliases</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">containers</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">container </span><span style="color: red">name</span><span style="color: blue">=</span>"<span style="color: blue">identitystores</span>"<span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">types</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">type </span><span style="color: red">name</span><span style="color: blue">=</span>"<span style="color: blue">primary</span>" <span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">IIdentityStore</span>" <span style="color: red">mapTo</span><span style="color: blue">=</span>"<span style="color: blue">ActiveDirectoryIdentityStore</span>" <span style="color: blue">&gt;
          &lt;</span><span style="color: #a31515">lifetime </span><span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">singleton</span>" <span style="color: blue">/&gt;
          &lt;</span><span style="color: #a31515">typeConfig 
            </span><span style="color: red">extensionType</span><span style="color: blue">=</span>"<span style="color: blue">Microsoft.Practices.Unity.Configuration.TypeInjectionElement, 
                           Microsoft.Practices.Unity.Configuration</span>"<span style="color: blue">&gt;
            &lt;</span><span style="color: #a31515">constructor</span><span style="color: blue">&gt;
              &lt;</span><span style="color: #a31515">param </span><span style="color: red">name</span><span style="color: blue">=</span>"<span style="color: blue">context</span>" <span style="color: red">parameterType</span><span style="color: blue">=</span>"<span style="color: blue">contextType</span>"<span style="color: blue">&gt;
                &lt;</span><span style="color: #a31515">value
                  </span><span style="color: red">value</span><span style="color: blue">=</span>"<span style="color: blue">Domain</span>"
                  <span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">contextType</span>"  <span style="color: blue">/&gt;
              &lt;/</span><span style="color: #a31515">param</span><span style="color: blue">&gt;
            &lt;/</span><span style="color: #a31515">constructor</span><span style="color: blue">&gt;
          &lt;/</span><span style="color: #a31515">typeConfig</span><span style="color: blue">&gt;
        &lt;/</span><span style="color: #a31515">type</span><span style="color: blue">&gt;
      &lt;/</span><span style="color: #a31515">types</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">container</span><span style="color: blue">&gt;
  &lt;/</span><span style="color: #a31515">containers</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">unity</span><span style="color: blue">&gt;
</span></pre>
<p>For the life of me, I couldn't figure out what I did wrong. I asked in an internal discussion list, and someone mentioned writing a plain old TypeConverter... Right he was, getting my enum value to work was pretty easy. The TypeConverter (as always, comments removed for clarity and provided AS IS, etc.):</p><pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">ContextTypeTypeConverter </span>: <span style="color: #2b91af">TypeConverter
</span>{
    <span style="color: blue">public override bool </span>CanConvertFrom(<span style="color: #2b91af">ITypeDescriptorContext </span>context, <span style="color: #2b91af">Type </span>sourceType)
    {
        <span style="color: blue">return </span>sourceType.GetType() == <span style="color: blue">typeof</span>(<span style="color: blue">string</span>);
    }

    <span style="color: blue">public override bool </span>CanConvertTo(<span style="color: #2b91af">ITypeDescriptorContext </span>context, <span style="color: #2b91af">Type </span>destinationType)
    {
        <span style="color: blue">return </span>destinationType == <span style="color: blue">typeof</span>(<span style="color: #2b91af">ContextType</span>);
    }
    
    <span style="color: blue">public override object </span>ConvertFrom(
        <span style="color: #2b91af">ITypeDescriptorContext </span>context, 
        <span style="color: #2b91af">CultureInfo </span>culture, 
        <span style="color: blue">object </span>value)
    {
        <span style="color: blue">return </span><span style="color: #2b91af">Enum</span>.Parse(<span style="color: blue">typeof</span>(<span style="color: #2b91af">ContextType</span>), (<span style="color: blue">string</span>)value);
    }

    <span style="color: blue">public override object </span>ConvertTo(
        <span style="color: #2b91af">ITypeDescriptorContext </span>context, 
        <span style="color: #2b91af">CultureInfo </span>culture, 
        <span style="color: blue">object </span>value, 
        <span style="color: #2b91af">Type </span>destinationType)
    {
        <span style="color: blue">return </span><span style="color: #2b91af">Enum</span>.GetName(<span style="color: blue">typeof</span>(<span style="color: #2b91af">ContextType</span>), value);
    }
}</pre>
<p>and modified configuration file:</p><pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">unity</span><span style="color: blue">&gt;<br>&nbsp; &lt;</span><span style="color: #a31515">typeAliases</span><span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">typeAlias <br>&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: red">alias</span><span style="color: blue">=</span>"<span style="color: blue">contextType</span>" <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">System.DirectoryServices.AccountManagement.ContextType, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.DirectoryServices.AccountManagement, Version=3.5.0.0, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Culture=neutral, PublicKeyToken=b77a5c561934e089</span>" <span style="color: blue">/&gt;<br>&nbsp; &lt;/</span><span style="color: #a31515">typeAliases</span><span style="color: blue">&gt;<br>&nbsp; &lt;</span><span style="color: #a31515">containers</span><span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">container</span><span style="color: red">name</span><span style="color: blue">=</span>"<span style="color: blue">identitystores</span>"<span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">types</span><span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">type</span><span style="color: red">name</span><span style="color: blue">=</span>"<span style="color: blue">primary</span>" <span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">IIdentityStore</span>" <span style="color: red">mapTo</span><span style="color: blue">=</span>"<span style="color: blue">ActiveDirectoryIdentityStore</span>" <span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">lifetime</span><span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">singleton</span>" <span style="color: blue">/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">typeConfig <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: red">extensionType</span><span style="color: blue">=</span>"<span style="color: blue">Microsoft.Practices.Unity.Configuration.TypeInjectionElement, <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; Microsoft.Practices.Unity.Configuration</span>"<span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">constructor</span><span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">param </span><span style="color: red">name</span><span style="color: blue">=</span>"<span style="color: blue">context</span>" <span style="color: red">parameterType</span><span style="color: blue">=</span>"<span style="color: blue">string</span>"<span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">value<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: red">value</span><span style="color: blue">=</span>"<span style="color: blue">Domain</span>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">contextType</span>"<br><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: red">typeConverter</span><span style="color: blue">=</span>"</strong><strong><span style="color: blue">Microsoft.AccountManagement.Extensions.ContextTypeTypeConverter, <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;&nbsp;&nbsp;&nbsp; Microsoft.AccountManagement.Extensions, Version=1.0.0.0, <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;&nbsp;&nbsp;&nbsp; Culture=neutral, PublicKeyToken=4fd564a94067c21</span>"</strong><span style="color: blue"><strong>/&gt;</strong><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #a31515">param</span><span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #a31515">constructor</span><span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #a31515">typeConfig</span><span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #a31515">type</span><span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #a31515">types</span><span style="color: blue">&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #a31515">container</span><span style="color: blue">&gt;<br>&nbsp; &lt;/</span><span style="color: #a31515">containers</span><span style="color: blue">&gt;<br>&lt;/</span><span style="color: #a31515">unity</span><span style="color: blue">&gt;</span></pre>That's it, now everything works just fine. HTH someone out there :)]]></content:encoded>
    </item>
    <item>
      <title>WCF extensions: The type 'x' registered for extension 'y' could not be loaded.</title>
      <link>https://docs.microsoft.com/archive/blogs/martijnh/wcf-extensions-the-type-x-registered-for-extension-y-could-not-be-loaded</link>
      <pubDate>Mon, 04 Jan 2010 04:26:14 GMT</pubDate>
      <dc:creator><![CDATA[martijnh1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martijnh/2010/01/04/wcf-extensions-the-type-x-registered-for-extension-y-could-not-be-loaded/</guid>
      <description><![CDATA[Quick note: if you configure a custom extension in WCF, don't forget to add it as a reference to...]]></description>
      <content:encoded><![CDATA[<p>Quick note: if you configure a custom extension in WCF, don't forget to add it as a reference to your project. If you don't configuration will run just fine, but at runtime, the following exception occurs:</p> <p>System.Configuration.ConfigurationErrorsException: The type 'x' registered for extension 'y' could not be loaded. (config information, line z)</p> <p>&nbsp;&nbsp; at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)<br>&nbsp;&nbsp; at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object&amp; result, Object&amp; resultRuntimeObject)<br>&nbsp;&nbsp; at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object&amp; result, Object&amp; resultRuntimeObject)<br>&nbsp;&nbsp; at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object&amp; result, Object&amp; resultRuntimeObject)<br>&nbsp;&nbsp; at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object&amp; result, Object&amp; resultRuntimeObject)<br>&nbsp;&nbsp; at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)<br>&nbsp;&nbsp; at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)<br>&nbsp;&nbsp; at System.Configuration.ConfigurationManager.GetSection(String sectionName)<br>&nbsp;&nbsp; at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetSectionFromConfigurationManager(String sectionPath)<br>&nbsp;&nbsp; at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetAssociatedSection(ContextInformation evalContext, String sectionPath)<br>&nbsp;&nbsp; at System.ServiceModel.Configuration.ServicesSection.UnsafeGetSection()<br>&nbsp;&nbsp; at System.ServiceModel.Description.ConfigLoader.LookupService(String serviceConfigurationName)<br>&nbsp;&nbsp; at System.ServiceModel.ServiceHostBase.ApplyConfiguration()<br>&nbsp;&nbsp; at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)<br>&nbsp;&nbsp; at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)<br>&nbsp;&nbsp; at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind)<br>&nbsp;&nbsp; at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info) </p>]]></content:encoded>
    </item>
    <item>
      <title>Unit testing: COM object that has been separated from its underlying RCW cannot be used</title>
      <link>https://docs.microsoft.com/archive/blogs/martijnh/unit-testing-com-object-that-has-been-separated-from-its-underlying-rcw-cannot-be-used</link>
      <pubDate>Thu, 31 Dec 2009 02:20:39 GMT</pubDate>
      <dc:creator><![CDATA[martijnh1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martijnh/2009/12/31/unit-testing-com-object-that-has-been-separated-from-its-underlying-rcw-cannot-be-used/</guid>
      <description><![CDATA[Let's say you're writing unit tests for code which uses COM objects. You want some initialization...]]></description>
      <content:encoded><![CDATA[<p>Let's say you're writing unit tests for code which uses COM objects. You want some initialization and some cleanup to be done. So you set up your test:</p><pre class="code"><span style="color: blue">private static </span><span style="color: #2b91af">MyStore </span>store;
</pre><a href="https://11011.net/software/vspaste"></a><pre class="code">[<span style="color: #2b91af">ClassInitialize</span>()]
<span style="color: blue">public static void </span>MyClassInitialize(<span style="color: #2b91af">TestContext </span>testContext)
{
    store = <span style="color: blue">new </span><span style="color: #2b91af">MyStore</span>(<span style="color: #a31515">"some value"</span>);
}
</pre><a href="https://11011.net/software/vspaste"></a><pre class="code">[<span style="color: #2b91af">ClassCleanup</span>]
<span style="color: blue">public static void </span>MyClassCleanup()
{
<span style="color: green">    </span>store.DoWork(someArgument);
}</pre>
<p>However, as your 'store' instance uses a COM object, you will get a test run error, saying: "System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used..".</p>
<p>The way to solve this issue is to open up your testrunconfig file using the XML editor and adding the highlighted element to it:</p><pre class="code"><span style="color: blue">&lt;?</span><span style="color: #a31515">xml </span><span style="color: red">version</span><span style="color: blue">=</span>"<span style="color: blue">1.0</span>" <span style="color: red">encoding</span><span style="color: blue">=</span>"<span style="color: blue">UTF-8</span>"<span style="color: blue">?&gt;
&lt;</span><span style="color: #a31515">TestRunConfiguration </span><span style="color: red">name</span><span style="color: blue">=</span>"<span style="color: blue">Local Test Run</span>" <span style="color: red">id</span><span style="color: blue">=</span>"<span style="color: blue">fbbfe81f-97fa-4e33-bde1-00b3827b933e</span>" <span style="color: red">xmlns</span><span style="color: blue">=</span>"<span style="color: blue">https://microsoft.com/schemas/VisualStudio/TeamTest/2006</span>"<span style="color: blue">&gt;
<strong>  &lt;</strong></span><strong><span style="color: #a31515">ExecutionThread </span><span style="color: red">apartmentState</span><span style="color: blue">=</span>"<span style="color: blue">MTA</span>" </strong><span style="color: blue"><strong>/&gt;
</strong>  &lt;</span><span style="color: #a31515">Description</span><span style="color: blue">&gt;</span>This is a default test run configuration for a local test run.<span style="color: blue">&lt;/</span><span style="color: #a31515">Description</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">TestTypeSpecific </span><span style="color: blue">/&gt;
&lt;/</span><span style="color: #a31515">TestRunConfiguration</span><span style="color: blue">&gt;</span></pre>The ExecutionThread element will instruct the test to use the MTA threading model. This way, the static instance of "store" can be shared across tests.]]></content:encoded>
    </item>
    <item>
      <title>Office 2010 Development – Outlook main window ribbon ID</title>
      <link>https://docs.microsoft.com/archive/blogs/martijnh/office-2010-development-outlook-main-window-ribbon-id</link>
      <pubDate>Tue, 01 Sep 2009 02:51:00 GMT</pubDate>
      <dc:creator><![CDATA[martijnh1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martijnh/2009/09/01/office-2010-development-outlook-main-window-ribbon-id/</guid>
      <description><![CDATA[I’m currently writing an Outlook add-in and I’m looking into getting this compatible with both...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-ansi-language: en" lang=EN><FONT color=#000000 size=3 face=Calibri>I’m currently writing an Outlook add-in and I’m looking into getting this compatible with both Office 2007 and Office 2010. One of the new features in Outlook 2010 is the main window Ribbon. </FONT></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-ansi-language: en" lang=EN><FONT color=#000000 size=3 face=Calibri>Using VSTO, you can create your own Ribbon, which can be automatically merged with default Ribbons by setting the correct OfficeId property for your Ribbon. Office 2007 has the list of available OfficeId values available </FONT><A href="https://blogs.msdn.com/redir.aspx?C=f3c986b3badc4ac3bb1025b97e021ab9&amp;URL=http%3a%2f%2fwww.microsoft.com%2fdownloads%2fdetails.aspx%3ffamilyid%3d4329D9E9-4D11-46A5-898D-23E4F331E9AE%26displaylang%3den" mce_href="https://blogs.msdn.com/redir.aspx?C=f3c986b3badc4ac3bb1025b97e021ab9&amp;URL=http%3a%2f%2fwww.microsoft.com%2fdownloads%2fdetails.aspx%3ffamilyid%3d4329D9E9-4D11-46A5-898D-23E4F331E9AE%26displaylang%3den"><FONT color=#0000ff size=3 face=Calibri>here</FONT></A><FONT size=3><FONT color=#000000><FONT face=Calibri>, but I has some trouble locating a list for the Office 2010 Technical Preview. </FONT></FONT></FONT></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-ansi-language: en" lang=EN><FONT size=3><FONT color=#000000><FONT face=Calibri>After some trial and error, I figures out there’s an easy way to find out what the different IDs for a specific Ribbon and it’s tabs is. 
<P mce_keep="true">&nbsp;</P></FONT></FONT></FONT></SPAN>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-ansi-language: en" lang=EN><FONT size=3><FONT color=#000000><FONT face=Calibri>Office 2010 let’s users customize the Ribbon from within Office.</FONT></FONT></FONT></SPAN> 
<P><FONT color=#000000 size=3 face=Calibri></FONT>&nbsp;</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_001_2.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_001_2.png" mce_href="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_001_2.png"><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=outlook_2010_ribbon_001 border=0 alt=outlook_2010_ribbon_001 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_001_thumb.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_001_thumb.png" width=719 height=502 mce_src="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_001_thumb.png"></A> </P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-ansi-language: en" lang=EN><FONT color=#000000 size=3 face=Calibri>Clicking ‘Customize the Ribbon’ brings up the customization dialog:</FONT></SPAN></P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_002_2.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_002_2.png" mce_href="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_002_2.png"><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=outlook_2010_ribbon_002 border=0 alt=outlook_2010_ribbon_002 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_002_thumb.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_002_thumb.png" width=732 height=599 mce_src="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_002_thumb.png"></A> </P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-ansi-language: en" lang=EN><FONT size=3><FONT color=#000000><FONT face=Calibri>On the right-hand side of the dialog, right-click the ‘RSS’ tab within the expanded ‘Home’ tab and choose ‘Rename’. Name it e.g. ‘testRSS’. After customizing, press OK on the dialog and re-open the customization dialog once more (if you don’t close and re-open the dialog, the following steps will not lead to the desired result).&nbsp; 
<P mce_keep="true">&nbsp;</P></FONT></FONT></FONT></SPAN>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-ansi-language: en" lang=EN><FONT size=3><FONT color=#000000><FONT face=Calibri>Now press the ‘Import/Export’ button and select ‘Export all Ribbon and Quick Access Toolbar customizations’. Save the file.</FONT></FONT></FONT></SPAN> 
<P><FONT color=#000000 size=3 face=Calibri></FONT>&nbsp;</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_003_2.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_003_2.png" mce_href="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_003_2.png"><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=outlook_2010_ribbon_003 border=0 alt=outlook_2010_ribbon_003 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_003_thumb.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_003_thumb.png" width=732 height=541 mce_src="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_003_thumb.png"></A> </P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-ansi-language: en" lang=EN><FONT size=3><FONT face=Calibri>The exported Office UI file has a .exportedUI extension. Rename this to .xml and open up the file. You’ll see something like this:</FONT></FONT></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-ansi-language: en" lang=EN><FONT size=3><FONT face=Calibri>
<P mce_keep="true">&nbsp;</P></FONT></FONT></SPAN><FONT color=#0000ff size=2><FONT color=#0000ff size=2><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"></SPAN>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:cmd</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt">app</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">MSOutlook</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt">dt</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">0</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"> /&gt; </SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:customUI</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt">xmlns:mso</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">https://schemas.microsoft.com/office/2007/10/customui</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&gt;</SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&nbsp; &lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:ribbon</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&gt;</SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&nbsp;&nbsp;&nbsp; &lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:qat</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">/&gt;</SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&nbsp;&nbsp;&nbsp; &lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:tabs</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&gt;</SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:tab</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt">idQ</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">mso:<STRONG><SPAN style="FONT-FAMILY: 'Courier New'">TabMail</SPAN></STRONG></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&gt;</SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:group</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt">idQ</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">mso:GroupRss</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt">label</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">testRSS</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt">"</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">/&gt;</SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:tab</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&gt;</SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&nbsp;&nbsp;&nbsp; &lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:tabs</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&gt;</SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&nbsp; &lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:ribbon</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&gt;</SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt">mso:customUI</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">&gt;</SPAN></P><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"></SPAN><SPAN style="COLOR: blue"><SPAN style="mso-ansi-language: en" lang=EN><FONT face="Times New Roman"><FONT color=#000000>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="mso-ansi-language: en" lang=EN><FONT size=3><FONT face=Calibri>Note the ‘TabMail’ ID. This is the current (it’s a technical preview, things will probably change in the future) identifier for the Ribbon Tab you’ve just modified.</FONT></FONT></SPAN></P>
<P><FONT face=Calibri><SPAN style="mso-ansi-language: en" lang=EN><FONT size=3>OK, we’ve got the Tab OfficeID. However, for a Ribbon to show up, you also need to specify RibbonType property. Normally, using VSTO, you get a drop down with all possible values for this property within Visual Studio. However, the main window Ribbon in Outlook is new, so there’s no value for this Ribbon within the list. Luckily, you can also type in your own value. Now all that’s left is finding out the name of the main Ribbon and we’d be set.</FONT></SPAN></FONT></P>
<P><FONT face=Calibri>
<P><FONT size=3>I looked around, but the value for the main Ribbon was a mystery to me. Finally, I decided Outlook probably had the string in memory during runtime, so I could use Process Explorer to find the correct value. As you probably know, Process Explorer has a tab called ‘strings’ on the properties dialog of a process. This tab enumerates all strings within the image of the process and lists them here. </FONT></P></FONT>
<P><FONT face=Calibri>
<P><FONT size=3><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_004_2.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_004_2.png" mce_href="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_004_2.png"><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=outlook_2010_ribbon_004 border=0 alt=outlook_2010_ribbon_004 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_004_thumb.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_004_thumb.png" width=530 height=614 mce_src="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_004_thumb.png"></A> </FONT></P></FONT>
<P><FONT face=Calibri>
<P><FONT size=3>I searched for ‘Microsoft.Outlook.’ (all values in the regular drop down start with this) and found ‘Microsoft.Outlook.Explorer’. Searching further, the other values we all know and love came up. However, ‘Microsoft.Outlook.Explorer’ was the only truly new value.</FONT></P></FONT>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3>&nbsp;<A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_005_2.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_005_2.png" mce_href="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_005_2.png"><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=outlook_2010_ribbon_005 border=0 alt=outlook_2010_ribbon_005 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_005_thumb.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_005_thumb.png" width=531 height=614 mce_src="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_005_thumb.png"></A><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_006_2.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_006_2.png" mce_href="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_006_2.png"><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=outlook_2010_ribbon_006 border=0 alt=outlook_2010_ribbon_006 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_006_thumb.png" original-url="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_006_thumb.png" width=531 height=615 mce_src="https://blogs.msdn.com/blogfiles/martijnh/WindowsLiveWriter/Office2010DevelopmentOutlookmainwindowri_A679/outlook_2010_ribbon_006_thumb.png"></A> </FONT></P>
<P><FONT size=3 face=Calibri>I tried using this value for the RibbonType and low and behold, my add-in appeared on the ‘RSS’ tab of the main Ribbon.</FONT></P>
<P><FONT size=3 face=Calibri><FONT color=#ff0000><STRONG>Key take-away</STRONG></FONT>: Using a RibbonType of ‘Microsoft.Outlook.Explorer’ and ‘TabMail’ as your ControlId, you can place your add-in on the main ribbon of the Outlook window.</FONT></P></FONT></FONT></SPAN></SPAN></FONT>
<P mce_keep="true">UPDATE: in Visual Studio 2010 beta 2, you can just select the RibbonType mentioned ;-)</P>
<P mce_keep="true">&nbsp;</P>
<P><STRONG>Disclaimer: This has been tested on the Technical Preview of Office 2010. There are no guarantees whether these IDs will be stable as we move forward with the product.</STRONG></P></FONT>]]></content:encoded>
    </item>
    <item>
      <title>PrintMonitor – A C# print spooler monitor</title>
      <link>https://docs.microsoft.com/archive/blogs/martijnh/printmonitor-a-c-print-spooler-monitor</link>
      <pubDate>Wed, 05 Aug 2009 05:40:34 GMT</pubDate>
      <dc:creator><![CDATA[martijnh1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martijnh/2009/08/05/printmonitor-a-c-print-spooler-monitor/</guid>
      <description><![CDATA[Recently, a colleague of mine had a requirement of getting information on the number of pages being...]]></description>
      <content:encoded><![CDATA[<p>Recently, a colleague of mine had a requirement of getting information on the number of pages being printed by users. Monitoring a printer is done by calling FindFirstPrinterChangeNotification, waiting for the returned WaitHandle to be signaled and then calling </p> <p><font size="2">FindNextPrinterChangeNotification to see why the handle got signaled and act accordingly. Sadly, there don’t seem to be any samples of this in C# out there, so I created one in my spare time. The attached application monitors all printer notification fields possible. It still has some issues like not disposing things correctly, but that’s left as an exercise to the reader, as I don’t have more time to spent.</font></p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px" id="scid:8747F07C-CDE8-481f-B0DF-C6CFD074BF67:826d266e-5b4d-400e-a77b-4fc6cf0b51ed" class="wlWriterEditableSmartContent"><a href="https://home.online.nl/martijnhoogendoorn/blogpictures/PrintMonitorACprintspoolermonitor_A429/printmonitor8x6b165b1fd7c3f405193c1aeaa24ff0e50.png" title="Yes, I printed 1624 pages (to XPS)" rel="thumbnail"><img border="0" src="https://home.online.nl/martijnhoogendoorn/blogpictures/PrintMonitorACprintspoolermonitor_A429/printmonitor2c61f610edbd43ca8c349d77cbaa097a.png" width="361" height="273" /></a></div> <p><font size="2">Upon starting the application, the Load event of the main form hooks up the event and handles (it currently takes the first printer it can find):</font></p><pre class="code"><font size="2">printerWaitHandle = <span style="color: blue">new </span><span style="color: #2b91af">ManualResetEvent</span>(<span style="color: blue">false</span>);

<span style="color: #2b91af">PRINTER_INFO_2</span>[] printers = enumPrinters(<span style="color: #2b91af">PrinterEnumFlags</span>.PRINTER_ENUM_NAME);
<span style="color: blue">string </span>printerName = printers[0].pPrinterName;
OpenPrinter(printerName, <span style="color: blue">out </span>printerHandle, 0);

printerChangeHandle = FindFirstPrinterChangeNotification(printerHandle, (<span style="color: blue">int</span>)<span style="color: #2b91af">PRINTER_CHANGES</span>.PRINTER_CHANGE_DELETE_JOB, 0, notifyOptions);
printerWaitHandle.SafeWaitHandle = <span style="color: blue">new </span><span style="color: #2b91af">SafeWaitHandle</span>(printerChangeHandle, <span style="color: blue">true</span>);

printerChangeNotificationHandle = <span style="color: #2b91af">ThreadPool</span>.RegisterWaitForSingleObject(</font></pre>
<blockquote><pre class="code"><font size="2">printerWaitHandle, </font></pre><pre class="code"><font size="2"><span style="color: blue">new </span><span style="color: #2b91af">WaitOrTimerCallback</span>(PrinterNotifyWaitCallback), printerWaitHandle, -1, <span style="color: blue">true</span>);
</font></pre></blockquote><a href="https://11011.net/software/vspaste"></a>
<p><font size="2">The callback method (PrinterNotifyWaitCallback) interprets the change:</font></p><pre class="code"><font size="2"><span style="color: blue">public void </span>PrinterNotifyWaitCallback(<span style="color: blue">object </span>state, <span style="color: blue">bool </span>timedOut)
{
    </font><font size="2"><span style="color: green">// BUG: if we Thread.Sleep here for the amount of time it takes to spool the print job, we only get the right notification for number of pages.

    </span><span style="color: blue">int </span>changeReason = 0;
    <span style="color: #2b91af">IntPtr </span>pNotifyInfo = <span style="color: #2b91af">IntPtr</span>.Zero;

    <span style="color: blue">bool </span>nxt = FindNextPrinterChangeNotification(printerChangeHandle, <span style="color: blue">out </span>changeReason, <span style="color: blue">null</span>, <span style="color: blue">out </span>pNotifyInfo);
</font><font size="2"></font></pre><pre class="code"><font size="2">...</font></pre><pre class="code"><font size="2">}
</font></pre>
<p>This works quite well. There is a bug in there somewhere which causes the following behavior: the total number of pages is first set to 0 when spooling the print job and only on the *subsequent* print job being printed is the correct number of pages signaled. If you put a Thread.Sleep (don’t ;-)) in the callback for the amount of time it takes the spooler to spool the print job, the correct number of printed pages is displayed directly (without the ‘0’ entry and within the actual print job it belongs to). If anyone can find the bug, please let me know!</p>
<p>Sourcecode attached, as always, no warranties of any kind, express, implied, etc.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:14be0dbc-db38-4a94-94dd-4271c78de1f0" class="wlWriterEditableSmartContent"><p> <a href="https://home.online.nl/martijnhoogendoorn/blogpictures/PrintMonitorACprintspoolermonitor_A429/PrintMonitor9bca0cc1cf21425f9b1c8378bb456aeb.zip">Sourcecode</a></p></div>]]></content:encoded>
    </item>
  </channel>
</rss>