<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Zupancic Perspective (v2.0)</title>
    <link>http://blog.devstone.com/aaron/</link>
    <description>An insight into the world of R. Aaron Zupancic, software development (.NET, et al), muses, and much more...</description>
    <language>en-us</language>
    <copyright>R. Aaron Zupancic</copyright>
    <lastBuildDate>Tue, 04 Nov 2008 11:00:03 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>aaron@devstone.com</managingEditor>
    <webMaster>aaron@devstone.com</webMaster>
    <item>
      <trackback:ping>http://blog.devstone.com/aaron/Trackback.aspx?guid=799f95f6-3487-4220-ab1d-0ee04df4157e</trackback:ping>
      <pingback:server>http://blog.devstone.com/aaron/pingback.aspx</pingback:server>
      <pingback:target>http://blog.devstone.com/aaron/PermaLink,guid,799f95f6-3487-4220-ab1d-0ee04df4157e.aspx</pingback:target>
      <dc:creator>R. Aaron Zupancic (Administrator)</dc:creator>
      <wfw:comment>http://blog.devstone.com/aaron/CommentView,guid,799f95f6-3487-4220-ab1d-0ee04df4157e.aspx</wfw:comment>
      <wfw:commentRss>http://blog.devstone.com/aaron/SyndicationService.asmx/GetEntryCommentsRss?guid=799f95f6-3487-4220-ab1d-0ee04df4157e</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Tahoma">This evening, I upgraded an installation of SQL Server Express
2005 to its 2008 counterpart because I have a few small websites that I've developed
that rely on SQL User Instances.  The upgrade was smooth enough, but I was promptly
and unexpectedly greeted with an error message that I had seen before:</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Tahoma">
              <strong>Failed to generate a user instance of SQL Server due to
a failure in starting the process for the user instance. The connection will be closed.</strong>
            </font>
          </p>
        </blockquote>
        <p>
          <font face="Tahoma">Well, in the past to address this issue I've had to 1) stop the
SQL Express service, 2) delete the user's SQLEXPRESS directory, and 3) restart the
service.  The user, in this case, is the account under which the User Instance
is be created.</font>
        </p>
        <p>
          <font face="Tahoma">For instance, supposing that my user name were USERNAME, this
directory would be <strong>C:\Documents and Settings\USERNAME\Local Settings\Application
Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS</strong>.  Note, that on
a Vista/Windows Server 2008 machine that path is addressable (due to some very
ingenious reparse point (a.k.a. junction) mappings, the actual path is <strong>C:\Users\USERNAME\AppData\Local\Microsoft\Microsoft
SQL Server Data\SQLEXPRESS</strong>.</font>
        </p>
        <p>
          <font face="Tahoma">In this particular instance, however, this wasn't working for
me.  The reason was immediately obvious: my SQL Express service runs under the
NETWORK SERVICE account, not USERNAME.  I verified that I could indeed host the
User Instance by explicitly impersonating a priviliged user in the web.config file:</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New">&lt;identity impersonate="true" userName="MACHINE\Account"
password="somethingSecure" /&gt;</font>
          </p>
        </blockquote>
        <p>
          <font face="Tahoma">However, when I set it back to not impersonate (as it was before
the upgrade to SQL Server 2008) the User Instance would not start.</font>
        </p>
        <p>
          <font face="Tahoma">Ultimately, I did have to delete Network Service's SQLEXPRESS
directory, but it's found in a completely different location:  <strong>%WINDIR%\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Microsoft
SQL Server Data\SQLEXPRESS</strong>.  Once I took care of that directory and
restarted the SQL Services my site was off to the races.</font>
        </p>
        <img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=799f95f6-3487-4220-ab1d-0ee04df4157e" />
      </body>
      <title>Battling SQL User Instance failures to start</title>
      <guid isPermaLink="false">http://blog.devstone.com/aaron/PermaLink,guid,799f95f6-3487-4220-ab1d-0ee04df4157e.aspx</guid>
      <link>http://blog.devstone.com/aaron/2008/11/04/BattlingSQLUserInstanceFailuresToStart.aspx</link>
      <pubDate>Tue, 04 Nov 2008 11:00:03 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Tahoma&gt;This evening, I upgraded an installation of SQL Server Express 2005
to its 2008 counterpart because I have a few small websites that I've developed that
rely on SQL User Instances.&amp;nbsp; The upgrade was smooth enough, but I was promptly
and unexpectedly greeted with an error message that I had seen before:&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face=Tahoma&gt;&lt;strong&gt;Failed to generate a user instance of SQL Server due to
a failure in starting the process for the user instance. The connection will be closed.&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;font face=Tahoma&gt;Well, in the past to address this issue I've had to 1) stop the
SQL Express service, 2) delete the user's SQLEXPRESS directory, and 3) restart the
service.&amp;nbsp; The user, in this case, is the account under which the User Instance
is be created.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;For instance, supposing that my user name were USERNAME, this directory
would be &lt;strong&gt;C:\Documents and Settings\USERNAME\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data\SQLEXPRESS&lt;/strong&gt;.&amp;nbsp; Note, that on a&amp;nbsp;Vista/Windows Server
2008 machine that path is addressable (due to some very ingenious reparse point (a.k.a.
junction) mappings, the actual path is &lt;strong&gt;C:\Users\USERNAME\AppData\Local\Microsoft\Microsoft
SQL Server Data\SQLEXPRESS&lt;/strong&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;In this particular instance, however, this wasn't working for me.&amp;nbsp;
The reason was immediately obvious: my SQL Express service runs under the NETWORK
SERVICE account, not USERNAME.&amp;nbsp; I verified that I could indeed host the User
Instance by explicitly impersonating a priviliged user in the web.config file:&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;identity impersonate="true" userName="MACHINE\Account"
password="somethingSecure" /&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;font face=Tahoma&gt;However, when I set it back to not impersonate (as it was before
the upgrade to SQL Server 2008) the User Instance would not start.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Ultimately, I did have to delete Network Service's SQLEXPRESS directory,
but it's found in a completely different location:&amp;nbsp; &lt;strong&gt;%WINDIR%\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Microsoft
SQL Server Data\SQLEXPRESS&lt;/strong&gt;.&amp;nbsp; Once I took care of that directory and
restarted the SQL Services my site was off to the races.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=799f95f6-3487-4220-ab1d-0ee04df4157e" /&gt;</description>
      <comments>http://blog.devstone.com/aaron/CommentView,guid,799f95f6-3487-4220-ab1d-0ee04df4157e.aspx</comments>
      <category>ASP.NET</category>
      <category>Database</category>
      <category>SQL Server</category>
      <category>Web</category>
    </item>
    <item>
      <trackback:ping>http://blog.devstone.com/aaron/Trackback.aspx?guid=a803de98-e711-4ea2-b7a0-0ef32461c084</trackback:ping>
      <pingback:server>http://blog.devstone.com/aaron/pingback.aspx</pingback:server>
      <pingback:target>http://blog.devstone.com/aaron/PermaLink,guid,a803de98-e711-4ea2-b7a0-0ef32461c084.aspx</pingback:target>
      <dc:creator>R. Aaron Zupancic (Administrator)</dc:creator>
      <wfw:comment>http://blog.devstone.com/aaron/CommentView,guid,a803de98-e711-4ea2-b7a0-0ef32461c084.aspx</wfw:comment>
      <wfw:commentRss>http://blog.devstone.com/aaron/SyndicationService.asmx/GetEntryCommentsRss?guid=a803de98-e711-4ea2-b7a0-0ef32461c084</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Tahoma">I arrived to PDC 2008 (Professional Developers Conference) in
Los Angeles, California yesterday and I can honestly say that the women have it lucky
in one regard: no bathroom lines. :)</font>
        </p>
        <p>
          <font face="Tahoma">Today I had the opportunity to attend a <em>great</em> pre-conference
session/workshop on Silverlight 2.0, presented by Jeff Prosise (pronounced Pro-sice)
of Wintellect.</font>
        </p>
        <p>
          <font face="Tahoma">Having done s fair amount of Silverlight 1.0 development, I've
been long awaiting the release of version 2.0 and with good reason.  Version
2.0 builds on a great platform and adds a slew of new capabilities.  These new
features have long been touted, but I simply haven't had the chance to dive into
them until RTM what with my day-to-day responsibilities.  These include some
built-in support for Buttons, TextBoxes, ComboBoxes, ListBoxes, and Calendar controls
to name just a few.  Additionally, you have one-time, one-way, and duplex databinding. 
A nicely featured threading model and networking stack.</font>
        </p>
        <p>
          <font face="Tahoma">I'm looking forward to putting together a presentation of my own
for the Utah .NET User Group on this very topic.  Stay tuned!</font>
        </p>
        <img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=a803de98-e711-4ea2-b7a0-0ef32461c084" />
      </body>
      <title>PDC 2008 - Day 01 (Silverlight 2.0)</title>
      <guid isPermaLink="false">http://blog.devstone.com/aaron/PermaLink,guid,a803de98-e711-4ea2-b7a0-0ef32461c084.aspx</guid>
      <link>http://blog.devstone.com/aaron/2008/10/27/PDC2008Day01Silverlight20.aspx</link>
      <pubDate>Mon, 27 Oct 2008 03:26:17 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Tahoma&gt;I arrived to PDC 2008 (Professional Developers Conference) in Los
Angeles, California yesterday and I can honestly say that the women have it lucky
in one regard: no&amp;nbsp;bathroom lines. :)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Today I had&amp;nbsp;the opportunity to attend a &lt;em&gt;great&lt;/em&gt; pre-conference
session/workshop on Silverlight 2.0, presented by Jeff Prosise (pronounced Pro-sice)
of Wintellect.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Having done s fair amount of Silverlight 1.0 development, I've been
long awaiting the release of version 2.0 and with good reason.&amp;nbsp; Version 2.0 builds
on a great platform and adds a slew of new capabilities.&amp;nbsp; These new features
have long&amp;nbsp;been touted, but I simply haven't had the chance to dive into them
until RTM what with my day-to-day responsibilities.&amp;nbsp; These include some built-in
support for Buttons, TextBoxes, ComboBoxes, ListBoxes, and Calendar controls to name
just a few.&amp;nbsp; Additionally, you have one-time, one-way, and duplex databinding.&amp;nbsp;
A nicely featured threading model and networking stack.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;I'm looking forward to putting together a presentation of my own
for the Utah .NET User Group on this very topic.&amp;nbsp; Stay tuned!&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=a803de98-e711-4ea2-b7a0-0ef32461c084" /&gt;</description>
      <comments>http://blog.devstone.com/aaron/CommentView,guid,a803de98-e711-4ea2-b7a0-0ef32461c084.aspx</comments>
      <category>Silverlight</category>
      <category>PDC 2008</category>
    </item>
    <item>
      <trackback:ping>http://blog.devstone.com/aaron/Trackback.aspx?guid=7b0feb6d-88a2-4981-8c02-a410d320b5e8</trackback:ping>
      <pingback:server>http://blog.devstone.com/aaron/pingback.aspx</pingback:server>
      <pingback:target>http://blog.devstone.com/aaron/PermaLink,guid,7b0feb6d-88a2-4981-8c02-a410d320b5e8.aspx</pingback:target>
      <dc:creator>R. Aaron Zupancic (Administrator)</dc:creator>
      <wfw:comment>http://blog.devstone.com/aaron/CommentView,guid,7b0feb6d-88a2-4981-8c02-a410d320b5e8.aspx</wfw:comment>
      <wfw:commentRss>http://blog.devstone.com/aaron/SyndicationService.asmx/GetEntryCommentsRss?guid=7b0feb6d-88a2-4981-8c02-a410d320b5e8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <font face="Tahoma">
          <img style="FLOAT: right" src="http://blog.devstone.com/aaron/content/binary/InvalidAction.png" border="0" />
        </font>
        <p>
          <font face="Tahoma">When I awoke this morning I was greeted with a high priority
email indicating that our CRM server down.  I promptly discovered that we were
receiving a very descriptive "Invalid Action: The selected action was not valid"
error message.</font>
        </p>
        <p>
          <font face="Tahoma">I quickly Googled the error message and found a </font>
          <a href="http://www.sadev.co.za/node/173">
            <font face="Tahoma">single
entry</font>
          </a>
          <font face="Tahoma"> where the issue was disk space.  Well, it
turns out that disk space wasn't the issue, but it prompted me to clean up the transaction
logs.  That was a nice detour, but it didn't get me closer to solving the problem.</font>
        </p>
        <p>
          <font face="Tahoma">The next thing I checked was the system's Application Event Log. 
Lo and behold, I found the following error message:</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New">Source:   MSCRMKeyGenerator<br />
Event ID: 18949<br /><br />
Current active key (KeyType : CrmWRPCTokenKey) is expired. This can indicate that
a key is not being regenerated properly. Current Active Key : CrmKey(Id:c2e0c738-dc7a-dd11-b61e-00188b3466e9,
ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmWRPCTokenKey, Expired:True,
ValidOn:09/04/2008 23:50:21, ExpiresOn:10/07/2008 23:50:21, CreatedOn:09/04/2008 23:50:21,
CreatedBy:NT AUTHORITY\NETWORK SERVICE. Key Setting : </font>
          </p>
        </blockquote>
        <p>
          <font face="Tahoma">Fortunately, this problem was easily solved by running <strong>services.msc</strong> and
starting the <strong>Microsoft CRM Asynchronous Processing Service</strong>.</font>
        </p>
        <img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=7b0feb6d-88a2-4981-8c02-a410d320b5e8" />
      </body>
      <title>The Case of the Invalid Action in Microsoft CRM 4.0</title>
      <guid isPermaLink="false">http://blog.devstone.com/aaron/PermaLink,guid,7b0feb6d-88a2-4981-8c02-a410d320b5e8.aspx</guid>
      <link>http://blog.devstone.com/aaron/2008/10/08/TheCaseOfTheInvalidActionInMicrosoftCRM40.aspx</link>
      <pubDate>Wed, 08 Oct 2008 17:06:29 GMT</pubDate>
      <description>&lt;font face=Tahoma&gt;&lt;img style="FLOAT: right" src="http://blog.devstone.com/aaron/content/binary/InvalidAction.png" border=0&gt;&lt;/font&gt; 
&lt;p&gt;
&lt;font face=Tahoma&gt;When I awoke&amp;nbsp;this morning I was greeted with a high priority
email indicating that our CRM server down.&amp;nbsp; I promptly discovered that we were
receiving a very descriptive&amp;nbsp;"Invalid Action: The selected action was not valid"
error message.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;I quickly Googled the error message and found a &lt;/font&gt;&lt;a href="http://www.sadev.co.za/node/173"&gt;&lt;font face=Tahoma&gt;single
entry&lt;/font&gt;&lt;/a&gt;&lt;font face=Tahoma&gt; where the issue was disk space.&amp;nbsp; Well, it
turns out that disk space wasn't the issue, but it prompted me to clean up the transaction
logs.&amp;nbsp; That was a nice detour, but it didn't get me closer to solving the problem.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;The next thing I checked was the system's Application Event Log.&amp;nbsp;
Lo and behold, I found the following error message:&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;Source:&amp;nbsp;&amp;nbsp; MSCRMKeyGenerator&lt;br&gt;
Event ID: 18949&lt;br&gt;
&lt;br&gt;
Current active key (KeyType : CrmWRPCTokenKey) is expired. This can indicate that
a key is not being regenerated properly. Current Active Key : CrmKey(Id:c2e0c738-dc7a-dd11-b61e-00188b3466e9,
ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmWRPCTokenKey, Expired:True,
ValidOn:09/04/2008 23:50:21, ExpiresOn:10/07/2008 23:50:21, CreatedOn:09/04/2008 23:50:21,
CreatedBy:NT AUTHORITY\NETWORK SERVICE. Key Setting : &lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;font face=Tahoma&gt;Fortunately, this problem was easily solved by running &lt;strong&gt;services.msc&lt;/strong&gt; and
starting the &lt;strong&gt;Microsoft CRM Asynchronous Processing Service&lt;/strong&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=7b0feb6d-88a2-4981-8c02-a410d320b5e8" /&gt;</description>
      <comments>http://blog.devstone.com/aaron/CommentView,guid,7b0feb6d-88a2-4981-8c02-a410d320b5e8.aspx</comments>
      <category>CRM 4.0</category>
    </item>
    <item>
      <trackback:ping>http://blog.devstone.com/aaron/Trackback.aspx?guid=d9cc793c-79f5-47a6-9761-c9450911dc2c</trackback:ping>
      <pingback:server>http://blog.devstone.com/aaron/pingback.aspx</pingback:server>
      <pingback:target>http://blog.devstone.com/aaron/PermaLink,guid,d9cc793c-79f5-47a6-9761-c9450911dc2c.aspx</pingback:target>
      <dc:creator>R. Aaron Zupancic (Administrator)</dc:creator>
      <wfw:comment>http://blog.devstone.com/aaron/CommentView,guid,d9cc793c-79f5-47a6-9761-c9450911dc2c.aspx</wfw:comment>
      <wfw:commentRss>http://blog.devstone.com/aaron/SyndicationService.asmx/GetEntryCommentsRss?guid=d9cc793c-79f5-47a6-9761-c9450911dc2c</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <title>UCNUG Meeting - Wednesday Sept 17, 2008</title>
      <guid isPermaLink="false">http://blog.devstone.com/aaron/PermaLink,guid,d9cc793c-79f5-47a6-9761-c9450911dc2c.aspx</guid>
      <link>http://blog.devstone.com/aaron/2008/09/16/UCNUGMeetingWednesdaySept172008.aspx</link>
      <pubDate>Tue, 16 Sep 2008 18:36:12 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Tahoma&gt;Tomorrow night I have the opportunity to speak at the monthly Utah
County .NET User Group meeting.&amp;nbsp; Here's a synopsis of the talk:&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;b&gt;&lt;font face=Tahoma&gt;&lt;font color=#000080&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;Delving
Into the WinForms Control Designer Experience&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Tahoma color=#000080&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Tahoma color=#000080&gt;The .NET framework makes writing WinForms controls
accessible to any and all programmers.&amp;nbsp; In this session we’re going to focus
on the control’s design-time experience; that is, what users of your controls will
experience when writing software using your controls.&amp;nbsp; There is a rich set of
classes and tools that can help you create slick, professional components that will
make your users’ lives easier, but without knowing what they are or where to find
them it can be a challenge.&amp;nbsp; Even sometimes when armed with the knowledge, it’s
not always intuitive how to use the objects.&amp;nbsp; We’re going to discuss Editors,
Extensions, Verbs, Action Lists, Designers, and more.&amp;nbsp; We’ll see what it takes
to have your control actually ‘run’ at design-time to offer a rich, interactive experience
for the end user.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Tahoma color=#000080&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Tahoma color=#000080&gt;If you write WinForms controls for the .NET platform,
you won’t want to miss it!&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;font face=Tahoma&gt;The meeting will be held at the NuSkin building at 1175 S 350 E
in Provo.&amp;nbsp; I look forward to seeing you there!&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=d9cc793c-79f5-47a6-9761-c9450911dc2c" /&gt;</description>
      <comments>http://blog.devstone.com/aaron/CommentView,guid,d9cc793c-79f5-47a6-9761-c9450911dc2c.aspx</comments>
      <category>Utah .NET User Group</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://blog.devstone.com/aaron/Trackback.aspx?guid=58a12801-ebbf-477d-910e-aff37ae901bd</trackback:ping>
      <pingback:server>http://blog.devstone.com/aaron/pingback.aspx</pingback:server>
      <pingback:target>http://blog.devstone.com/aaron/PermaLink,guid,58a12801-ebbf-477d-910e-aff37ae901bd.aspx</pingback:target>
      <dc:creator>R. Aaron Zupancic (Administrator)</dc:creator>
      <wfw:comment>http://blog.devstone.com/aaron/CommentView,guid,58a12801-ebbf-477d-910e-aff37ae901bd.aspx</wfw:comment>
      <wfw:commentRss>http://blog.devstone.com/aaron/SyndicationService.asmx/GetEntryCommentsRss?guid=58a12801-ebbf-477d-910e-aff37ae901bd</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Tahoma">When granting database permissions to built-in security accounts
you need to be aware of potentially localized account names.</font>
        </p>
        <p>
          <font face="Tahoma">Just this past week I ran into an issue when attempting to execute
a SQL Server database script on a German server OS.  The database script in question
had hard-coded the usage of 'NT AUTHORITY\NETWORK SERVICE' as the account name for
granting database permissions.  As it turns out, however, this account doesn't
exist in the German version of Windows.  Instead, the account is 'NT-AUTORITÄT\NETZWERKDIENST'. 
I found it interesting that the account name is not localized on other non-English
versions of Windows.</font>
        </p>
        <p>
          <font face="Tahoma">Unless I misunderstanding something, the </font>
          <a href="http://msdn.microsoft.com/en-us/library/ms684272(VS.85).aspx">
            <font face="Tahoma">documentation</font>
          </a>
          <font face="Tahoma"> indicates
that "the name of the account in all locales is NT AUTHORITY\NETWORK SERVICE" so I
was initially confused by this.</font>
        </p>
        <p>
          <font face="Tahoma">In this particular case my script file is, conveniently, not executed
100% verbatim.  Via a little script engine that I wrote, I have the ability to
update variables with runtime values.  In this case, rather than use the exact
string 'NT AUTHORITY\NETWORK SERVICE', I replaced it with a variable and determined
the value to use at runtime.</font>
        </p>
        <p>
          <font face="Tahoma">Resolving to the properly localized account name is pretty easy:</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New">
              <font color="#008000">private static string</font> getNetworkServiceAcctName()
{<br />
   SecurityIdentifier id = <font color="#008000">new</font> SecurityIdentifier(WellKnownSidType.NetworkServiceSid, <font color="#008000">null</font>);<br />
   NTAccount acct = ( NTAccount )id.Translate(<font color="#008000">typeof</font>(
NTAccount ));<br />
   <font color="#008000">return</font> acct.Value;<br />
}</font>
          </p>
        </blockquote>
        <p>
          <font face="Tahoma">What's quite interesting is after researching the issue and updating
the application to properly resolve the account name, we stumbled upon a </font>
          <a href="http://blogs.msdn.com/jbower/archive/2005/04/01/404829.aspx">
            <font face="Tahoma">blog
post</font>
          </a>
          <font face="Tahoma"> made a couple of years ago that resolved the exact
same issue.</font>
        </p>
        <img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=58a12801-ebbf-477d-910e-aff37ae901bd" />
      </body>
      <title>Resolving Localized System Account Names</title>
      <guid isPermaLink="false">http://blog.devstone.com/aaron/PermaLink,guid,58a12801-ebbf-477d-910e-aff37ae901bd.aspx</guid>
      <link>http://blog.devstone.com/aaron/2008/09/08/ResolvingLocalizedSystemAccountNames.aspx</link>
      <pubDate>Mon, 08 Sep 2008 01:08:42 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Tahoma&gt;When granting database permissions to built-in security accounts
you need to be aware of potentially localized account names.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Just this past week I ran into an issue when attempting to execute
a SQL Server database script on a German server OS.&amp;nbsp; The database script in question
had hard-coded the usage of 'NT AUTHORITY\NETWORK SERVICE' as the account name for
granting database permissions.&amp;nbsp; As it turns out, however, this account doesn't
exist in the German version of Windows.&amp;nbsp; Instead, the account is 'NT-AUTORITÄT\NETZWERKDIENST'.&amp;nbsp;
I found it interesting that the account name is not localized on other non-English
versions of Windows.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Unless I misunderstanding something, the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms684272(VS.85).aspx"&gt;&lt;font face=Tahoma&gt;documentation&lt;/font&gt;&lt;/a&gt;&lt;font face=Tahoma&gt; indicates
that "the name of the account in all locales is NT AUTHORITY\NETWORK SERVICE" so I
was initially confused by this.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;In this particular case my script file is, conveniently, not executed
100% verbatim.&amp;nbsp; Via a little script engine that I wrote, I have the ability to
update variables with runtime values.&amp;nbsp; In this case, rather than use the exact
string 'NT AUTHORITY\NETWORK SERVICE', I replaced it with a variable and determined
the value to use at runtime.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Resolving to the properly localized account name is pretty easy:&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#008000&gt;private static string&lt;/font&gt; getNetworkServiceAcctName()
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; SecurityIdentifier id = &lt;font color=#008000&gt;new&lt;/font&gt; SecurityIdentifier(WellKnownSidType.NetworkServiceSid, &lt;font color=#008000&gt;null&lt;/font&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; NTAccount acct = ( NTAccount )id.Translate(&lt;font color=#008000&gt;typeof&lt;/font&gt;(
NTAccount ));&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;return&lt;/font&gt; acct.Value;&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;font face=Tahoma&gt;What's quite interesting is after researching the issue and updating
the application to properly resolve the account name, we stumbled upon a &lt;/font&gt;&lt;a href="http://blogs.msdn.com/jbower/archive/2005/04/01/404829.aspx"&gt;&lt;font face=Tahoma&gt;blog
post&lt;/font&gt;&lt;/a&gt;&lt;font face=Tahoma&gt; made a couple of years ago that resolved the exact
same issue.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=58a12801-ebbf-477d-910e-aff37ae901bd" /&gt;</description>
      <comments>http://blog.devstone.com/aaron/CommentView,guid,58a12801-ebbf-477d-910e-aff37ae901bd.aspx</comments>
      <category>C#</category>
      <category>Security</category>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.devstone.com/aaron/Trackback.aspx?guid=044c3b22-1b9e-48ce-bcde-d728e524795c</trackback:ping>
      <pingback:server>http://blog.devstone.com/aaron/pingback.aspx</pingback:server>
      <pingback:target>http://blog.devstone.com/aaron/PermaLink,guid,044c3b22-1b9e-48ce-bcde-d728e524795c.aspx</pingback:target>
      <dc:creator>R. Aaron Zupancic (Administrator)</dc:creator>
      <wfw:comment>http://blog.devstone.com/aaron/CommentView,guid,044c3b22-1b9e-48ce-bcde-d728e524795c.aspx</wfw:comment>
      <wfw:commentRss>http://blog.devstone.com/aaron/SyndicationService.asmx/GetEntryCommentsRss?guid=044c3b22-1b9e-48ce-bcde-d728e524795c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Tahoma">I ran across some interesting (read "unexpected") behavior the
other day when writing a .NET WinForms control.  This particular control has
some logic that executes if and only if the host OS has visual themes enabled.</font>
        </p>
        <p>
          <font face="Tahoma">In order to check for the existence of enabled themes, I call a
method called 'IsVisualStylesEnabled()' which is defined as below:</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New">
              <font color="#008000">public static bool </font>IsVisualStylesEnabled()
{<br />
   <font color="#008000">bool</font> isEnabled = <font color="#008000">false</font>;<br />
   <font color="#008000">try</font> {<br />
      OperatingSystem os = Environment.OSVersion;<br />
      <em><font color="#a9a9a9">// decide whether the OS
even supports visual styles</font></em><br />
      <font color="#008000">bool</font> isSupported = ( os.Platform
== PlatformID.Win32NT )<br />
                        
&amp;&amp; ( ( ( os.Version.Major == 5 ) &amp;&amp; ( os.Version.Minor &gt;= 1 ) )<br />
                             
|| ( os.Version.Major &gt; 5 ) );<br />
      <font color="#008000">if</font> ( isSupported ) {<br />
         int majorDllVersion = getComCtlMajorVersion();<br />
         isEnabled = ( majorDllVersion &gt;
5 ) &amp;&amp; IsThemeActive() &amp;&amp; IsAppThemed();<br />
      }<br />
   }<br />
   <font color="#008000">catch</font> ( Exception ) {<br />
      <em><font color="#a9a9a9">// do nothing explicitly</font></em><br />
   }<br />
   <font color="#008000">return</font> isEnabled;<br />
}</font>
          </p>
          <p>
            <br />
            <font face="Courier New">
              <font color="#008000">private static int</font> getComCtlMajorVersion()
{<br />
   DLLVERSIONINFO dllVersion = <font color="#008000">new</font> DLLVERSIONINFO
{ cbSize = Marshal.SizeOf(typeof( DLLVERSIONINFO )) };<br />
   DllGetVersion(<font color="#008000">ref</font> dllVersion);<br />
   <font color="#008000">return</font> dllVersion.dwMajorVersion;<br />
}</font>
          </p>
          <p>
            <font face="Courier New">
            </font> 
</p>
          <p>
            <font face="Courier New">[StructLayout(LayoutKind.Sequential)]<br /><font color="#008000">private struct</font> DLLVERSIONINFO {<br />
   <font color="#008000">public int</font> cbSize;<br />
   <font color="#008000">public int</font> dwMajorVersion;<br />
   <font color="#008000">public int</font> dwMinorVersion;<br />
   <font color="#008000">public int</font> dwBuildNumber;<br />
   <font color="#008000">public int</font> dwPlatformID;<br />
}</font>
          </p>
          <p>
            <font face="Courier New">
            </font> 
</p>
          <p>
            <font face="Courier New">[DllImport(<font color="#a52a2a">"comctl32.dll"</font>, CharSet
= CharSet.Auto)]<br /><font color="#008000">private static extern int</font> DllGetVersion(<font color="#008000">ref</font> DLLVERSIONINFO
version);</font>
          </p>
          <p>
            <br />
            <font face="Courier New">[DllImport(<font color="#a52a2a">"uxtheme.dll"</font>, CharSet
= CharSet.Auto)]<br /><font color="#008000">private static extern bool</font> IsThemeActive();</font>
          </p>
          <p>
            <br />
            <font face="Courier New">[DllImport(<font color="#a52a2a">"uxtheme.dll"</font>, CharSet
= CharSet.Auto)]<br /><font color="#008000">private static extern bool</font> IsAppThemed();</font>
          </p>
        </blockquote>
        <p dir="ltr">
          <font face="Tahoma">This code is pretty standard.</font>
        </p>
        <p dir="ltr">
          <font face="Tahoma">At design-time (i.e., within Visual Studio) my control would render
properly.  The problem, however, was evident when I executed the code - it
would think that visual styles were disabled and degrade gracefully to the non-themed
output.</font>
        </p>
        <p dir="ltr">
          <font face="Tahoma">After a little bit of debugging I discovered that the comctl32.dll
version being loaded at design-time was version 6 (the desired version) whereas at
runtime I was getting version 5.  The first thing I tried was embedding a manifest
into my executable to explicitly load version 6.  No dice - I was still getting
version 5.</font>
        </p>
        <p dir="ltr">
          <font face="Tahoma">Ultimately, however, I did discover the source of the issue: I
was calling the IsVisualStylesEnabled() too early in the load process of my application. 
This was made apparent by placing my control on a form other than the start-up form
- everything worked!</font>
        </p>
        <p dir="ltr">
          <font face="Tahoma">When initialized, my control began setting up UI components such
as brushes, pens, etc and some of this logic was based on whether the themes were
enabled.  Most, if not all, of the setup logic occurs in the InitializeComponent()
method which is called from the .ctor() of the control.</font>
        </p>
        <p dir="ltr">
          <font face="Tahoma">In order to guarantee that the proper version of comctl32.dll
is loaded, you cannot call the GetDllVersion() method until at least the OnHandleCreated()
method of your control.  If you call it earlier, you effectively <em>lock</em> your
application (and consequently the host application if your application is a visual
component) into using version 5 whether or not the manifest dictates otherwise.</font>
        </p>
        <p dir="ltr">
          <font face="Tahoma">For my purposes, I had to wait until the OnPaintBackground() method
to initialize the brushes and other auxiliary objects, but that at least happens after
the OnHandleCreated().</font>
        </p>
        <img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=044c3b22-1b9e-48ce-bcde-d728e524795c" />
      </body>
      <title>Watch How and When You Check For Windows Themes</title>
      <guid isPermaLink="false">http://blog.devstone.com/aaron/PermaLink,guid,044c3b22-1b9e-48ce-bcde-d728e524795c.aspx</guid>
      <link>http://blog.devstone.com/aaron/2008/09/02/WatchHowAndWhenYouCheckForWindowsThemes.aspx</link>
      <pubDate>Tue, 02 Sep 2008 05:50:27 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Tahoma&gt;I ran across some interesting (read "unexpected") behavior the other
day when writing a .NET WinForms control.&amp;nbsp; This particular control has some logic
that executes if and only&amp;nbsp;if the host OS has visual themes enabled.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;In order to check for the existence of enabled themes, I call&amp;nbsp;a
method called 'IsVisualStylesEnabled()' which is defined as below:&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#008000&gt;public static bool &lt;/font&gt;IsVisualStylesEnabled()
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;bool&lt;/font&gt; isEnabled = &lt;font color=#008000&gt;false&lt;/font&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;try&lt;/font&gt; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OperatingSystem os = Environment.OSVersion;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;em&gt;&lt;font color=#a9a9a9&gt;// decide whether the OS even
supports visual styles&lt;/font&gt;&lt;/em&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;bool&lt;/font&gt; isSupported = ( os.Platform
== PlatformID.Win32NT )&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;amp;&amp;amp; ( ( ( os.Version.Major == 5 ) &amp;amp;&amp;amp; ( os.Version.Minor &amp;gt;= 1 ) )&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
|| ( os.Version.Major &amp;gt; 5 ) );&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;if&lt;/font&gt; ( isSupported ) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int majorDllVersion = getComCtlMajorVersion();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isEnabled = ( majorDllVersion &amp;gt;
5 ) &amp;amp;&amp;amp; IsThemeActive() &amp;amp;&amp;amp; IsAppThemed();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;catch&lt;/font&gt; ( Exception ) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;em&gt;&lt;font color=#a9a9a9&gt;// do nothing explicitly&lt;/font&gt;&lt;/em&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;return&lt;/font&gt; isEnabled;&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&lt;font color=#008000&gt;private static int&lt;/font&gt; getComCtlMajorVersion()
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; DLLVERSIONINFO dllVersion = &lt;font color=#008000&gt;new&lt;/font&gt; DLLVERSIONINFO
{ cbSize = Marshal.SizeOf(typeof( DLLVERSIONINFO )) };&lt;br&gt;
&amp;nbsp;&amp;nbsp; DllGetVersion(&lt;font color=#008000&gt;ref&lt;/font&gt; dllVersion);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;return&lt;/font&gt; dllVersion.dwMajorVersion;&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[StructLayout(LayoutKind.Sequential)]&lt;br&gt;
&lt;font color=#008000&gt;private struct&lt;/font&gt; DLLVERSIONINFO {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;public int&lt;/font&gt; cbSize;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;public int&lt;/font&gt; dwMajorVersion;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;public int&lt;/font&gt; dwMinorVersion;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;public int&lt;/font&gt; dwBuildNumber;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;public int&lt;/font&gt; dwPlatformID;&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[DllImport(&lt;font color=#a52a2a&gt;"comctl32.dll"&lt;/font&gt;, CharSet
= CharSet.Auto)]&lt;br&gt;
&lt;font color=#008000&gt;private static extern int&lt;/font&gt; DllGetVersion(&lt;font color=#008000&gt;ref&lt;/font&gt; DLLVERSIONINFO
version);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;[DllImport(&lt;font color=#a52a2a&gt;"uxtheme.dll"&lt;/font&gt;, CharSet
= CharSet.Auto)]&lt;br&gt;
&lt;font color=#008000&gt;private static extern bool&lt;/font&gt; IsThemeActive();&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;[DllImport(&lt;font color=#a52a2a&gt;"uxtheme.dll"&lt;/font&gt;, CharSet
= CharSet.Auto)]&lt;br&gt;
&lt;font color=#008000&gt;private static extern bool&lt;/font&gt; IsAppThemed();&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p dir=ltr&gt;
&lt;font face=Tahoma&gt;This code is pretty standard.&lt;/font&gt;
&lt;/p&gt;
&lt;p dir=ltr&gt;
&lt;font face=Tahoma&gt;At design-time (i.e., within Visual Studio) my control would render
properly.&amp;nbsp; The problem, however, was evident when I executed the code -&amp;nbsp;it
would think that visual styles were disabled and degrade gracefully to the non-themed
output.&lt;/font&gt;
&lt;/p&gt;
&lt;p dir=ltr&gt;
&lt;font face=Tahoma&gt;After a little bit of debugging I discovered that the comctl32.dll
version being loaded at design-time was version 6 (the desired version) whereas at
runtime I was getting version 5.&amp;nbsp; The first thing I tried was embedding a manifest
into my executable to explicitly load version 6.&amp;nbsp; No dice - I was still getting
version 5.&lt;/font&gt;
&lt;/p&gt;
&lt;p dir=ltr&gt;
&lt;font face=Tahoma&gt;Ultimately, however, I did discover the source of the issue: I was
calling the IsVisualStylesEnabled() too early in the load process of my application.&amp;nbsp;
This was made apparent by placing my control on a form other than the start-up form
- everything worked!&lt;/font&gt;
&lt;/p&gt;
&lt;p dir=ltr&gt;
&lt;font face=Tahoma&gt;When initialized, my control began setting up UI components such
as brushes, pens, etc and some of this logic was based on whether the themes were
enabled.&amp;nbsp; Most, if not all, of the setup logic occurs in the InitializeComponent()
method which is called from the .ctor() of the control.&lt;/font&gt;
&lt;/p&gt;
&lt;p dir=ltr&gt;
&lt;font face=Tahoma&gt;In order to guarantee that the proper version of comctl32.dll is
loaded, you cannot call the GetDllVersion() method until at least the OnHandleCreated()
method of your control.&amp;nbsp; If you call it earlier, you effectively &lt;em&gt;lock&lt;/em&gt; your
application (and consequently the host application if your application is a visual
component) into using version 5 whether or not the manifest dictates otherwise.&lt;/font&gt;
&lt;/p&gt;
&lt;p dir=ltr&gt;
&lt;font face=Tahoma&gt;For my purposes, I had to wait until the OnPaintBackground() method
to initialize the brushes and other auxiliary objects, but that at least happens after
the OnHandleCreated().&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=044c3b22-1b9e-48ce-bcde-d728e524795c" /&gt;</description>
      <comments>http://blog.devstone.com/aaron/CommentView,guid,044c3b22-1b9e-48ce-bcde-d728e524795c.aspx</comments>
      <category>C#</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://blog.devstone.com/aaron/Trackback.aspx?guid=941944d3-44ad-423e-8ec5-08519fa7b2e8</trackback:ping>
      <pingback:server>http://blog.devstone.com/aaron/pingback.aspx</pingback:server>
      <pingback:target>http://blog.devstone.com/aaron/PermaLink,guid,941944d3-44ad-423e-8ec5-08519fa7b2e8.aspx</pingback:target>
      <dc:creator>R. Aaron Zupancic (Administrator)</dc:creator>
      <wfw:comment>http://blog.devstone.com/aaron/CommentView,guid,941944d3-44ad-423e-8ec5-08519fa7b2e8.aspx</wfw:comment>
      <wfw:commentRss>http://blog.devstone.com/aaron/SyndicationService.asmx/GetEntryCommentsRss?guid=941944d3-44ad-423e-8ec5-08519fa7b2e8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Tahoma">I've been putting together a nice little WinForms Wizard control
recently that had a few twist and turns to its development.  In particular, I
wanted to make the design-time experience a good one for the end user.  I wanted
to support design-time navigation of the wizard pages, drag/drop of control to each
child page, reordering of the pages, and much more.  In fact, as soon as
I tidy up the code a bit and flesh it out a bit, I'll be posting the component here
on my blog for general use.  But enough of that...</font>
        </p>
        <p>
          <font face="Tahoma">The wizard control has a rich design-time experience. 
I owe some of the thanks for the functionality to control's ControlDesigner and DesignerActionList. 
Among many other things, these classes provides a mechanism for a developer to
associate custom verbs and actions with the control at design-time.  These actions
are made available to the developer through the smart-tag menu when the control is
selected on its design surface.</font>
        </p>
        <p>
          <font face="Tahoma">It is through these custom actions that I've given the programmer
the ability to manage pages on the wizard.  Internally, these pages are represented
not only as controls on the wizard itself, but also in a collection of pages that
the wizard uses to properly navigate the sequence of pages.  It is this collection
that gets persisted (serialized) in the form's InitializeComponent() method when saving
changes made to the wizard at design-time.</font>
        </p>
        <p>
          <font face="Tahoma">I quickly discovered, however, that all wasn't green grass and
blue skies.  I wanted to support reordering the pages through the design-time
smart-tags.  While I was able to easily reorder the elements in the page collection
and even update the control's display at design-time to reflect the changes, the Visual
Studio environment didn't register the change.  Unless I then went ahead and
further edited a property through Visual Studio itself (effectively to <em>cause a
change</em> in the environment), the reordering of the pages never persisted. 
So I had to figure out how to notify Visual Studio that a change had been made.</font>
        </p>
        <p>
          <font face="Tahoma">Fortunately, this isn't difficult, but it's not very intuitive
at the same time.</font>
        </p>
        <p>
          <font face="Tahoma">The ControlDesigner's GetService() method provides access to the
services available to the control at design time.  Among these is the IComponentChangeService. 
It is through this service that you can notify the designer of a change.  To
do so, you need a property to update.  I, for one, don't really like the idea
of utilizing an existing property for this purpose (though it could be done).</font>
        </p>
        <p>
          <font face="Tahoma">What I did in my solution was create a design-time-only property
in the ControlDesigner.  Then, when a change is made that requires the change
notification I call a method which 'updates' the property.  The property doesn't
really get updated, but at least the code is clearer.</font>
        </p>
        <p>
          <font face="Tahoma">In the control designer:</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New">
              <font color="#008000">protected override void</font> PreFilterProperties(IDictionary
properties) {<br />
   <font color="#008000">base</font>.PreFilterProperties(properties);<br /><br />
   Attribute[] attribs = {<br />
                            <font color="#008000">new</font> BrowsableAttribute(<font color="#008000">false</font>),<br />
                            <font color="#008000">new</font> DesignOnlyAttribute(<font color="#008000">true</font>)<br />
                        
};<br />
   PropertyDescriptor prop = TypeDescriptor.CreateProperty(GetType(), <font color="#a52a2a">"DesignTimeChange"</font>, <font color="#008000">typeof</font>(<font color="#008000">string</font>),
attribs);<br />
   properties.Add(<font color="#a52a2a">"DesignTimeChange"</font>, prop);<br />
}<br /><br /><font color="#a9a9a9">/// &lt;summary&gt;<br />
/// Property created exclusively for the purpose of notifying the<br />
/// designer of changes to properties made through the designer<br />
/// (such as reordering the pages).<br />
/// &lt;/summary&gt;<br /></font><font color="#008000">public string</font> DesignTimeChange { <font color="#008000">get</font>; <font color="#008000">set</font>;
}</font>
          </p>
        </blockquote>
        <p>
          <font face="Tahoma">Then, also in the Designer, a method that causes a change to be
acknowledged:</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New">
              <font color="#008000">private void</font> notifyOfChange()
{<br />
   PropertyDescriptor prop = TypeDescriptor.GetProperties(<font color="#008000">this</font>)[<font color="#a52a2a">"DesignTimeChange"</font>];<br />
   getComponentChangeService().OnComponentChanged(<font color="#008000">this</font>,
prop, <font color="#008000">null</font>, <font color="#008000">null</font>);<br />
}</font>
          </p>
        </blockquote>
        <p>
          <font face="Tahoma">That's all there is to it.  When an action occurs in the
designer that would not otherwise register a change in the environment, I simply have
it call the notifyOfChange() method.</font>
        </p>
        <p>
          <font face="Tahoma">A little more work would be involved if the change were coming
from outside the designer.  For instance, if the change was made within the collection
or within the control, you'd first have to evaluate whether it's running in design
mode, and then retrieve a reference to the ControlDesigner, invoking the method (it'd
probably have to be made <strong>internal</strong> (and it's name appropriately Pascal-cased)
rather than <strong>private</strong>).</font>
        </p>
        <p>
          <font face="Tahoma">Maybe something like this (NOTE: untested, but seemingly approximately
accurate):</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New">
              <font color="#008000">if</font> ( DesignMode ) {<br />
   IDesignerHost host = ( IDesignerHost )Site.Container;<br />
   ControlDesigner designer = ( ControlDesigner )host.GetDesigner(<font color="#008000">this</font>);<br />
   designer.NotifyOfChange();<br />
}</font>
          </p>
        </blockquote>
        <img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=941944d3-44ad-423e-8ec5-08519fa7b2e8" />
      </body>
      <title>Registering Design-Time Changes Programmatically in Custom .NET Controls</title>
      <guid isPermaLink="false">http://blog.devstone.com/aaron/PermaLink,guid,941944d3-44ad-423e-8ec5-08519fa7b2e8.aspx</guid>
      <link>http://blog.devstone.com/aaron/2008/08/29/RegisteringDesignTimeChangesProgrammaticallyInCustomNETControls.aspx</link>
      <pubDate>Fri, 29 Aug 2008 01:47:20 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Tahoma&gt;I've been putting together a nice little WinForms Wizard control
recently that had a few twist and turns to its development.&amp;nbsp; In particular, I
wanted to make the design-time experience a good one for the end user.&amp;nbsp; I wanted
to support design-time navigation of the wizard pages, drag/drop of control to each
child page, reordering of the pages,&amp;nbsp;and much more.&amp;nbsp; In fact, as soon as
I tidy up the code a bit and flesh it out a bit, I'll be posting the component here
on my blog for general use.&amp;nbsp; But enough of that...&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;The wizard&amp;nbsp;control has a rich design-time experience.&amp;nbsp;
I owe some of the thanks for the functionality to control's ControlDesigner and DesignerActionList.&amp;nbsp;
Among many other things, these classes&amp;nbsp;provides a mechanism for a developer to
associate custom verbs and actions with the control at design-time.&amp;nbsp; These actions
are made available to the developer through the smart-tag menu when the control is
selected on its design surface.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;It is through these custom actions that I've given the programmer
the ability to manage pages on the wizard.&amp;nbsp; Internally, these pages are represented
not only as controls on the wizard itself, but also in a collection of pages that
the wizard uses to properly navigate the sequence of pages.&amp;nbsp; It is this collection
that gets persisted (serialized) in the form's InitializeComponent() method when saving
changes made to the wizard at design-time.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;I quickly discovered, however, that all wasn't green grass and blue
skies.&amp;nbsp; I wanted to support reordering the pages through the design-time smart-tags.&amp;nbsp;
While I was able to easily reorder the elements in the page collection and even update
the control's display at design-time to reflect the changes, the Visual Studio environment
didn't register the change.&amp;nbsp; Unless I then went ahead and further edited a property
through Visual Studio itself (effectively to &lt;em&gt;cause a change&lt;/em&gt; in the environment),
the reordering of the pages never persisted.&amp;nbsp; So I had to figure out how to notify
Visual Studio that a&amp;nbsp;change had been made.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Fortunately, this isn't difficult, but it's not very intuitive at
the same time.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;The ControlDesigner's GetService() method provides access to the
services available to the control at design time.&amp;nbsp; Among these is the IComponentChangeService.&amp;nbsp;
It is through this service that you can notify the designer of a change.&amp;nbsp; To
do so, you need a property to update.&amp;nbsp; I, for one, don't really like the idea
of utilizing an existing property for this purpose (though it could be done).&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;What I did in my solution was create a design-time-only property
in the ControlDesigner.&amp;nbsp; Then, when a change is made that requires the change
notification I call a method which 'updates' the property.&amp;nbsp; The property doesn't
really get updated, but at least the code is clearer.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;In the control designer:&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#008000&gt;protected override void&lt;/font&gt; PreFilterProperties(IDictionary
properties) {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;base&lt;/font&gt;.PreFilterProperties(properties);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; Attribute[] attribs = {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;new&lt;/font&gt; BrowsableAttribute(&lt;font color=#008000&gt;false&lt;/font&gt;),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;new&lt;/font&gt; DesignOnlyAttribute(&lt;font color=#008000&gt;true&lt;/font&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
};&lt;br&gt;
&amp;nbsp;&amp;nbsp; PropertyDescriptor prop = TypeDescriptor.CreateProperty(GetType(), &lt;font color=#a52a2a&gt;"DesignTimeChange"&lt;/font&gt;, &lt;font color=#008000&gt;typeof&lt;/font&gt;(&lt;font color=#008000&gt;string&lt;/font&gt;),
attribs);&lt;br&gt;
&amp;nbsp;&amp;nbsp; properties.Add(&lt;font color=#a52a2a&gt;"DesignTimeChange"&lt;/font&gt;, prop);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;font color=#a9a9a9&gt;/// &amp;lt;summary&amp;gt;&lt;br&gt;
/// Property created exclusively for the purpose of notifying the&lt;br&gt;
/// designer of changes to properties made through the designer&lt;br&gt;
/// (such as reordering the pages).&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/font&gt;&lt;font color=#008000&gt;public string&lt;/font&gt; DesignTimeChange { &lt;font color=#008000&gt;get&lt;/font&gt;; &lt;font color=#008000&gt;set&lt;/font&gt;;
}&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;font face=Tahoma&gt;Then, also in the Designer, a method that causes a change to be
acknowledged:&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#008000&gt;private void&lt;/font&gt; notifyOfChange()
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; PropertyDescriptor prop = TypeDescriptor.GetProperties(&lt;font color=#008000&gt;this&lt;/font&gt;)[&lt;font color=#a52a2a&gt;"DesignTimeChange"&lt;/font&gt;];&lt;br&gt;
&amp;nbsp;&amp;nbsp; getComponentChangeService().OnComponentChanged(&lt;font color=#008000&gt;this&lt;/font&gt;,
prop, &lt;font color=#008000&gt;null&lt;/font&gt;, &lt;font color=#008000&gt;null&lt;/font&gt;);&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;font face=Tahoma&gt;That's all there is to it.&amp;nbsp; When an action occurs in the designer
that would not otherwise register a change in the environment, I simply have it call
the notifyOfChange() method.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;A little more work would be involved if the change were coming from
outside the designer.&amp;nbsp; For instance, if the change was made within the collection
or within the control, you'd first have to evaluate whether it's running in design
mode, and then retrieve a reference to the ControlDesigner, invoking the method (it'd
probably have to be made &lt;strong&gt;internal&lt;/strong&gt; (and it's name appropriately Pascal-cased)
rather than &lt;strong&gt;private&lt;/strong&gt;).&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Maybe something like this (NOTE: untested, but seemingly approximately
accurate):&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#008000&gt;if&lt;/font&gt; ( DesignMode ) {&lt;br&gt;
&amp;nbsp;&amp;nbsp; IDesignerHost host = ( IDesignerHost )Site.Container;&lt;br&gt;
&amp;nbsp;&amp;nbsp; ControlDesigner designer = ( ControlDesigner )host.GetDesigner(&lt;font color=#008000&gt;this&lt;/font&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; designer.NotifyOfChange();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt;&lt;img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=941944d3-44ad-423e-8ec5-08519fa7b2e8" /&gt;</description>
      <comments>http://blog.devstone.com/aaron/CommentView,guid,941944d3-44ad-423e-8ec5-08519fa7b2e8.aspx</comments>
      <category>C#</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://blog.devstone.com/aaron/Trackback.aspx?guid=f3c84b9c-6b85-45ab-8158-fa8e3f0d0819</trackback:ping>
      <pingback:server>http://blog.devstone.com/aaron/pingback.aspx</pingback:server>
      <pingback:target>http://blog.devstone.com/aaron/PermaLink,guid,f3c84b9c-6b85-45ab-8158-fa8e3f0d0819.aspx</pingback:target>
      <dc:creator>R. Aaron Zupancic (Administrator)</dc:creator>
      <wfw:comment>http://blog.devstone.com/aaron/CommentView,guid,f3c84b9c-6b85-45ab-8158-fa8e3f0d0819.aspx</wfw:comment>
      <wfw:commentRss>http://blog.devstone.com/aaron/SyndicationService.asmx/GetEntryCommentsRss?guid=f3c84b9c-6b85-45ab-8158-fa8e3f0d0819</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Tahoma">Earlier this year I <a href="http://blog.devstone.com/aaron/2008/02/07/UsingSGENexeFromWithinVisualStudio.aspx">posted
an article</a> demonstrating how to use the SGEN.exe utility to generate a serialization
assembly.  The article identified how to create a custom MSBuild task by editing
the project file (e.g., csproj).  I've recently come to discover that the MSBuild
task will fail when automating a build of the project through TFS Build. 
The error presents itself as follows:</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Tahoma" color="#ff0000">SGEN(0,0): error : File or assembly name 'C:....\bin\CustomLibrary.dll',
or one of its dependencies, was not found.</font>
          </p>
        </blockquote>
        <p>
          <font face="Tahoma">Ultimately, the root of the problem goes back to the SGEN
MSBuild task's usage of the $(OutputPath) variable.  Even in TFS Build this is
pointing to same location that Visual Studio would point to.  TFS, however, will
override the output locations of the compiled applications, but this variable doesn't
get updated.  As stated in the </font>
          <a href="http://msdn.microsoft.com/en-us/library/bb629394.aspx">
            <font face="Tahoma">MSDN
documentation</font>
          </a>
          <font face="Tahoma">, "OutputPath has been deprecated and
OutDir should be used instead whenever possible.".  I was happy to discover that
by simply replacing the $(OutputPath) with $(OutDir) in the MSBuild task was all I
needed to do; the task will execute properly both from my development machine as well
as the build server.</font>
        </p>
        <p>
          <font face="Tahoma">My updated task resembles the following:</font>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New">&lt;<font color="#a52a2a">Target</font><font color="#ff0000">Name</font>="<font color="#0000ff">GenSerializationAssembly</font>"<br />
        <font color="#ff0000">DependsOnTargets</font>="<font color="#0000ff">AssignTargetPaths;Compile;ResolveKeySource</font>"<br />
        <font color="#ff0000">Inputs</font>="<font color="#0000ff">$(MSBuildAllProjects);@(IntermediateAssembly)</font>"<br />
        <font color="#ff0000">Outputs</font>="<font color="#0000ff">$(OutDir)$(_<span class="searchword">SGen</span>DllName)</font>"&gt;<br />
  &lt;<font color="#a52a2a"><span class="searchword">SGen</span></font><font color="#ff0000">BuildAssemblyName</font>="<font color="#0000ff">$(TargetFileName)</font>"<br />
        <font color="#ff0000">BuildAssemblyPath</font>="<font color="#0000ff">$(OutDir)</font>"<br />
        <font color="#ff0000">References</font>="<font color="#0000ff">@(ReferencePath)</font>"<br />
        <font color="#ff0000">ShouldGenerateSerializer</font>="<font color="#0000ff">true</font>"<br />
        <font color="#ff0000">UseProxyTypes</font>="<font color="#0000ff">false</font>"<br />
        <font color="#ff0000">KeyContainer</font>="<font color="#0000ff">$(KeyContainerName)</font>"<br />
        <font color="#ff0000">KeyFile</font>="<font color="#0000ff">$(KeyOriginatorFile)</font>"<br />
        <font color="#ff0000">DelaySign</font>="<font color="#0000ff">$(DelaySign)</font>"<br />
        <font color="#ff0000">ToolPath</font>="<font color="#0000ff">$(<span class="searchword">SGen</span>ToolPath)</font>"&gt;<br />
    &lt;<font color="#a52a2a">Output</font><font color="#ff0000">TaskParameter</font>="<font color="#0000ff">SerializationAssembly</font>" <font color="#ff0000">ItemName</font>="<font color="#0000ff">SerializationAssembly</font>"
/&gt; 
<br />
  &lt;/<font color="#a52a2a"><span class="searchword">SGen</span></font>&gt;<br />
&lt;/<font color="#a52a2a">Target</font>&gt;<br />
&lt;<font color="#a52a2a">Target</font><font color="#ff0000">Name</font>="<font color="#0000ff">AfterBuild</font>" <font color="#ff0000">DependsOnTargets</font>="<font color="#0000ff">GenSerializationAssembly</font>"
/&gt;</font>
          </p>
        </blockquote>
        <img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=f3c84b9c-6b85-45ab-8158-fa8e3f0d0819" />
      </body>
      <title>Using an SGEN.exe MSBuild task in TFS Build</title>
      <guid isPermaLink="false">http://blog.devstone.com/aaron/PermaLink,guid,f3c84b9c-6b85-45ab-8158-fa8e3f0d0819.aspx</guid>
      <link>http://blog.devstone.com/aaron/2008/08/26/UsingAnSGENexeMSBuildTaskInTFSBuild.aspx</link>
      <pubDate>Tue, 26 Aug 2008 19:06:57 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Tahoma&gt;Earlier this year I &lt;a href="http://blog.devstone.com/aaron/2008/02/07/UsingSGENexeFromWithinVisualStudio.aspx"&gt;posted
an article&lt;/a&gt; demonstrating how to use the SGEN.exe utility to generate a serialization
assembly.&amp;nbsp; The article identified how to create a custom MSBuild task by editing
the project file (e.g., csproj).&amp;nbsp; I've recently come to discover that the MSBuild
task will fail when automating a build of the project&amp;nbsp;through TFS Build.&amp;nbsp;
The error presents itself as follows:&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face=Tahoma color=#ff0000&gt;SGEN(0,0): error : File or assembly name 'C:....\bin\CustomLibrary.dll',
or one of its dependencies, was not found.&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;font face=Tahoma&gt;Ultimately, the root of the problem goes back to the&amp;nbsp;SGEN MSBuild
task's usage of the $(OutputPath) variable.&amp;nbsp; Even in TFS Build this is pointing
to same location that Visual Studio would point to.&amp;nbsp; TFS, however, will override
the output locations of the compiled applications, but this variable doesn't get updated.&amp;nbsp;
As stated in the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb629394.aspx"&gt;&lt;font face=Tahoma&gt;MSDN
documentation&lt;/font&gt;&lt;/a&gt;&lt;font face=Tahoma&gt;, "OutputPath has been deprecated and OutDir
should be used instead whenever possible.".&amp;nbsp; I was happy to discover that by
simply replacing the $(OutputPath) with $(OutDir) in the MSBuild task was all I needed
to do; the task will execute properly both from my development machine as well as
the build server.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;My updated task resembles the following:&lt;/font&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;&lt;font color=#a52a2a&gt;Target&lt;/font&gt; &lt;font color=#ff0000&gt;Name&lt;/font&gt;="&lt;font color=#0000ff&gt;GenSerializationAssembly&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;DependsOnTargets&lt;/font&gt;="&lt;font color=#0000ff&gt;AssignTargetPaths;Compile;ResolveKeySource&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;Inputs&lt;/font&gt;="&lt;font color=#0000ff&gt;$(MSBuildAllProjects);@(IntermediateAssembly)&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;Outputs&lt;/font&gt;="&lt;font color=#0000ff&gt;$(OutDir)$(_&lt;span class=searchword&gt;SGen&lt;/span&gt;DllName)&lt;/font&gt;"&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;&lt;font color=#a52a2a&gt;&lt;span class=searchword&gt;SGen&lt;/span&gt;&lt;/font&gt; &lt;font color=#ff0000&gt;BuildAssemblyName&lt;/font&gt;="&lt;font color=#0000ff&gt;$(TargetFileName)&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;BuildAssemblyPath&lt;/font&gt;="&lt;font color=#0000ff&gt;$(OutDir)&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;References&lt;/font&gt;="&lt;font color=#0000ff&gt;@(ReferencePath)&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;ShouldGenerateSerializer&lt;/font&gt;="&lt;font color=#0000ff&gt;true&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;UseProxyTypes&lt;/font&gt;="&lt;font color=#0000ff&gt;false&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;KeyContainer&lt;/font&gt;="&lt;font color=#0000ff&gt;$(KeyContainerName)&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;KeyFile&lt;/font&gt;="&lt;font color=#0000ff&gt;$(KeyOriginatorFile)&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;DelaySign&lt;/font&gt;="&lt;font color=#0000ff&gt;$(DelaySign)&lt;/font&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#ff0000&gt;ToolPath&lt;/font&gt;="&lt;font color=#0000ff&gt;$(&lt;span class=searchword&gt;SGen&lt;/span&gt;ToolPath)&lt;/font&gt;"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;font color=#a52a2a&gt;Output&lt;/font&gt; &lt;font color=#ff0000&gt;TaskParameter&lt;/font&gt;="&lt;font color=#0000ff&gt;SerializationAssembly&lt;/font&gt;" &lt;font color=#ff0000&gt;ItemName&lt;/font&gt;="&lt;font color=#0000ff&gt;SerializationAssembly&lt;/font&gt;"
/&amp;gt; 
&lt;br&gt;
&amp;nbsp; &amp;lt;/&lt;font color=#a52a2a&gt;&lt;span class=searchword&gt;SGen&lt;/span&gt;&lt;/font&gt;&amp;gt;&lt;br&gt;
&amp;lt;/&lt;font color=#a52a2a&gt;Target&lt;/font&gt;&amp;gt;&lt;br&gt;
&amp;lt;&lt;font color=#a52a2a&gt;Target&lt;/font&gt; &lt;font color=#ff0000&gt;Name&lt;/font&gt;="&lt;font color=#0000ff&gt;AfterBuild&lt;/font&gt;" &lt;font color=#ff0000&gt;DependsOnTargets&lt;/font&gt;="&lt;font color=#0000ff&gt;GenSerializationAssembly&lt;/font&gt;"
/&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt;&lt;img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=f3c84b9c-6b85-45ab-8158-fa8e3f0d0819" /&gt;</description>
      <comments>http://blog.devstone.com/aaron/CommentView,guid,f3c84b9c-6b85-45ab-8158-fa8e3f0d0819.aspx</comments>
      <category>Team Foundation Server</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://blog.devstone.com/aaron/Trackback.aspx?guid=3de56574-c826-4e92-a777-dd0232633cf2</trackback:ping>
      <pingback:server>http://blog.devstone.com/aaron/pingback.aspx</pingback:server>
      <pingback:target>http://blog.devstone.com/aaron/PermaLink,guid,3de56574-c826-4e92-a777-dd0232633cf2.aspx</pingback:target>
      <dc:creator>R. Aaron Zupancic (Administrator)</dc:creator>
      <wfw:comment>http://blog.devstone.com/aaron/CommentView,guid,3de56574-c826-4e92-a777-dd0232633cf2.aspx</wfw:comment>
      <wfw:commentRss>http://blog.devstone.com/aaron/SyndicationService.asmx/GetEntryCommentsRss?guid=3de56574-c826-4e92-a777-dd0232633cf2</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Tahoma">
            <img style="FLOAT: left" src="http://blog.devstone.com/aaron/content/binary/TeamExplorer01.gif" border="0" />I've
had an issue on two computers (my primary development machine and a virtual pc dev
box) which I was <em>finally</em> able to solve today after many hours of frustrated
searching and experimenting.  Interestingly, this issue only affected my two
machines, but not those of a co-worker.  What was more peculiar was that I have
higher privileges in TFS.  The issue revolved around getting the Team Foundation
Server Team Explorer 2008 to recognize our automated builds.</font>
        </p>
        <p>
          <font face="Tahoma">Within Visual Studio 2008's Team Explorer pane I am able to browse
all work items, documents, reports, etc, but not builds.  In fact, the node shows
up with a red 'X' icon and is mislabeled 'Build' rather than the correct 'Builds'.</font>
        </p>
        <p>
          <font face="Tahoma">I attempted to fix it by uninstalling / reinstalling the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=00803636-1d16-4df1-8a3d-ef1ad4f4bbab&amp;displaylang=en">TFS
2008 Power Tools (July Release)</a>, repairing my VS2008 installation, disabling my
firewall, disabling my antivirus.  I tried digging into various configuration
files and renaming / deleting my cache folder to no avail.</font>
        </p>
        <p>
          <font face="Tahoma">Ultimately, to fix the issue I had to resort to resetting my Visual
Studio settings to their factory settings.  To do this, I did the following:</font>
        </p>
        <ol>
          <li>
            <font face="Tahoma">Renamed/Deleted by TFS Cache folder.  On my Vista machine
it's found in (C:\Users\[USERNAME]\AppData\Local\Microsoft\Team Foundation\2.0).</font>
          </li>
          <li>
            <font face="Tahoma">Reset Visual Studio 2008 settings by typing <font face="Courier New"><strong>devenv
/resetuserdata</strong></font> from the command line.</font>
          </li>
        </ol>
        <img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=3de56574-c826-4e92-a777-dd0232633cf2" />
      </body>
      <title>Repairing TFS's Team Explorer Build Node in Visual Studio 2008</title>
      <guid isPermaLink="false">http://blog.devstone.com/aaron/PermaLink,guid,3de56574-c826-4e92-a777-dd0232633cf2.aspx</guid>
      <link>http://blog.devstone.com/aaron/2008/08/18/RepairingTFSsTeamExplorerBuildNodeInVisualStudio2008.aspx</link>
      <pubDate>Mon, 18 Aug 2008 05:34:53 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Tahoma&gt;&lt;img style="FLOAT: left" src="http://blog.devstone.com/aaron/content/binary/TeamExplorer01.gif" border=0&gt;I've
had an issue on two computers (my primary development machine and a virtual pc dev
box) which I was &lt;em&gt;finally&lt;/em&gt; able to solve today after many hours of frustrated
searching and experimenting.&amp;nbsp; Interestingly, this issue only affected my two
machines, but not those of a co-worker.&amp;nbsp; What was more peculiar was that I have
higher privileges in TFS.&amp;nbsp; The issue revolved around getting the Team Foundation
Server Team Explorer 2008 to recognize our automated builds.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Within Visual Studio 2008's Team Explorer pane I am able to browse
all work items, documents, reports, etc, but not builds.&amp;nbsp; In fact, the node shows
up with a red 'X' icon and is mislabeled 'Build' rather than the correct 'Builds'.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;I attempted to fix it by uninstalling / reinstalling the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=00803636-1d16-4df1-8a3d-ef1ad4f4bbab&amp;amp;displaylang=en"&gt;TFS
2008 Power Tools (July Release)&lt;/a&gt;, repairing my VS2008 installation, disabling my
firewall, disabling my antivirus.&amp;nbsp; I tried digging into various configuration
files and renaming / deleting my cache folder to no avail.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Ultimately, to fix the issue I had to resort to resetting my Visual
Studio settings to their factory settings.&amp;nbsp; To&amp;nbsp;do this, I did the following:&lt;/font&gt;
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;font face=Tahoma&gt;Renamed/Deleted by TFS Cache folder.&amp;nbsp; On my Vista machine it's
found in (C:\Users\[USERNAME]\AppData\Local\Microsoft\Team Foundation\2.0).&lt;/font&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;font face=Tahoma&gt;Reset Visual Studio 2008 settings by typing &lt;font face="Courier New"&gt;&lt;strong&gt;devenv
/resetuserdata&lt;/strong&gt;&lt;/font&gt; from the command line.&lt;/font&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=3de56574-c826-4e92-a777-dd0232633cf2" /&gt;</description>
      <comments>http://blog.devstone.com/aaron/CommentView,guid,3de56574-c826-4e92-a777-dd0232633cf2.aspx</comments>
      <category>Team Foundation Server</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://blog.devstone.com/aaron/Trackback.aspx?guid=7fb0b94f-7b10-407d-8772-852e3edc2469</trackback:ping>
      <pingback:server>http://blog.devstone.com/aaron/pingback.aspx</pingback:server>
      <pingback:target>http://blog.devstone.com/aaron/PermaLink,guid,7fb0b94f-7b10-407d-8772-852e3edc2469.aspx</pingback:target>
      <dc:creator>R. Aaron Zupancic (Administrator)</dc:creator>
      <wfw:comment>http://blog.devstone.com/aaron/CommentView,guid,7fb0b94f-7b10-407d-8772-852e3edc2469.aspx</wfw:comment>
      <wfw:commentRss>http://blog.devstone.com/aaron/SyndicationService.asmx/GetEntryCommentsRss?guid=7fb0b94f-7b10-407d-8772-852e3edc2469</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Tahoma">I upgraded my Visual Studio 2008 installation the other day to </font>
          <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;displaylang=en">
            <font face="Tahoma">SP1</font>
          </a>
          <font face="Tahoma"> and
everything went beautifully.  One of the issues that Microsoft fixed centered
around the naming of embedded binary resource files.</font>
        </p>
        <p>
          <font face="Tahoma">Traditionally, binary resource files have an extension of
.resources.  However, when VS2008 was introduced, </font>
          <a href="http://blog.devstone.com/aaron/2008/02/20/LosingResourcesInVS2008CompiledAssemblies.aspx">
            <font face="Tahoma">it came
with a bug that forced you to tack on a second extension</font>
          </a>
          <font face="Tahoma">: fileName.resources.resources.</font>
        </p>
        <p>
          <font face="Tahoma">Apparently, this is now fixed, but I did have to go back and rename
my files accordingly.</font>
        </p>
        <img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=7fb0b94f-7b10-407d-8772-852e3edc2469" />
      </body>
      <title>VS 2008 SP1 Fixes Missing .resources Issue</title>
      <guid isPermaLink="false">http://blog.devstone.com/aaron/PermaLink,guid,7fb0b94f-7b10-407d-8772-852e3edc2469.aspx</guid>
      <link>http://blog.devstone.com/aaron/2008/08/14/VS2008SP1FixesMissingResourcesIssue.aspx</link>
      <pubDate>Thu, 14 Aug 2008 22:27:22 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Tahoma&gt;I upgraded my Visual Studio 2008 installation the other day to &lt;/font&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;amp;displaylang=en"&gt;&lt;font face=Tahoma&gt;SP1&lt;/font&gt;&lt;/a&gt;&lt;font face=Tahoma&gt;&amp;nbsp;and
everything went beautifully.&amp;nbsp; One of the issues that Microsoft fixed centered
around the naming of embedded binary resource files.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Traditionally,&amp;nbsp;binary resource files have an extension of .resources.&amp;nbsp;
However, when VS2008 was introduced, &lt;/font&gt;&lt;a href="http://blog.devstone.com/aaron/2008/02/20/LosingResourcesInVS2008CompiledAssemblies.aspx"&gt;&lt;font face=Tahoma&gt;it&amp;nbsp;came
with a bug that&amp;nbsp;forced you to&amp;nbsp;tack on a second extension&lt;/font&gt;&lt;/a&gt;&lt;font face=Tahoma&gt;:&amp;nbsp;fileName.resources.resources.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Tahoma&gt;Apparently, this is now fixed, but I did have to go back and rename
my files accordingly.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.devstone.com/aaron/aggbug.ashx?id=7fb0b94f-7b10-407d-8772-852e3edc2469" /&gt;</description>
      <comments>http://blog.devstone.com/aaron/CommentView,guid,7fb0b94f-7b10-407d-8772-852e3edc2469.aspx</comments>
      <category>Visual Studio</category>
    </item>
  </channel>
</rss>