﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" 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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
  <channel>
    <title>Random .Net Stuff</title>
    <description>It's fairly random, maybe useful, maybe not</description>
    <link>http://www.rodenbaugh.net/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.Net Syndication Generator 1.0.0.0 (http://dotnetblogengine.net/)</generator>
    <language>en-GB</language>
    <blogChannel:blogRoll>http://www.rodenbaugh.net/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://www.dotnetblogengine.net/syndication.axd</blogChannel:blink>
    <dc:creator>Bill Rodenbaugh</dc:creator>
    <dc:title>Random .Net Stuff</dc:title>
    <item>
      <title>ADO .NET Entity Framework Vote of No Confidence</title>
      <description>&lt;p&gt;
Read it. Sign it.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/"&gt;http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/ 
&lt;/a&gt;
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/ADO-NET-Entity-Framework-Vote-of-No-Confidence.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/ADO-NET-Entity-Framework-Vote-of-No-Confidence.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=f08cb614-90ca-4e5f-9f50-3f476aeb12a6</guid>
      <pubDate>Mon, 23 Jun 2008 14:26:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=f08cb614-90ca-4e5f-9f50-3f476aeb12a6</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=f08cb614-90ca-4e5f-9f50-3f476aeb12a6</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/ADO-NET-Entity-Framework-Vote-of-No-Confidence.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=f08cb614-90ca-4e5f-9f50-3f476aeb12a6</wfw:commentRss>
    </item>
    <item>
      <title>Defensive Event Publishing</title>
      <description>&lt;p&gt;
How does one go about publishing event in a safe way so that one could minimize the chance of exceptions?&amp;nbsp; Let&amp;#39;s say you have a class such as this: &lt;br /&gt;
&lt;br /&gt;
public class MyClass &lt;br /&gt;
{ &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public event EventHandler MyEvent; &lt;br /&gt;
}
&lt;/p&gt;
&lt;p&gt;
The first thing that comes to mind when you want to publish MyEvent would be to just invoke the delegate. 
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;
MyEvent(&lt;span class="kwrd"&gt;this&lt;/span&gt;, EventArgs.Empty);
&lt;/pre&gt;
&lt;p&gt;
The first issue that you would find is that if no one has subscribed to the event then just invoking the delegate would cause a null reference exception.&amp;nbsp; So we need to check for null. 
&lt;/p&gt;
&lt;p&gt;
&lt;span class="kwrd"&gt;if&lt;/span&gt; ( MyEvent != &lt;span class="kwrd"&gt;null&lt;/span&gt; )&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; MyEvent(&lt;span class="kwrd"&gt;this&lt;/span&gt;, EventArgs.Empty);&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
This leads to another issue.&amp;nbsp; Someone could unsubscribe from the event handler after we check for null which would lead to another null reference exception when we invoke the delegate.&amp;nbsp; Since delegates are immutable we can copy the delegate to a variable and it will keep its state even if someone unsubscribes from the event.&amp;nbsp; So we assign it to a variable, check the variable for null then invoke. 
&lt;/p&gt;
&lt;p&gt;
EventHandler handler = MyEvent;&lt;br /&gt;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (handler != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; handler(&lt;span class="kwrd"&gt;this&lt;/span&gt;, EventArgs.Empty);&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
That much code for invoking a delegate smells bad and needs to be moved to its own method.&amp;nbsp; So we refactor using ExtractMethod and create an OnMyEvent method. 
&lt;/p&gt;
&lt;p&gt;
&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnMyEvent()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; EventHandler handler = MyEvent;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (handler != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; handler(&lt;span class="kwrd"&gt;this&lt;/span&gt;, EventArgs.Empty);&lt;br /&gt;
}&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Now that we have the method there is one hidden issue that most people don&amp;#39;t realize could cause us problems which is compiler optimization.&amp;nbsp; The JIT compiler might decide to optimize our method, removing our variable and just make the call directly to the event delegate leaving us open for another null reference exception.&amp;nbsp; We can stop that from occurring by adding an attribute which will tell the compiler to not optimize the method. 
&lt;/p&gt;
&lt;p&gt;
[MethodImpl(MethodImplOptions.NoInlining)]&lt;br /&gt;
&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnMyEvent()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; EventHandler handler = MyEvent;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (handler != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; handler(&lt;span class="kwrd"&gt;this&lt;/span&gt;, EventArgs.Empty);&lt;br /&gt;
}&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
This gives us a self contained safe and easy way to raise the event. 
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/Defensive-Event-Publishing.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/Defensive-Event-Publishing.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=fce2a595-1794-4629-ba02-87d6bcb4926e</guid>
      <pubDate>Mon, 26 May 2008 15:48:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=fce2a595-1794-4629-ba02-87d6bcb4926e</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=fce2a595-1794-4629-ba02-87d6bcb4926e</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/Defensive-Event-Publishing.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=fce2a595-1794-4629-ba02-87d6bcb4926e</wfw:commentRss>
    </item>
    <item>
      <title>Vista Sidebar CC.Net Monitor</title>
      <description>&lt;p&gt;
Note to self....
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://gallery.live.com/LiveItemDetail.aspx?li=5b50b967-4961-4cf6-8c3d-456db65cba17"&gt;http://gallery.live.com/LiveItemDetail.aspx?li=5b50b967-4961-4cf6-8c3d-456db65cba17&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://codeclimber.net.nz/archive/2007/07/15/CruiseControl.NET-Monitor-Vista-Gadget-version-0.9.5.aspx"&gt;http://codeclimber.net.nz/archive/2007/07/15/CruiseControl.NET-Monitor-Vista-Gadget-version-0.9.5.aspx&lt;/a&gt;
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/Vista-Sidebar-CCNet-Monitor.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/Vista-Sidebar-CCNet-Monitor.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=329f6b22-2df9-4f59-badc-b4561e4f4cbe</guid>
      <pubDate>Sat, 23 Jun 2007 20:38:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=329f6b22-2df9-4f59-badc-b4561e4f4cbe</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=329f6b22-2df9-4f59-badc-b4561e4f4cbe</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/Vista-Sidebar-CCNet-Monitor.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=329f6b22-2df9-4f59-badc-b4561e4f4cbe</wfw:commentRss>
    </item>
    <item>
      <title>Windows 2003, IIS 6, FileStream, UnauthorizedAccessException</title>
      <description>&lt;p&gt;
Hopefully, if you are getting&amp;nbsp;an &lt;strong&gt;UnauthorizedAccessException&lt;/strong&gt;&amp;nbsp;in &lt;strong&gt;IIS 6&lt;/strong&gt; while trying to write out a file this will help you.
&lt;/p&gt;
&lt;p&gt;
Today a client was frustrated after rolling out an application from staging to live.&amp;nbsp; The web application created thumbnails on the fly and caches those thumbnails to disk using a FileStream.&amp;nbsp; The code worked fine in the dev environment and in the staging environment, but as soon as it went to the live server it started throwing an UnauthorizedAccessException whenever the file was being written.
&lt;/p&gt;
&lt;p&gt;
After searching Google for the terms in this posts subject I finally came across what I thought might &lt;a href="http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet.security/msg/1f9951abc8a296c3"&gt;fix the problem&lt;/a&gt;, sure enough it did. The &lt;strong&gt;IIS_WPG&lt;/strong&gt; group must have the correct rights in the folder you are trying to write files to.
&lt;/p&gt;
&lt;p&gt;
----------------------&amp;nbsp;Snip of the error -------------------&lt;br /&gt;
&lt;strong&gt;UnauthorizedAccessException&lt;/strong&gt;: Access to the path &amp;#39;[THE_PATH_WAS_HERE]&amp;#39; is denied.]&lt;br /&gt;
System.IO.__Error.&lt;strong&gt;WinIOError&lt;/strong&gt;(Int32 errorCode, String maybeFullPath) +2013027&lt;br /&gt;
System.IO.&lt;strong&gt;FileStream.Init&lt;/strong&gt;(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +998&lt;br /&gt;
System.IO.FileStream..ctor(String path, FileMode mode) +65
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/Windows-20032-IIS-6-FileStream-UnauthorizedAccessException.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/Windows-20032-IIS-6-FileStream-UnauthorizedAccessException.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=72f6cf9a-0274-4c87-8d39-e4ddd0f313ab</guid>
      <pubDate>Mon, 02 Apr 2007 20:22:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=72f6cf9a-0274-4c87-8d39-e4ddd0f313ab</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=72f6cf9a-0274-4c87-8d39-e4ddd0f313ab</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/Windows-20032-IIS-6-FileStream-UnauthorizedAccessException.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=72f6cf9a-0274-4c87-8d39-e4ddd0f313ab</wfw:commentRss>
    </item>
    <item>
      <title>Simulating Persisted StateMachine Workflows</title>
      <description>I wanted&amp;nbsp;the unit tests for a &lt;a href="http://msdn2.microsoft.com/en-us/library/system.workflow.activities.statemachineworkflowactivity.aspx" title="StateMachineWorkflowActivity Class (System.Workflow.Activities)"&gt;StateMachineWorkflow&lt;/a&gt; to act as if they are persisted so I&amp;nbsp;created the InMemoryPersistenceService.&amp;nbsp; Basically the service serializes the activities to memory then stores them as byte arrays in dictionaries using the guid as the key.&amp;nbsp; Fairly simple stuff, but usefull. 
&lt;p&gt;
&lt;a rel="enclosure" href="http://www.rodenbaugh.net/BlogEngine.Web/file.axd?file=InMemoryPersistenceService+.cs"&gt;InMemoryPersistenceService .cs (5.64 kb)&lt;/a&gt;
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/Simulating-Persisted-StateMachine-Workflows.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/Simulating-Persisted-StateMachine-Workflows.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=36873d02-a87d-464e-8ecc-9badda944113</guid>
      <pubDate>Fri, 30 Mar 2007 11:18:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=36873d02-a87d-464e-8ecc-9badda944113</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=36873d02-a87d-464e-8ecc-9badda944113</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/Simulating-Persisted-StateMachine-Workflows.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=36873d02-a87d-464e-8ecc-9badda944113</wfw:commentRss>
    </item>
    <item>
      <title>Multiple Generic Types + Multiple Constraints</title>
      <description>&lt;p&gt;
I could not remember how to do this (I kept trying to use a comma). 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; T CreateSomething&amp;lt;U, V&amp;gt;()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;where&lt;/span&gt; T : SomeObject&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;where&lt;/span&gt; U : SomeObject&amp;lt;V&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;where&lt;/span&gt; V : SomeThingElse, &lt;span class="kwrd"&gt;new&lt;/span&gt;()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;font color="#0000ff"&gt;.....&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;
} 
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/Multiple-Generic-Types-Multiple-Constraints.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/Multiple-Generic-Types-Multiple-Constraints.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=458da1ed-d1e2-4424-ab8d-f4e3904652a8</guid>
      <pubDate>Sun, 07 Jan 2007 11:02:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=458da1ed-d1e2-4424-ab8d-f4e3904652a8</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=458da1ed-d1e2-4424-ab8d-f4e3904652a8</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/Multiple-Generic-Types-Multiple-Constraints.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=458da1ed-d1e2-4424-ab8d-f4e3904652a8</wfw:commentRss>
    </item>
    <item>
      <title>Nesting Project Items</title>
      <description>&lt;p&gt;
I don&amp;#39;t really understand why this isn&amp;#39;t built in to vs.net.&amp;nbsp; &lt;a href="http://www.delarou.net/weblog/PermaLink,guid,a81a2d9d-02de-4fe1-ad8d-ee2fee97cf20.aspx" target="_blank" title="Visual Studio .NET Macro for nesting project items"&gt;Delarou&amp;#39;s macro&lt;/a&gt; makes life alot easier if you want to do any item nesting.&lt;br /&gt;
&lt;br /&gt;
---
&lt;/p&gt;
&lt;p&gt;
&amp;quot;This macro enables you to nest project items inside Visual Studio .NET. Until now, there is no easy way to nest project items through the Visual Studio IDE, you can only do it by manipulating the project (&lt;em&gt;.csproj&lt;/em&gt; or &lt;em&gt;.vbproj&lt;/em&gt;) file and adding the&amp;nbsp;&lt;em&gt;DependentUpon&lt;/em&gt; element.&amp;quot;
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/Nesting-Project-Items.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/Nesting-Project-Items.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=e6f37581-da46-425b-88c6-3e6fffd21c80</guid>
      <pubDate>Wed, 03 Jan 2007 13:56:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=e6f37581-da46-425b-88c6-3e6fffd21c80</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=e6f37581-da46-425b-88c6-3e6fffd21c80</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/Nesting-Project-Items.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=e6f37581-da46-425b-88c6-3e6fffd21c80</wfw:commentRss>
    </item>
    <item>
      <title>GridView Combined ImageField and HyperLinkField</title>
      <description>&lt;p&gt;
Is it so hard to imagine that someone someday would want to link an image to something from within the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx" title="GridView"&gt;GridView&lt;/a&gt;?&amp;nbsp; You&amp;nbsp;can&amp;#39;t just set some link properties on the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.imagefield.aspx" target="_blank" title="ImageField Class"&gt;ImageField&lt;/a&gt; or set some image properties on the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.aspx" target="_blank" title="HyperLinkField Class"&gt;HyperLinkField&lt;/a&gt;. So I broke out &lt;a href="http://www.aisto.com/roeder/dotnet/" title="Reflector for .NET"&gt;Reflector&lt;/a&gt; and made an ImageLinkField.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a rel="enclosure" href="http://www.rodenbaugh.net/BlogEngine.Web/file.axd?file=ImageLinkField+.cs"&gt;ImageLinkField .cs (12.75 kb)&lt;/a&gt;
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/GridView-Combined-ImageField-and-HyperLinkField.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/GridView-Combined-ImageField-and-HyperLinkField.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=d2dac87a-addf-4a75-8623-f592b471441b</guid>
      <pubDate>Fri, 08 Dec 2006 21:50:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=d2dac87a-addf-4a75-8623-f592b471441b</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=d2dac87a-addf-4a75-8623-f592b471441b</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/GridView-Combined-ImageField-and-HyperLinkField.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=d2dac87a-addf-4a75-8623-f592b471441b</wfw:commentRss>
    </item>
    <item>
      <title>C# Exception Class Template</title>
      <description>&lt;p&gt;
Download the&amp;nbsp;&lt;a rel="enclosure" href="http://www.rodenbaugh.net/BlogEngine.Web/file.axd?file=ExceptionClass.zip"&gt;ExceptionClass.zip (1.53 kb)&lt;/a&gt;&amp;nbsp;and place it in [Drive]:\Documents and Settings\[User]\My Documents\Visual Studio 2005\Templates\ItemTemplates\Visual C#\. 
&lt;/p&gt;
&lt;p&gt;
The next time you go to add a file, ExceptionClass should be in your &amp;quot;My Templates&amp;quot; section at the bottom. 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/C-Exception-Class-Template.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/C-Exception-Class-Template.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=6389e97f-5d47-48b1-b025-099d3342e722</guid>
      <pubDate>Tue, 21 Nov 2006 08:26:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=6389e97f-5d47-48b1-b025-099d3342e722</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=6389e97f-5d47-48b1-b025-099d3342e722</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/C-Exception-Class-Template.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=6389e97f-5d47-48b1-b025-099d3342e722</wfw:commentRss>
    </item>
    <item>
      <title>Simple ClickOnce Utils</title>
      <description>&lt;p&gt;
Two simple methods for &lt;a href="http://www.google.com/search?q=ClickOnce"&gt;ClickOnce&lt;/a&gt; deployed applications. 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ClickOnce&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;/// Determines whether this instance is deployed.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;///&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if this instance is deployed; otherwise, &amp;lt;c&amp;gt;false&amp;lt;/c&amp;gt;.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;/// &amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsDeployed()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; (AppDomain.CurrentDomain.ActivationContext != &lt;span class="kwrd"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; ApplicationDeployment.IsNetworkDeployed);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;/// Parses the query string.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;see cref=&amp;quot;NameValueCollection&amp;quot;/&amp;gt; containing the key/value pairs from the ActivationUri if they are found; otheriwise an empty &amp;lt;see cref=&amp;quot;NameValueCollection&amp;quot;/&amp;gt;.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; NameValueCollection ParseQueryString()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (!IsDeployed())&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; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; NameValueCollection();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Uri uri = ApplicationDeployment.CurrentDeployment.ActivationUri;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (uri != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NameValueCollection parms = HttpUtility.ParseQueryString(uri.Query);&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; &lt;span class="kwrd"&gt;if&lt;/span&gt; (parms.Count != 0)&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; &lt;span class="kwrd"&gt;return&lt;/span&gt; parms;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; NameValueCollection();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
} 
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/Simple-ClickOnce-Utils.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/Simple-ClickOnce-Utils.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=6ede0285-a0ed-48fa-bf63-6d1931c9c1d3</guid>
      <pubDate>Wed, 08 Nov 2006 19:59:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=6ede0285-a0ed-48fa-bf63-6d1931c9c1d3</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=6ede0285-a0ed-48fa-bf63-6d1931c9c1d3</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/Simple-ClickOnce-Utils.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=6ede0285-a0ed-48fa-bf63-6d1931c9c1d3</wfw:commentRss>
    </item>
    <item>
      <title>Enum Helper Class Using Generics</title>
      <description>&lt;p&gt;
A week or so ago I came across&amp;nbsp;&lt;a href="http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/7a51edaf8e47730d/79d7e2950e29ed1e?hl=en#79d7e2950e29ed1e"&gt;this&lt;/a&gt; post in &lt;a href="http://groups.google.com/group/microsoft.public.dotnet.languages.csharp?hl=en" target="_blank"&gt;microsoft.public.dotnet.languages.csharp&lt;/a&gt;&amp;nbsp;&amp;nbsp;asking about using Generics to make dealing with bitwise operations on enums that have the &lt;a href="http://www.google.com/search?num=100&amp;amp;hl=en&amp;amp;rls=GGLG,GGLG:2005-47,GGLG:en&amp;amp;lr=lang_en&amp;amp;sa=X&amp;amp;oi=spell&amp;amp;resnum=0&amp;amp;ct=result&amp;amp;cd=1&amp;amp;q=FlagsAttribute+bitwise+enum&amp;amp;spell=1"&gt;FlagsAttribute&lt;/a&gt;.&amp;nbsp; I was thinking that even though you can&amp;#39;t use an Enum as &lt;a href="http://www.google.com/search?num=100&amp;amp;hl=en&amp;amp;lr=lang_en&amp;amp;rls=GGLG%2CGGLG%3A2005-47%2CGGLG%3Aen&amp;amp;q=Generics+Constraint"&gt;Generic Constraint&lt;/a&gt;&amp;nbsp;you can probably fudge it just enough to make a usefull class. So I posted my answer to the question and then decided to write my Enum&amp;lt;T&amp;gt; class. Yes, I actually named the class Enum&amp;lt;T&amp;gt;. 
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;
&lt;a rel="enclosure" href="http://www.rodenbaugh.net/BlogEngine.Web/file.axd?file=Enum.cs"&gt;Enum.cs (17.12 kb)&lt;/a&gt;
&lt;/pre&gt;
&lt;p&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Class1&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [Flags]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; FlaggedEnum&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; None = 0,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Red = 1,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Blue = 2,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; White = 4,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Black = 8,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Green = 16&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; MyTestEnum&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Description(&lt;span class="str"&gt;&amp;quot;This is a description&amp;quot;&lt;/span&gt;)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Val0,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Val1,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Val2&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyTestEnum a;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enum&amp;lt;MyTestEnum&amp;gt;.TryParse(&lt;span class="str"&gt;&amp;quot;Val1&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;out&lt;/span&gt; a);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(a); &lt;span class="rem"&gt;// output: Val1&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;bool&lt;/span&gt; returnValue = Enum&amp;lt;MyTestEnum&amp;gt;.TryParse(&lt;span class="str"&gt;&amp;quot;Val3&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;out&lt;/span&gt; a);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(returnValue); &lt;span class="rem"&gt;// output: False&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyTestEnum? b;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enum&amp;lt;MyTestEnum&amp;gt;.TryParse(&lt;span class="str"&gt;&amp;quot;Val2&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;out&lt;/span&gt; b);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(b); &lt;span class="rem"&gt;// output: Val2&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enum&amp;lt;MyTestEnum&amp;gt;.TryParse(&lt;span class="str"&gt;&amp;quot;Val3&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;out&lt;/span&gt; b);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(b); &lt;span class="rem"&gt;// output: nothing&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//Enum&amp;lt;MyTestEnum&amp;gt;.Flags.IsFlagSet(a, MyTestEnum.Val2); // raises an assert by design&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//int test;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//Enum&amp;lt;int&amp;gt;.TryParse(&amp;quot;hello&amp;quot;, out test); // raises an assert by design&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;// Flags Methods&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FlaggedEnum flagged = FlaggedEnum.Red | FlaggedEnum.Blue | FlaggedEnum.White;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(flagged); &lt;span class="rem"&gt;// output: Red, Blue, White&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flagged = Enum&amp;lt;FlaggedEnum&amp;gt;.Flags.SwapFlag(flagged, FlaggedEnum.Red);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(flagged); &lt;span class="rem"&gt;// output: Blue, White&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flagged = Enum&amp;lt;FlaggedEnum&amp;gt;.Flags.SwapFlag(flagged, FlaggedEnum.Red);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(flagged); &lt;span class="rem"&gt;// output: Red, Blue, White&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flagged = Enum&amp;lt;FlaggedEnum&amp;gt;.Flags.ClearFlag(flagged, FlaggedEnum.White);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(flagged); &lt;span class="rem"&gt;// output: Red, Blue&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flagged = Enum&amp;lt;FlaggedEnum&amp;gt;.Flags.SetFlag(flagged, FlaggedEnum.White);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(flagged); &lt;span class="rem"&gt;// output: Red, Blue, White&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;// using the ref overrides&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enum&amp;lt;FlaggedEnum&amp;gt;.Flags.SwapFlag(&lt;span class="kwrd"&gt;ref&lt;/span&gt; flagged, FlaggedEnum.White);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(flagged); &lt;span class="rem"&gt;// output: Red, Blue&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enum&amp;lt;FlaggedEnum&amp;gt;.Flags.SetFlag(&lt;span class="kwrd"&gt;ref&lt;/span&gt; flagged, FlaggedEnum.White);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(flagged); &lt;span class="rem"&gt;// output: Red, Blue, White&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IList&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; values = Enum&amp;lt;FlaggedEnum&amp;gt;.GetValues&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;string&lt;/span&gt; name = Enum&amp;lt;FlaggedEnum&amp;gt;.GetName(2);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(name); &lt;span class="rem"&gt;// output: Blue&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DescriptionAttribute attrib = Enum&amp;lt;MyTestEnum&amp;gt;.Reflection.GetAttributeOnValue&amp;lt;DescriptionAttribute&amp;gt;(MyTestEnum.Val0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(attrib.Description); &lt;span class="rem"&gt;// output: This is a description&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;// For WinForms DataBinding&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IList&amp;lt;IBindableEnum&amp;lt;MyTestEnum&amp;gt;&amp;gt; list = Enum&amp;lt;MyTestEnum&amp;gt;.DataBinding.CreateList();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;foreach&lt;/span&gt;( IBindableEnum&amp;lt;MyTestEnum&amp;gt; bindable &lt;span class="kwrd"&gt;in&lt;/span&gt; list )&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; Debug.WriteLine(String.Format(&lt;span class="str"&gt;&amp;quot;{0} : {1}&amp;quot;&lt;/span&gt;, bindable.Name, bindable.Value));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;// output:&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//&amp;nbsp; Val0 : Val0&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//&amp;nbsp; Val1 : Val1&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//&amp;nbsp; Val2 : Val2&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list = Enum&amp;lt;MyTestEnum&amp;gt;.DataBinding.CreateList&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;delegate&lt;/span&gt;(MyTestEnum target) &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; { &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; &lt;span class="kwrd"&gt;return&lt;/span&gt; target.ToString().Replace(&lt;span class="str"&gt;&amp;quot;Val&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Value &amp;quot;&lt;/span&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; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (IBindableEnum&amp;lt;MyTestEnum&amp;gt; bindable &lt;span class="kwrd"&gt;in&lt;/span&gt; list)&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; Debug.WriteLine(String.Format(&lt;span class="str"&gt;&amp;quot;{0} : {1}&amp;quot;&lt;/span&gt;, bindable.Name, bindable.Value));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;// output:&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//&amp;nbsp; Value 0 : Val0&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//&amp;nbsp; Value 1 : Val1&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//&amp;nbsp; Value 2 : Val2&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://rodenbaugh.net/files/folders/18/download.aspx"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;
&amp;nbsp;
&lt;/pre&gt;
</description>
      <link>http://www.rodenbaugh.net/post/Enum-Helper-Class-Using-Generics.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/Enum-Helper-Class-Using-Generics.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=504fc407-48af-4d5e-8154-3a82e0ac6c10</guid>
      <pubDate>Wed, 01 Nov 2006 20:23:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=504fc407-48af-4d5e-8154-3a82e0ac6c10</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=504fc407-48af-4d5e-8154-3a82e0ac6c10</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/Enum-Helper-Class-Using-Generics.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=504fc407-48af-4d5e-8154-3a82e0ac6c10</wfw:commentRss>
    </item>
    <item>
      <title>Windows Forms Flicker Fix Using SendMessage</title>
      <description>&lt;p&gt;
A simple way to stop forms/controls from flickering. The zip file contains the WindowLock class. 
&lt;/p&gt;
&lt;div style="font-size: 10pt; font-family: Monospace; background-color: white"&gt;
&lt;span style="color: blue"&gt;using&lt;/span&gt;&lt;span style="color: black"&gt; (&lt;/span&gt;&lt;span style="color: teal"&gt;IWindowLock&lt;/span&gt;&lt;span style="color: black"&gt; windowLock = &lt;/span&gt;&lt;span style="color: teal"&gt;WindowLock&lt;/span&gt;&lt;span style="color: black"&gt;.CreateLock(control))&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: green"&gt;// do stuff....&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: black"&gt;}&lt;/span&gt; 
&lt;/div&gt;
&lt;p&gt;
&lt;a rel="enclosure" href="http://www.rodenbaugh.net/BlogEngine.Web/file.axd?file=External.Windows.zip"&gt;External.Windows.zip (8.48 kb)&lt;/a&gt; 
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/Windows-Forms-Flicker-Fix-Using-SendMessage.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/Windows-Forms-Flicker-Fix-Using-SendMessage.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=19760089-af80-43c1-8e6e-8ff2f4859eb1</guid>
      <pubDate>Tue, 17 Oct 2006 22:16:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=19760089-af80-43c1-8e6e-8ff2f4859eb1</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=19760089-af80-43c1-8e6e-8ff2f4859eb1</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/Windows-Forms-Flicker-Fix-Using-SendMessage.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=19760089-af80-43c1-8e6e-8ff2f4859eb1</wfw:commentRss>
    </item>
    <item>
      <title>Implementing IPersistComponentSettings</title>
      <description>&lt;p&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/system.configuration.ipersistcomponentsettings.aspx" target="_blank"&gt;IPersistComponentSettings&lt;/a&gt; is defined by MSDN as a standard functionality for controls or libraries that store and retrieve application settings. Yes, MSDN does define it and it&amp;nbsp;shows you all the properties and methods on the interface, however it does not tell you how to use it at all. 
&lt;/p&gt;
&lt;p&gt;
In the simplest case you need a class which inherits from &lt;em&gt;System.Configuration.ApplicationSettingsBase&lt;/em&gt; to store your settings. Your control (or UserControl) needs to implement the &lt;em&gt;IPersistComponentSettings&lt;/em&gt; and have it&amp;rsquo;s &lt;em&gt;SaveSettings&lt;/em&gt; property set to true. It is also a good idea to set the &lt;em&gt;SettingsKey&lt;/em&gt; property to something specific. The name of control seems to work fine. 
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;LoadComponentSettings&lt;/em&gt;(): retrieve your properties from the &lt;em&gt;ApplicationSettingsBase&lt;/em&gt; class and set the values on the control. 
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;SaveComponentSettings&lt;/em&gt;(): set the properties on the &lt;em&gt;ApplicationSettingsBase&lt;/em&gt; class and then call the Save() method on that class. 
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;ResetComponentSettings&lt;/em&gt;(): call &lt;em&gt;Reset&lt;/em&gt;() on the &lt;em&gt;ApplicationSettingsBase&lt;/em&gt; class. 
&lt;/p&gt;
&lt;p&gt;
I have not figured out how or if something else should be forcing a save by calling &lt;em&gt;SaveComponentSettings&lt;/em&gt; automatically, so in my control I added an override to the &lt;em&gt;Dispose&lt;/em&gt; method and call &lt;em&gt;SaveComponentSettings&lt;/em&gt; myself. 
&lt;/p&gt;
&lt;p&gt;
&lt;a rel="enclosure" href="http://www.rodenbaugh.net/BlogEngine.Web/file.axd?file=IPersistComponentSettingsExample.zip"&gt;IPersistComponentSettingsExample.zip (14.72 kb)&lt;/a&gt;
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/Implementing-IPersistComponentSettings.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/Implementing-IPersistComponentSettings.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=34e02220-1705-4db6-8189-6c7c23545a0a</guid>
      <pubDate>Sat, 14 Oct 2006 22:42:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=34e02220-1705-4db6-8189-6c7c23545a0a</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=34e02220-1705-4db6-8189-6c7c23545a0a</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/Implementing-IPersistComponentSettings.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=34e02220-1705-4db6-8189-6c7c23545a0a</wfw:commentRss>
    </item>
    <item>
      <title>A simple way to get the Desktop Width/Height across all monitors</title>
      <description>&lt;p&gt;
You would think that System.Windows.Forms.Screen would have a property for the whole desktop, but it doesn&amp;#39;t.&amp;nbsp; If you are looking to get the actual desktop width and height across all monitors you need to use.....
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;System.Windows.Forms.SystemInformation.VirtualScreen&lt;/strong&gt;
&lt;/p&gt;
</description>
      <link>http://www.rodenbaugh.net/post/A-simple-way-to-get-the-Desktop-WidthHeight-across-all-monitors.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/A-simple-way-to-get-the-Desktop-WidthHeight-across-all-monitors.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=75ce5cf6-5e01-432c-8609-0a77787038e5</guid>
      <pubDate>Sat, 14 Oct 2006 14:37:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=75ce5cf6-5e01-432c-8609-0a77787038e5</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=75ce5cf6-5e01-432c-8609-0a77787038e5</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/A-simple-way-to-get-the-Desktop-WidthHeight-across-all-monitors.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=75ce5cf6-5e01-432c-8609-0a77787038e5</wfw:commentRss>
    </item>
    <item>
      <title>VS.Net 2005 taking forever to close files</title>
      <description>I have a large solution w/ 30+ projects and everytime I closed a file in the IDE it took almost 10 seconds to close.&amp;nbsp; I found that when I deleted the slutions .suo (solution user options) file this fixed my problem.&amp;nbsp; I have no idea what that thing was doing, but it seemed to fix it. 
</description>
      <link>http://www.rodenbaugh.net/post/VSNet-2005-taking-forever-to-close-files.aspx</link>
      <author>bill</author>
      <comments>http://www.rodenbaugh.net/post/VSNet-2005-taking-forever-to-close-files.aspx#comment</comments>
      <guid>http://www.rodenbaugh.net/post.aspx?id=4ad48c9a-a803-44e0-b030-04ded69eb607</guid>
      <pubDate>Thu, 12 Oct 2006 07:57:00 -0700</pubDate>
      <dc:publisher>bill</dc:publisher>
      <pingback:server>http://www.rodenbaugh.net/pingback.axd</pingback:server>
      <pingback:target>http://www.rodenbaugh.net/post.aspx?id=4ad48c9a-a803-44e0-b030-04ded69eb607</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.rodenbaugh.net/trackback.axd?id=4ad48c9a-a803-44e0-b030-04ded69eb607</trackback:ping>
      <wfw:comment>http://www.rodenbaugh.net/post/VSNet-2005-taking-forever-to-close-files.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.rodenbaugh.net/syndication.axd?post=4ad48c9a-a803-44e0-b030-04ded69eb607</wfw:commentRss>
    </item>
  </channel>
</rss>