<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>@ Head : VB10</title><link>http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx</link><description>Tags: VB10</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>ElementAtOrDefault</title><link>http://msmvps.com/blogs/bill/archive/2009/12/15/elementatordefault.aspx</link><pubDate>Tue, 15 Dec 2009 01:40:17 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1745625</guid><dc:creator>bill</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1745625</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/12/15/elementatordefault.aspx#comments</comments><description>&lt;p&gt;VB 9 or later has a particular &lt;em&gt;feature&lt;/em&gt; that can make life easier in some circumstances: the compiler allows you to access indexed items on non indexed enumerables.&amp;#160;&amp;#160; Let’s say you have code such as:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Dim items as IEnumerable(Of String)     &lt;br /&gt;. . . .      &lt;br /&gt;For i = 0 to items.Count - 1      &lt;br /&gt;&amp;#160;&amp;#160; Debug.Print items(i)      &lt;br /&gt;Next&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;VB will compile that for you. The Count is an extension method that loops through the list to determine the count; luckily VB calls that only once. The real killer though is&lt;strong&gt; items(i)&lt;/strong&gt; is actually compiled as &lt;strong&gt;items.ElementAtOrDefault(i). &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;ElementAtOrDefault&lt;/strong&gt; extension tries to cast the IEnumerable(Of T) to an IList(Of T); if the IEnumerable isn’t actually an IList, it loops through the collection, returning at the given index. As you can imagine this would get extremely slow for large lists especially inside a loop.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Good:&lt;/strong&gt;    &lt;br /&gt;&amp;#160;&amp;#160; If your IEnumerable is in fact an IList, such as a List(Of T), then the compiler magically adding this extension call makes life a little easier as you don’t have to cast to IList yourself.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The BAD:     &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160; You have to be really careful when doing any code maintenance, especially if you change an IEnumerable source to a different collection base that doesn’t implement IList(Of T). You can end up writing really bad, slow code really easily.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;I got bitten by the bad, but I caught it immediately as I was curious about the collection base I was using.&amp;#160; In my particular case I had swapped an List(Of T) out with a ConcurrentBag(Of T). ConcurrentBag(Of T) basically uses linked lists where each item is stored as a node. Each node has a previous and next node; the list has a head and a tail. I thought it strange that ConcurrentBag would have an indexer given that would force walking through the nodes. I went to change the items(i) to items.Item(i) and BINGO it wouldn’t compile.&lt;/p&gt;  &lt;p&gt;Possible best practices to avoid being bitten by this:&lt;/p&gt;  &lt;p&gt;(1) Use For Each loops, not indexers. Your code will be far more flexible/manageable&lt;/p&gt;  &lt;p&gt;(2) If you only want the first item, make it explicit by using First or FirstOrDefault extensions.&lt;/p&gt;  &lt;p&gt;(3) Try to do the explicit cast to IList(Of T) yourself and work with an IList(Of T) instead of an IEnumerable(Of T)&lt;/p&gt;  &lt;p&gt;(4) Consider explicitly using the Item property , eg: items.Item(0) instead of items(0)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I’m not really comfortable with having to use the Item property: hopefully practices 1 to 3 will alleviate the need for practice 4.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1745625" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://msmvps.com/blogs/bill/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category></item><item><title>IntPtr gets operators !!!</title><link>http://msmvps.com/blogs/bill/archive/2009/11/05/intptr-gets-operators.aspx</link><pubDate>Thu, 05 Nov 2009 01:48:27 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1737714</guid><dc:creator>bill</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1737714</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/11/05/intptr-gets-operators.aspx#comments</comments><description>&lt;p&gt;This seems so incredibly long overdue, but at last as of .NET 4, IntPtr has + and – operators added to it !!&lt;/p&gt;  &lt;p&gt;This means you can now easily write code such as :&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; Dim ptr As IntPtr &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; . . . .   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ptr += 4&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;this is great when dealing with offsets etc.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The actual implementation is kind of interesting. Here I’m seeing&amp;#160; the implementation as :&lt;/p&gt;  &lt;p&gt;&lt;font color="#4d6886"&gt;Public Shared &lt;b&gt;Operator&lt;/b&gt; &lt;b&gt;&lt;a href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:4.0.0.0:b77a5c561934e089/System.IntPtr/op_Subtraction(IntPtr,Int32):IntPtr"&gt;-&lt;/a&gt;&lt;/b&gt;(ByVal &lt;b&gt;pointer&lt;/b&gt; As &lt;/font&gt;&lt;a href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:4.0.0.0:b77a5c561934e089/System.IntPtr"&gt;&lt;font color="#4d6886"&gt;IntPtr&lt;/font&gt;&lt;/a&gt;&lt;font color="#4d6886"&gt;, ByVal &lt;b&gt;offset&lt;/b&gt; As &lt;/font&gt;&lt;a href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:4.0.0.0:b77a5c561934e089/System.Int32"&gt;&lt;font color="#4d6886"&gt;Integer&lt;/font&gt;&lt;/a&gt;&lt;font color="#4d6886"&gt;) As &lt;/font&gt;&lt;a href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:4.0.0.0:b77a5c561934e089/System.IntPtr"&gt;&lt;font color="#4d6886"&gt;IntPtr&lt;/font&gt;&lt;/a&gt;&lt;font color="#4d6886"&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return New &lt;/font&gt;&lt;a href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:4.0.0.0:b77a5c561934e089/System.IntPtr/.ctor(Int32)"&gt;&lt;font color="#4d6886"&gt;IntPtr&lt;/font&gt;&lt;/a&gt;&lt;font color="#4d6886"&gt;((&lt;/font&gt;&lt;a&gt;&lt;font color="#4d6886"&gt;pointer&lt;/font&gt;&lt;/a&gt;&lt;font color="#4d6886"&gt;.&lt;/font&gt;&lt;a href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:4.0.0.0:b77a5c561934e089/System.IntPtr/ToInt32():Int32"&gt;&lt;font color="#4d6886"&gt;ToInt32&lt;/font&gt;&lt;/a&gt;&lt;font color="#4d6886"&gt; - &lt;/font&gt;&lt;a&gt;&lt;font color="#4d6886"&gt;offset&lt;/font&gt;&lt;/a&gt;&lt;font color="#4d6886"&gt;))      &lt;br /&gt;End Function&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I guess this is because it is the 32 bit version of the library. Hopefully in the 64 bit version it calls on IntPtr.ToInt64 ;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1737714" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category></item><item><title>Iterators: a flag for simplification ?</title><link>http://msmvps.com/blogs/bill/archive/2009/04/21/iterators-a-flag-for-simplification.aspx</link><pubDate>Tue, 21 Apr 2009 02:02:16 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1689277</guid><dc:creator>bill</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1689277</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/04/21/iterators-a-flag-for-simplification.aspx#comments</comments><description>&lt;p&gt;A couple of months ago &lt;a href="http://msmvps.com/blogs/bill/archive/2009/02/02/iterators-in-vb-10.aspx" target="_blank"&gt;I blogged about iterators in VB&lt;/a&gt; (or the lack there-of), and pointed folks to &lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2972" target="_blank"&gt;an article I wrote for Visual Studio magazine that provides snippets and templates to help with iterators in VB&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;One of the things I talk about in that article is often the use of iterators in C# code that I have seen is superfulous, especially given the LINQ libraries.&amp;#160; Yesterday I read &lt;a href="http://weblogs.asp.net/davidmccollough/archive/2009/04/19/covariant-generic-list.aspx" target="_blank"&gt;another example of this where the developer(s) had written a custom iterator instead of using a LINQ query&lt;/a&gt;. Their code required the defining of a generic class:     &lt;br /&gt;&lt;/p&gt;    &lt;blockquote&gt;     &lt;pre&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; EnumerableGeneric&amp;lt;TClass, TInterface&amp;gt; 
              : IEnumerable&amp;lt;TInterface&amp;gt; where TClass : TInterface
{
   &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; IList&amp;lt;TClass&amp;gt; list;

   &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; EnumerableGeneric(IList&amp;lt;TClass&amp;gt; list)
   {
      &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.list = list;
   }

   &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; IEnumerator&amp;lt;TInterface&amp;gt; GetEnumerator()
   {
      &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (TClass item &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; list)
      {
         yield &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; item;
      }
   }

   IEnumerator IEnumerable.GetEnumerator()
   {
      &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.GetEnumerator();
   }
}&lt;/pre&gt;
  &lt;/blockquote&gt;


&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;And the example of using this required the calling code to instantiate an instance of this class:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

  &lt;blockquote&gt;
    &lt;pre&gt;MyMethod(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; EnumerableGeneric&amp;lt;ClassA, IClassInterface&amp;gt;(caInstance));&lt;/pre&gt;
  &lt;/blockquote&gt;


&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;A simpler alternative is to actually use LINQ, eg:&lt;/p&gt;

&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyMethod(caInstance.Cast&amp;lt;IClassInterface&amp;gt;());&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;In VB talk I think it’s even more natural flowing: 
  &lt;br /&gt;

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; MyMethod(caInstance.Cast(Of IClassInterface))&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;It is in places like that I like the (Of T) syntax of VB a lot better, but some folks prefer a Cup&amp;lt;T&amp;gt; to a Cup(Of T)&amp;#160; .&amp;#160; The key point here is the use of “yield return” in C# is a good indicator that the code can often be replaced with far simpler LINQ constructs that reduce your LOC’s, and hence reduce your debugging and maintenance loads.&amp;#160; There will of course be times where there isn’t a simple LINQ replacement, but if you do ever come across custom iterators, do take pause to think about using LINQ.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1689277" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Microsoft: make VB like C#</title><link>http://msmvps.com/blogs/bill/archive/2009/03/19/microsoft-make-vb-like-c.aspx</link><pubDate>Thu, 19 Mar 2009 11:48:24 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1679464</guid><dc:creator>bill</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1679464</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/03/19/microsoft-make-vb-like-c.aspx#comments</comments><description>&lt;p&gt;I was reading yet another VB versus C# rant: I don’t want to get sucked into wading into that, but I will say that anyone who thinks folks that use VB can’t use C# has really got things back the front.&amp;#160; Most people who use VB can read and write C# quite well; they &lt;strong&gt;choose&lt;/strong&gt; VB knowing both.&amp;#160; Whereas so many C# developers I’ve met have absolutely no idea about VB or concepts such as declarative event handling etc, etc.&amp;#160; For them they don’t have the basis of choice.&amp;#160; &lt;/p&gt;  &lt;p&gt;The reason VB folk have to read and write in C# is because a lot of SDK’s etc are all in C# originally.&amp;#160; Even things like the enterprise library provide source code only in C#; this even after Soma promised to do better in regard to that.&amp;#160; So for VB folks there is a real need to learn C#.&lt;/p&gt;  &lt;p&gt;The big problem though is if you want to use C# source code in your VB project: you often have to re-write it or separate into different assemblies.&amp;#160; That’s not productive.&amp;#160; What I want is for VB to like C# and vice versa.&amp;#160; I don’t mean make them the same, I mean for them to &lt;strong&gt;like&lt;/strong&gt; each other; to get along well inside the same project.&amp;#160; I’d like to be able to add a C# class to my VB project and happily compile it.&amp;#160; And I bet some C# folk would love to have some concurrent basic or XML literals in their C# projects without all the current barriers.&lt;/p&gt;  &lt;p&gt;Maybe the talk of compilers as a service type thing will give us that true cross language project, where VB and C# like each other so much that they then are free to diverge again :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1679464" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Rant/default.aspx">Rant</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category></item><item><title>String.IsNullOrEmpty : update on that nasty null reference exception</title><link>http://msmvps.com/blogs/bill/archive/2009/03/10/string-isnullorempty-update-on-that-nasty-null-reference-exception.aspx</link><pubDate>Tue, 10 Mar 2009 12:08:26 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1677289</guid><dc:creator>bill</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1677289</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/03/10/string-isnullorempty-update-on-that-nasty-null-reference-exception.aspx#comments</comments><description>&lt;p&gt;Back in April 2006, &lt;a href="http://msmvps.com/blogs/bill/archive/2006/04/04/89234.aspx" target="_blank"&gt;I blogged about a nasty JIT compiler optimisation&lt;/a&gt; that would cause String.IsNullOrEmpty to throw a null reference exception;&amp;#160; ironic really given that is the very thing you’d use the IsNullOrEmpty method to check against.&amp;#160; Well since then, due to popular demand on the connect site, this bug has been fixed in .NET 2.0 SP1 (which implies .NET 3.0 and 3.5)&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://msmvps.com/kb/940900/"&gt;&lt;em&gt;940900&lt;/em&gt;&lt;/a&gt;&lt;em&gt; (http://support.microsoft.com/kb/940900/ ) FIX: You receive the NullReferenceException exception when you call the String.IsNullOrEmpty function in an application that is built on the .NET Framework 2.0&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1677289" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Whidbey/default.aspx">Whidbey</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Bug/default.aspx">Bug</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Snippet Editor 2.1 screen-cast</title><link>http://msmvps.com/blogs/bill/archive/2009/02/05/snippet-editor-2-1-screen-cast.aspx</link><pubDate>Thu, 05 Feb 2009 09:08:31 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1669250</guid><dc:creator>bill</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1669250</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/02/05/snippet-editor-2-1-screen-cast.aspx#comments</comments><description>&lt;p&gt;I’ve just uploaded a new screen cast:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://billmccarthy.com/Projects/Snippet_Editor/screencast.html" target="_blank"&gt;Snippet Editor Tips and Tricks&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Enjoy :)&lt;/p&gt;  &lt;p&gt;(oh and don’t forget the “&lt;a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;amp;hosted_button_id=2895732" target="_blank"&gt;buy me a beer&lt;/a&gt;” button)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1669250" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Whidbey/default.aspx">Whidbey</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Snippets/default.aspx">Snippets</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/XML/default.aspx">XML</category></item><item><title>New release of Snippet Editor</title><link>http://msmvps.com/blogs/bill/archive/2009/02/04/new-release-of-snippet-editor.aspx</link><pubDate>Tue, 03 Feb 2009 17:31:38 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1668548</guid><dc:creator>bill</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1668548</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/02/04/new-release-of-snippet-editor.aspx#comments</comments><description>&lt;p&gt;Snippet Editor 2.1 is now released on codeplex:    &lt;br /&gt;&lt;a title="http://www.codeplex.com/SnippetEditor" href="http://www.codeplex.com/SnippetEditor"&gt;http://www.codeplex.com/SnippetEditor&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Apart from the few minor bug fixes, it includes improved search and now support for Visual Studio 2010 as well as 2008 and 2005.&lt;/p&gt;  &lt;p&gt;I’ve also added a “buy me a beer” button to this blog, and on the codeplex site, so if you like the Snippet Editor you can help put a smile on my face :) &lt;/p&gt;  &lt;p&gt;&lt;a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;amp;hosted_button_id=2895732"&gt;&lt;img title="donate" alt="donate" src="http://msmvps.com/cfs-filesystemfile.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill/bymeabeer.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The snippet editor remains free: no advertisements, no nag screens.&amp;#160; &lt;/p&gt;  &lt;p&gt;yep, free as in beer ;)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Enjoy :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1668548" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Whidbey/default.aspx">Whidbey</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Snippets/default.aspx">Snippets</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/XML/default.aspx">XML</category></item><item><title>Iterators in VB 10 ?</title><link>http://msmvps.com/blogs/bill/archive/2009/02/02/iterators-in-vb-10.aspx</link><pubDate>Mon, 02 Feb 2009 13:56:01 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1668151</guid><dc:creator>bill</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1668151</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/02/02/iterators-in-vb-10.aspx#comments</comments><description>&lt;p&gt;Although VB 10 won’t have a formal syntax for iterators, it will have all the necessary ingredients to easily write iterators. In VB10 you can use a generic template and multi line lambdas to create iterators. &lt;/p&gt;  &lt;p&gt;This iterator in C# :&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt; static public IEnumerable&amp;lt;String&amp;gt; Lines( this TextReader rdr)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; String line;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; while ((line = rdr.ReadLine()) != null)&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; yield return line;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Can be written as this in VB10:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&amp;lt;Extension()&amp;gt; &lt;/font&gt;&lt;br /&gt;Public Function Lines(ByVal rdr as TextReader) As IEnumerable(Of String)&lt;/pre&gt;

  &lt;pre&gt;     Return New GenericIterator(Of String) 
          (&lt;strong&gt;Function(ByRef nextItem As String) As Boolean
              nextItem = rdr.ReadLine
              Return nextItem IsNot Nothing
           End Function)&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre&gt;End Function&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The above code uses a generic iterator class that accepts a lambda function. The lambda function sets the Current item of the iterator and returns True if MoveNext should be True. The above example is written as an extension method, but you can also use the inner part of the function inline.&lt;/p&gt;

&lt;p&gt;For more on using iterators in VB 9 today, as well as the generic class for the above example, see &lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2972" target="_blank"&gt;my latest article in Visual Studio Magazine .&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1668151" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx">VSM</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category></item><item><title>VB.Net and splash screens</title><link>http://msmvps.com/blogs/bill/archive/2009/01/20/vb-net-and-splash-screens.aspx</link><pubDate>Tue, 20 Jan 2009 00:27:39 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1663420</guid><dc:creator>bill</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1663420</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/01/20/vb-net-and-splash-screens.aspx#comments</comments><description>&lt;p&gt;One of the nice things about the My application framework in VB.NET is the ability to easily show splash screens.&amp;#160; The splash screen is displayed using a separate thread and by default will close when your main form’s Load event is called. There is however a quirk with it &lt;em&gt;sometimes&lt;/em&gt;. &lt;/p&gt;  &lt;p&gt;Whilst testing, if I launched the application from Explorer, the splash screen would appear in front of the explorer window but the main form behind it.&amp;#160; When the splash screen closed, the main form didn’t come to the foreground.&amp;#160; This behaviour would depend on the system being tested and seems to only consistently show up when run from a VPC.&amp;#160; The fix for this is reasonably simple: you just need to call Activate in your main form’s Load event&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="font-size:11pt;background:#f1f3f2;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Private&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; Me_Load(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; Object, &lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; EventArgs) &lt;span style="color:#3092b1;"&gt;Handles&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;MyBase&lt;/span&gt;.Load&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Me&lt;/span&gt;.Activate()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Kudos to &lt;a href="http://blogs.msdn.com/vbteam/" target="_blank"&gt;the VB team&lt;/a&gt; for the fix :)&lt;/p&gt;  &lt;p&gt;When the VB team suggested this fix to me, I could have sworn I had already tried that.&amp;#160; I had also looked into the my application framework code and saw it called Activate in it’s handler of the Load. So my first thoughts on it was it was a race condition, and hence I set up a single shot timer to call Activate, the timer being set to trigger a couple of hundred milliseconds after the load event.&amp;#160; At first I thought that fixed it, but that was the “sometimes” effect tricking me &amp;lt;g&amp;gt;&lt;/p&gt;  &lt;p&gt;Kevin from the VB team suggested I try Activate in the Load event, and sure enough it seems to work *&lt;strong&gt;ALL&lt;/strong&gt;* the time.&amp;#160; But this was even more puzzling as to why didn’t my timer approach work.&amp;#160; So I tried overriding the OnLoad method :&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="font-size:11pt;background:#f1f3f2;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Protected&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Overrides&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; OnLoad(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; EventArgs)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;MyBase&lt;/span&gt;.OnLoad(e)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Me&lt;/span&gt;.Activate()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;That actually fails ( yes “sometimes”).&amp;#160; But if you change that to:&lt;/p&gt;  &lt;div style="font-size:11pt;background:#f1f3f2;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &lt;span style="color:#3092b1;"&gt;Protected&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Overrides&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; OnLoad(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; EventArgs)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Me&lt;/span&gt;.Activate()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;MyBase&lt;/span&gt;.OnLoad(e)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Then it works. So the key is that Activate has to be called before the call to OnLoad completes.&amp;#160;&amp;#160; Suddenly the pieces of the puzzle all fit together.&amp;#160; &lt;/p&gt;  &lt;p&gt;What I think is happening is this: The my application framework hooks into the Load event and uses that to dispose of the splash screen. The problem occurs when the splash screen which has the UI input is closed before the call to Activate is made. Because the calling thread doesn’t have the UI Input, SetForeGround window doesn’t work.&amp;#160; Based on this hypothesis, I suggested a fix to the WindowsFormsApplicationBase.&amp;#160; Currently is has this method in it:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="font-size:11pt;background:#f1f3f2;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39;************************************************************************** &lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; ;HideSplashScreen&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;summary&amp;gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; Hide the splash screeen.&amp;#160; The splash screen was created on another thread so marshal &lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; the call over to it.&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;/summary&amp;gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;EditorBrowsable(EditorBrowsableState.Advanced)&amp;gt; &lt;span style="color:#3092b1;"&gt;Protected&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; HideSplashScreen()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;SyncLock&lt;/span&gt; m_SplashLock &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;We can get called from two threads at once&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt; m_SplashScreen &lt;span style="color:#3092b1;"&gt;IsNot&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;AndAlso&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Not&lt;/span&gt; m_SplashScreen.IsDisposed &lt;span style="color:#3092b1;"&gt;Then&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; TheBigGoodbye &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; DisposeDelegate(&lt;span style="color:#3092b1;"&gt;AddressOf&lt;/span&gt; m_SplashScreen.Dispose)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; m_SplashScreen.Invoke(TheBigGoodbye) &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; m_SplashScreen = &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Me&lt;/span&gt;.MainForm &lt;span style="color:#3092b1;"&gt;IsNot&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Then&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Call&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; System.Security.Permissions.UIPermission(UIPermissionWindow.AllWindows).Assert()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Me&lt;/span&gt;.MainForm.Activate()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Security.PermissionSet.RevertAssert() &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;CLR also reverts if we throw or when we return from this function&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;SyncLock&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; &lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;My suggestion is to activate the main form before disposing of the splash screen :&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="font-size:11pt;background:#f1f3f2;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:#e6ffe6;color:green;"&gt;&lt;/span&gt;&lt;/p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;EditorBrowsable(EditorBrowsableState.Advanced)&amp;gt; &lt;span style="color:#3092b1;"&gt;Protected&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; HideSplashScreen()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;SyncLock&lt;/span&gt; m_SplashLock &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;We can get called from two threads at once&lt;/span&gt;    &lt;p style="margin:0px;"&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;&lt;/span&gt;&lt;/p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Me&lt;/span&gt;.MainForm &lt;span style="color:#3092b1;"&gt;IsNot&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Then     &lt;br /&gt;&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Call&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; System.Security.Permissions.UIPermission(UIPermissionWindow.AllWindows).Assert()    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Me&lt;/span&gt;.MainForm.Activate()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Security.PermissionSet.RevertAssert() &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;CLR also reverts if we throw or when we return from this function&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt; m_SplashScreen &lt;span style="color:#3092b1;"&gt;IsNot&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;AndAlso&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Not&lt;/span&gt; m_SplashScreen.IsDisposed &lt;span style="color:#3092b1;"&gt;Then&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; TheBigGoodbye &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; DisposeDelegate(&lt;span style="color:#3092b1;"&gt;AddressOf&lt;/span&gt; m_SplashScreen.Dispose)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; m_SplashScreen.Invoke(TheBigGoodbye) &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; m_SplashScreen = &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;SyncLock&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; &lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Hopefully that will fix this issue completely. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In the meanwhile, simply call Activate in your main form’s Load event :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1663420" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Bug/default.aspx">Bug</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category></item><item><title>Extension methods and Interfaces.</title><link>http://msmvps.com/blogs/bill/archive/2009/01/15/extension-methods-and-interfaces.aspx</link><pubDate>Thu, 15 Jan 2009 04:58:59 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1661885</guid><dc:creator>bill</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1661885</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/01/15/extension-methods-and-interfaces.aspx#comments</comments><description>&lt;p&gt;A comment by &lt;a href="http://blogs.msdn.com/brada/archive/2009/01/12/framework-design-guidelines-extension-methods.aspx" target="_blank"&gt;Joe Duffy on the Framework Guidelines for Extension&lt;/a&gt; says :&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Extension methods can also be used to provide actual concrete method implementations for interfaces.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;And this is a very important point. In .NET there is no support for multiple implementation inheritance. So although you could use an abstract class (MustInherit) with some implementation in it, you would be tied to that single chain in your class inheritance. Interfaces on the other hand are extremely flexible, supporting multiple inheritance both in interfaces and implementing classes.&amp;#160; So by providing extension methods for interfaces, you get great flexibility and code re-use, and you also get to extend existing interfaces.. the classic example being the Enumerable set of extensions which extend IEnumerable(Of T)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1661885" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category></item><item><title>So what is a “Library”  ?</title><link>http://msmvps.com/blogs/bill/archive/2009/01/12/so-what-is-a-library.aspx</link><pubDate>Sun, 11 Jan 2009 14:13:41 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1660746</guid><dc:creator>bill</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1660746</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/01/12/so-what-is-a-library.aspx#comments</comments><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/blogs/bill/archive/2009/01/11/winfs-it-s-b-a-a-a-ck.aspx" target="_blank"&gt;Earlier I posted&lt;/a&gt; what I hope wetted your appetite for some more info about Libraries in Windows 7.&amp;#160; So&amp;#160; what are libraries you ask//I ask ;) Well I hope the following provides some insight.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;em&gt;caveat emptor: this is still just my first impressions !&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;A Library is really a view of different “folders”.&amp;#160; Each library is a file, which internally is an xml file.&amp;#160; The default library files are stored in the user’s roaming profile, eg:&lt;/p&gt;  &lt;p&gt;C:\Users\Bill\AppData\Roaming\Microsoft\Windows\Libraries&lt;/p&gt;  &lt;p&gt;This is an example of &lt;/p&gt;  &lt;div style="font-size:11pt;background:#f1f3f2;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a31515;"&gt;xml&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:#a60000;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="color:#2d7bd2;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:#a60000;"&gt;encoding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="color:#2d7bd2;"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;?&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;libraryDescription&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ownerSID&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;S-1-5-21-168223323-3520011370-4180941423-1000&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ownerSID&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;3&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;isLibraryPinned&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;-1&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;isLibraryPinned&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;templateInfo&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;folderType&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;{5C4F28B5-F869-4E84-8E60-F11DB97C5CC7}&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;folderType&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;templateInfo&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;propertyStore&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;property&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:#a60000;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="color:#2d7bd2;"&gt;&amp;quot;HasModifiedLocations&amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:#a60000;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="color:#2d7bd2;"&gt;&amp;quot;boolean&amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&amp;lt;![CDATA[&lt;/span&gt;&lt;span style="color:gray;"&gt;-1&lt;/span&gt;&lt;span style="color:blue;"&gt;]]&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;property&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;propertyStore&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;searchConnectorDescriptionList&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;searchConnectorDescription&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;isDefaultSaveLocation&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;-1&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;isDefaultSaveLocation&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;simpleLocation&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;url&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;C:\Users\Bill\Documents\Visual Studio 2008\Projects&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;url&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;serialized&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;…&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;serialized&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;simpleLocation&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;searchConnectorDescription&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;searchConnectorDescriptionList&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;libraryDescription&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I omitted the contents of the serialized element for brevity.&lt;/p&gt;  &lt;p&gt;You can programmatically access libraries via the IShellLibrary interface and some shell helper functions.&amp;#160; &lt;/p&gt;  &lt;p&gt;You can add multiple “folders” to these library files.&amp;#160; I say “folders” in quotes, because according to the IShellLibrary::AddFolder documentation, &lt;strong&gt;&lt;em&gt;the object in psiLocation can be a folder or a Search Connector (*.searchconnector-ms) file&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;What’s this mean.&amp;#160; Well I don’t know for sure yet, but it looks to me like Libraries can be a way to aggregate search providers. At the simplest level they provide a view of directories, but they have the potential to provide a view over data from various sources, not just file based.&amp;#160; This of course leads us towards the topic of “Federated Search” (more on that in next episode &amp;lt;g&amp;gt;).&amp;#160; &lt;/p&gt;  &lt;p&gt;So is it WinFS ? Not really. It is not reliant on managed frameworks like the entity framework… it is instead heavily reliant on XML. From the Library file, saved searches, right through to Federated Search which itself is based around RSS style of XML.&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;Thankfully VB9 rocks when it comes to working with XML !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1660746" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/XML/default.aspx">XML</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>XSD’s in Visual Studio: Past, Present and Future.</title><link>http://msmvps.com/blogs/bill/archive/2008/12/30/xsd-s-in-visual-studio-past-present-and-future.aspx</link><pubDate>Tue, 30 Dec 2008 02:51:36 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1658055</guid><dc:creator>bill</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1658055</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/12/30/xsd-s-in-visual-studio-past-present-and-future.aspx#comments</comments><description>&amp;#160; &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;When I was going through the &lt;a href="http://www.codeplex.com/SnippetEditor" target="_blank"&gt;snippet editor&lt;/a&gt; code to put it on CodePlex, I wanted to grab a screen shot of the snippet schema.&amp;#160; immediately I was confronted with there being no visual designer for schemas in VS 2008, but the worse part was I could have sworn there use to be.&amp;#160; To clear up that confusion here’s an illustrated history lesson on schema views in Visual Studio.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In earlier versions of Visual Studio the schema designer was a bit like the early dataset designer. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;This is Visual Studio 2005 :&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill/xsd2005_5F00_xFBMIA.png"&gt;&lt;img title="xsd2005" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="452" alt="xsd2005" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill/xsd2005_5F00_thumb_5F00_hm6h7A.png" width="620" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;It was detailed as far as types and constraints goes but omitted documentation.&amp;#160; With complex schemas it was a mess, but you could hide parts.&lt;/p&gt;  &lt;p&gt;Then in Visual Studio 2008 they decided to get rid of the schema designer completely !!&amp;#160; I’m really not sure the logic on that. There was however a CTP for the new Schema Explorer, and come Visual Studio 2008 Service Pack 1, the schema explorer was included.&amp;#160; (I hope I’ve got that bit of history right)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill/xsd2008_5F00_B1PwJQ.png"&gt;&lt;img title="xsd2008" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="356" alt="xsd2008" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill/xsd2008_5F00_thumb_5F00_sG0GEQ.png" width="358" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The Schema explorer gives a nice overview, and provides for navigation but totally lacks real details (&lt;strong&gt;not&lt;/strong&gt; synchronized with the properties window).&amp;#160; Sadly for Visual Studio 2008 that’s as best as it gets, the rest is wading through the actual xsd file as xml.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The first CTP of Visual Studio 10, reveals a new designer that can be used in conjunction with the Schema Explorer.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill/xsd2010_5F00_n4et6w.png"&gt;&lt;img title="xsd2010" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="476" alt="xsd2010" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill/xsd2010_5F00_thumb_5F00_WZK35w.png" width="571" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This pretty visual representation is all done in WPF so you can zoom in and out nicely. As well as the ability to easily expand and shrink elements, it’s really nice way to get an overview.&amp;#160; You can even turn on documentation so as you can see any comments from the schema:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill/xsd2010_5F00_with_5F00_doc_5F00_FMtFMw.png"&gt;&lt;img title="xsd2010_with_doc" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="409" alt="xsd2010_with_doc" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill/xsd2010_5F00_with_5F00_doc_5F00_thumb_5F00_2wIj9w.png" width="592" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Although this is very pretty, and a great visual aid, it still doesn’t provide any means to create a schema or edit one… it’s simply a view.&amp;#160;&amp;#160; Some things I’d like to see improved are :&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Provide designer &lt;strong&gt;editing&lt;/strong&gt; and creation of schemas&amp;#160; &lt;/li&gt;    &lt;li&gt;have an export to .png feature &lt;/li&gt;    &lt;li&gt;Ability to fully expand comments for all items.&amp;#160; At present only the first two lines are shown and you have to double click on each element to get the comments to fully expand &lt;/li&gt;    &lt;li&gt;did I mention &lt;strong&gt;editing&lt;/strong&gt; ? &lt;/li&gt;    &lt;li&gt;tear-offs would be nice, such that I could then use the width of the screen (eg: Drag the “Header” element from the above picture to the right, and then it expands over there rather than in situ.) &lt;/li&gt;    &lt;li&gt;show restrictions. For example, the SnippetType is restricted to three possible legal values, “Expansion”, “SurroundsWith” and “Refactoring”.&amp;#160; To find that out I have to delve into the xsd. &lt;/li&gt;    &lt;li&gt;Synchronise with Properties window allowing for more detail to be shown and edited in the Properties window&lt;/li&gt;    &lt;li&gt;Provide Copy as Path. The bottom of the screen shows the path of the selected node, but it would be great if you could select to copy that to the clipboard as an XPath. Even cooler if you could choose between XPath, VB XML Axis/Literal sytnax, or XElement syntax (for those poor ol’ C# folks ;) )&lt;/li&gt;    &lt;li&gt;&amp;#160; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The Visual Studio 10 stuff looks promising, but still has a long way to go. (did I mention the lack of &lt;strong&gt;editing&lt;/strong&gt; ?)&amp;#160; In the interim it would be nice if there was &lt;strong&gt;&lt;em&gt;something&lt;/em&gt;&lt;/strong&gt;, &lt;em&gt;&lt;strong&gt;anything&lt;/strong&gt;&lt;/em&gt; !&amp;#160; I’m really not sure why the 2005 xsd designer was dropped. Sure some of it was ugly, especially the way it shows things like the string restrictions, but it was and is less ugly than the XML for&amp;#160; that part of the xsd !!&lt;/p&gt;  &lt;p&gt;Visually we have progressed... but what about the &lt;strong&gt;editing&lt;/strong&gt; ??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1658055" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Whidbey/default.aspx">Whidbey</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Snippets/default.aspx">Snippets</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/XML/default.aspx">XML</category></item><item><title>Snippet Editor is now on CodePlex</title><link>http://msmvps.com/blogs/bill/archive/2008/12/28/snippet-editor-is-now-on-codeplex.aspx</link><pubDate>Sun, 28 Dec 2008 09:13:22 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1657880</guid><dc:creator>bill</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1657880</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/12/28/snippet-editor-is-now-on-codeplex.aspx#comments</comments><description>&lt;p&gt;I’ve just finished uploading the Snippet Editor to CodePlex&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.codeplex.com/SnippetEditor" href="http://www.codeplex.com/SnippetEditor"&gt;http://www.codeplex.com/SnippetEditor&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It includes some minor bug fixes from the previous release.&lt;/p&gt;  &lt;p&gt;Enjoy :)&lt;/p&gt;  &lt;p&gt;And Merry XMas :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1657880" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Whidbey/default.aspx">Whidbey</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Snippets/default.aspx">Snippets</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category></item><item><title>List transactions</title><link>http://msmvps.com/blogs/bill/archive/2008/12/19/list-transactions.aspx</link><pubDate>Thu, 18 Dec 2008 14:55:53 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1657126</guid><dc:creator>bill</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1657126</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/12/19/list-transactions.aspx#comments</comments><description>&lt;p&gt;From a recent discussion on using lists, and whether or not you can remove items in while iterating, I decided to write an extension that allows you to get a “transaction” for an IList(Of t).&amp;#160; This ListTransaction(Of T) caches adds and removes until you call commit (kudos to Duncan for the idea !!).&amp;#160; It also implements IDisposable so you can use a using scope, eg:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="font-size:11pt;background:#f0f4f2;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Using&lt;/span&gt; listTran = mylist.GetTransaction&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;For&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Each&lt;/span&gt; item &lt;span style="color:#3092b1;"&gt;In&lt;/span&gt; mylist&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39; other code here&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; listTran.Remove(item)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Next&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Using&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;And here’s the implementation:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="font-size:11pt;background:#f0f4f2;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;Module&lt;/span&gt; ListExtensions&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &amp;lt;Runtime.CompilerServices.Extension()&amp;gt; _&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt; GetTransaction(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; list &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; IList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)) &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; ListTransaction(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Return&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; ListTransaction(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)(list)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Class&lt;/span&gt; ListTransaction(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Implements&lt;/span&gt; IDisposable&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Private&lt;/span&gt; _list &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; IList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Private&lt;/span&gt; _adds &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; List(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Private&lt;/span&gt; _removes &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; List(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt;(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; list &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; IList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T))&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _list = list&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; Add(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; item &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; T)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt; _adds &lt;span style="color:#3092b1;"&gt;Is&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Then&lt;/span&gt; _adds = &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; List(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _adds.Add(item)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; Remove(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; item &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; T)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt; _removes &lt;span style="color:#3092b1;"&gt;Is&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Then&lt;/span&gt; _removes = &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; List(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _removes.Add(item)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; Commit()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt; _list &lt;span style="color:#3092b1;"&gt;Is&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Then&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Exit&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt; _adds &lt;span style="color:#3092b1;"&gt;IsNot&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Then&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;For&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Each&lt;/span&gt; item &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; T &lt;span style="color:#3092b1;"&gt;In&lt;/span&gt; _adds&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _list.Add(item)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Next&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _adds = &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt; _removes &lt;span style="color:#3092b1;"&gt;IsNot&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Then&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;For&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Each&lt;/span&gt; item &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; T &lt;span style="color:#3092b1;"&gt;In&lt;/span&gt; _removes&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _list.Remove(item)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Next&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _removes = &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; Rollback()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _adds = &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _removes = &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; Dispose() &lt;span style="color:#3092b1;"&gt;Implements&lt;/span&gt; IDisposable.Dispose&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Commit()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; GC.SuppressFinalize(&lt;span style="color:#3092b1;"&gt;Me&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Class&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Module&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1657126" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category></item><item><title>VB Snippet Editor</title><link>http://msmvps.com/blogs/bill/archive/2008/12/08/vb-snippet-editor.aspx</link><pubDate>Mon, 08 Dec 2008 11:42:02 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1656158</guid><dc:creator>bill</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1656158</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/12/08/vb-snippet-editor.aspx#comments</comments><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;Over the last week I’ve got a sudden influx of emails about the Snippet Editor.&amp;#160; I’m figuring this is stemming from &lt;a href="http://blogs.msdn.com/vbteam/archive/2008/12/07/did-you-know-there-are-many-ways-to-insert-a-snippet-into-your-code-lisa-feigenbaum.aspx" target="_blank"&gt;Lisa’s recent blog entry&lt;/a&gt; and her &lt;a href="http://blogs.msdn.com/vbteam/archive/2008/12/06/video-microsoft-visual-basic-2008-tips-and-tricks-lisa-feigenbaum.aspx" target="_blank"&gt;tips and trips for VS 2008 presentation&lt;/a&gt; :)&amp;#160; &lt;/p&gt;  &lt;p&gt;Some of the emails have been really nice praise, folks wanting to add some features, a bug on XP 64 (which unfortunately is about the only OS I don’t have in my testing suite), and some general questions around snippets.&amp;#160; So I gave this lots of thought and decided to put up a site on CodePlex. This will allow people to add features, work together on bugs, and share discussions around snippets including future directions for the snippet editor.&lt;/p&gt;  &lt;p&gt;The new codeplex site will be at &lt;a title="http://www.codeplex.com/SnippetEditor" href="http://www.codeplex.com/SnippetEditor"&gt;http://www.codeplex.com/SnippetEditor&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It’s not ready yet, and will probably be a week while I get all the bits together and ensure there’s no rude words in the code comments etc ;)&amp;#160; I was hesitant about moving to CodePlex as I was really disappointed how gotdotnet was just closed down and not migrated. And I should add here a word of caution for those in charge should CodePlex go a similar route.. I will travel the continents and track you down and when I find you stare at you for a really long time until you feel uncomfortable !!&amp;#160; ;)&amp;#160; (Seriously, please don’t close codeplex)&lt;/p&gt;  &lt;p&gt;So, all going well, the Snippet Editor will be on CodePlex this time next week.&amp;#160; I’ll make sure to post when it’s ready and redirect my current site there.&amp;#160; Any suggestions on the open&amp;#160; source license eula etc most welcome.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1656158" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Whidbey/default.aspx">Whidbey</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Snippets/default.aspx">Snippets</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category></item><item><title>What does VB 10 have ?</title><link>http://msmvps.com/blogs/bill/archive/2008/11/12/what-does-vb-10-have.aspx</link><pubDate>Wed, 12 Nov 2008 01:18:10 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1653804</guid><dc:creator>bill</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1653804</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/11/12/what-does-vb-10-have.aspx#comments</comments><description>&lt;p&gt;To answer what is in VB 10, have a &lt;a href="http://code.msdn.microsoft.com/vbfuture" target="_blank"&gt;look at the document on the vb futures site&lt;/a&gt;.&amp;#160; Basically the list is removal for the need of the line continuation character in many places, collection and array initializers, multi statement lambdas, and generic variance.&lt;/p&gt;  &lt;p&gt;I decided to look back at my brief wish lists for VB10&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/05/vb-10-thoughts.aspx" target="_blank"&gt;VB 10 thoughts Part 1&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/05/vb-10-thoughts-part-2.aspx" target="_blank"&gt;VB 10 thoughts Part 2&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/06/vb-10-thoughts-part-3.aspx" target="_blank"&gt;VB 10 thoughts Part 3&lt;/a&gt;&amp;#160; &lt;br /&gt;&lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/09/vb-10-thoughts-part-4.aspx" target="_blank"&gt;VB 10 thoughts Part 4&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/10/vb-10-thoughts-part-5.aspx" target="_blank"&gt;VB 10 thoughts Part 5&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/11/vb-10-thoughts-part-6.aspx" target="_blank"&gt;VB 10 thoughts Part 6&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/12/vb-10-thoughts-part-7.aspx" target="_blank"&gt;VB 10 thoughts Part 7&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/12/vb-10-thoughts-part-8.aspx" target="_blank"&gt;VB 10 thoughts Part 8&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/16/vb-10-thoughts-part-9.aspx" target="_blank"&gt;VB 10 thoughts Part 9&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Seems I did very poorly.&amp;#160; The only match I got was &lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/05/vb-10-thoughts.aspx" target="_blank"&gt;number 6&lt;/a&gt; multi statement lambdas. I should have had generic variance in the list considering that’s something I wanted since I first saw .NET generics&amp;#160; although that really is a framework thing not a language thing. The continuation character, collection and array initializers all seem nice, but functionally trivial to void.&amp;#160; Ironically, C#. which has many of those things on my list also picked up a couple it didn’t such as dynamic and they implemented optional parameters as they should be.&amp;#160; I must admit that hurts, especially as the optional parameters issues was &lt;a href="http://msmvps.com/blogs/bill/archive/2007/10/05/vb-10-thoughts.aspx" target="_blank"&gt;my #1&lt;/a&gt; item.&lt;/p&gt;  &lt;p&gt;For some reason in this new era of supposed language parity, I feel short changed :(&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1653804" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category></item><item><title>Making tuples more friendly</title><link>http://msmvps.com/blogs/bill/archive/2008/09/09/making-tuples-more-friendly.aspx</link><pubDate>Mon, 08 Sep 2008 13:30:19 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1647130</guid><dc:creator>bill</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1647130</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/09/09/making-tuples-more-friendly.aspx#comments</comments><description>&lt;p&gt;Via &lt;a href="http://www.pluralsight.com/community/blogs/dbox/archive/2008/09/07/managed-extensibility-framework-mef-now-with-source-code.aspx" target="_blank"&gt;Don Box’s blog&lt;/a&gt;, I found the preliminary code for &lt;a href="http://www.codeplex.com/MEF/SourceControl/FileView.aspx?itemId=336631&amp;amp;changeSetId=23846" target="_blank"&gt;a tuple at CodePlex&lt;/a&gt;. The tuple is a simple structure containing in this case two values: a double tuple.&amp;#160; It basically looks like this :&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;blockquote&gt;   &lt;div style="font-size:11pt;background:white;color:black;font-family:consolas;"&gt;     &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;Structure&lt;/span&gt; Tuple(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; TFirst, TSecond)&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Property&lt;/span&gt; First() &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; TFirst&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Property&lt;/span&gt; Second() &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; TSecond&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160; &lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Structure&lt;/span&gt;&lt;/p&gt;   &lt;/div&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;I’ve omitted the details, such as the constructor or equality overloads and operators etc.&amp;#160; &lt;/p&gt;  &lt;p&gt;So Tuple’s can be handy general purpose storage to pass around a couple of values.&amp;#160; Let’s say I write a Parse method such as :&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="font-size:11pt;background:white;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt; Parse(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; value &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;String&lt;/span&gt;) &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; Tuple(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; Int32, &lt;span style="color:#3092b1;"&gt;Boolean&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; iVal &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; Int32&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; success = Int32.TryParse(value, iVal)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Return&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; Tuple(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; Int32, &lt;span style="color:#3092b1;"&gt;Boolean&lt;/span&gt;)(iVal, success)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;That makes it a little easier for calling code to parse a string to an int32, but the problem they then face is the values are First and Second. For example:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="font-size:11pt;background:white;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; tuple = Parse(&lt;span style="background:#feffea;color:#a31515;"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; i? = &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt;(tuple.Second, tuple.First, &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt;)&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Wouldn’t it be nicer if that could be written as :&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="font-size:11pt;background:white;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; tuple = Parse(&lt;span style="background:#feffea;color:#a31515;"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; i? = &lt;span style="color:#3092b1;"&gt;If&lt;/span&gt;(tuple.Success, tuple.Value, &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt;)&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Sure you could write your own structure for this, but then we are back to type bloat.&amp;#160; That level of detail, Success and Value are only needed at design time, so they could be compiler magic based on XML comments.&amp;#160; Perhaps something like this on my Parse method would make the tuple parameters appear as Success and Value instead of First and Second :&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;div style="font-size:11pt;background:white;color:black;font-family:consolas;"&gt;     &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; A Parse wrapper for string to integer&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;param name=&amp;quot;value&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="background:#e6ffe6;color:green;"&gt;a string representation of an integer value&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;tuple&amp;gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;First name=&amp;quot;Value&amp;quot;&amp;gt;&lt;span style="background:#e6ffe6;color:green;"&gt;the integer value or 0 if the parse fails&lt;/span&gt;&amp;lt;/First&amp;gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;Second name=&amp;quot;Success&amp;quot;&amp;gt;&lt;span style="background:#e6ffe6;color:green;"&gt;true if the parse succeeds, otherwise false&lt;/span&gt;&amp;lt;/Second&amp;gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/tuple&amp;gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="background:#e6ffe6;color:green;"&gt;&amp;#39;&amp;#39;&amp;#39; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt; Parse(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; value &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;String&lt;/span&gt;) &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; Tuple(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; Int32, &lt;span style="color:#3092b1;"&gt;Boolean&lt;/span&gt;)&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; iVal &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; Int32&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; success = Int32.TryParse(value, iVal)&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Return&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; Tuple(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; Int32, &lt;span style="color:#3092b1;"&gt;Boolean&lt;/span&gt;)(iVal, success)&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt;&lt;/p&gt;   &lt;/div&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The down side of this is it would only work with the immediate assignment, and one could argue only when it is used with type inference (as I did above).&amp;#160; I doubt the cost justifies the benefit, but imagine the fun you could have if it was a cooking tuple: you could have a double Tuple with Boil and Bubble&lt;/p&gt;  &lt;p&gt;(I can’t believe I left that last line in here ;) )&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1647130" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Unsubscribing events: How VB Handles it</title><link>http://msmvps.com/blogs/bill/archive/2008/08/21/unsubscribing-events-how-vb-handles-it.aspx</link><pubDate>Thu, 21 Aug 2008 11:40:39 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1645354</guid><dc:creator>bill</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1645354</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/08/21/unsubscribing-events-how-vb-handles-it.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://davybrion.com/blog/2008/08/why-you-should-always-unscubscribe-event-handlers/" target="_blank"&gt;Davy Brion posted&lt;/a&gt; about how events can keep object references alive.&amp;#160; In C# to rid yourself of this issue you have to manually unwire any event handler you wired.&amp;#160; In VB, it is a lot easier, all you have to do is use WithEvents and set the variable to nothing. This code is the VB version of Davy’s sample:&lt;/p&gt;  &lt;div style="font-size:11pt;background:white;color:black;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Class&lt;/span&gt; Publisher&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Event&lt;/span&gt; MyEvent &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; EventHandler&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; FireEvent()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;RaiseEvent&lt;/span&gt; MyEvent(&lt;span style="color:#3092b1;"&gt;Me&lt;/span&gt;, EventArgs.Empty)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Class&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Class&lt;/span&gt; GoodSubscriber&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Implements&lt;/span&gt; IDisposable&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Private&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;WithEvents&lt;/span&gt; _publisher &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; Publisher&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt;(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; publisher &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; Publisher)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _publisher = publisher&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Private&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; _publisher_MyEvent(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Object&lt;/span&gt;, &lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color:#3092b1;"&gt;Handles&lt;/span&gt; _publisher.MyEvent&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&lt;span style="background:#feffea;color:#a31515;"&gt;&amp;quot;the publisher notified the good subscriber of an event&amp;quot;&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; Dispose() &lt;span style="color:#3092b1;"&gt;Implements&lt;/span&gt; IDisposable.Dispose&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _publisher = &lt;span style="color:#3092b1;"&gt;Nothing&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Class&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;As long as the variable is declared as WithEvents any event wired up via declarative event handling will be unwired when the variable is set to Nothing.&lt;/p&gt;  &lt;p&gt;This is yet another subtle but important example of how declarative coding styles can lead to more robust code.&amp;#160; The above example is minimal, but when you get many events and many objects raising events, the cleanness of the VB way of handling it becomes even more important.&amp;#160; Or in other words in C# you have to make sure you unwire each and every event, in VB you use declarative events syntax and VB handles it for you ;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1645354" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category></item><item><title>WPF Toolkit on CodePlex</title><link>http://msmvps.com/blogs/bill/archive/2008/08/19/wpf-toolkit-on-codeplex.aspx</link><pubDate>Mon, 18 Aug 2008 15:44:15 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1644942</guid><dc:creator>bill</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1644942</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/08/19/wpf-toolkit-on-codeplex.aspx#comments</comments><description>&lt;p&gt;In case you haven’t seen it, Microsoft is releasing tools for WPF out of cycle as part of the &lt;a href="http://www.codeplex.com/wpf/Wiki/View.aspx?title=Toolkit%20Roadmap&amp;amp;referringTitle=Home" target="_blank"&gt;WPF toolkit&lt;/a&gt;. Current release includes a CTP of a Data Grid, and a Date Picker and Calendar is planned.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1644942" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Generic Variance Part1 : Do you really need it ?</title><link>http://msmvps.com/blogs/bill/archive/2008/08/11/generic-variance-part1-do-you-really-need-it.aspx</link><pubDate>Mon, 11 Aug 2008 03:21:25 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1644183</guid><dc:creator>bill</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1644183</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/08/11/generic-variance-part1-do-you-really-need-it.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/vbteam/archive/2008/08/07/co-and-contra-variance-lucian-wischik.aspx" target="_blank"&gt;Lucian has kicked off the conversation on generic variance in VB&lt;/a&gt; , so I thought I’d write a few posts outlining my perspectives on the subject… the first of which is this one, and what better place to start than to question whether or not it is really needed……&lt;/p&gt; &lt;p&gt;Generics came to .NET &lt;strong&gt;&lt;em&gt;after&lt;/em&gt;&lt;/strong&gt; the base framework and languages were implemented.&amp;nbsp; It was very much a bolt-on approach.&amp;nbsp; As such there was and still is an impedance mismatch between conventional concepts of polymorphism and generics. &lt;a href="http://msmvps.com/blogs/bill/archive/2007/11/05/oh-so-you-want-polymorphism.aspx" target="_blank"&gt;As I posted previously&lt;/a&gt;, I had raised this is issue with Anders and other language experts back at the 2003 PDC (at which time Anders suggested using a language other than VB or C# &amp;lt;g&amp;gt;). Fast forward to today, and this issue is now being looked at, but now I find myself questioning if it is really needed, or is the fault the mismatch of the original framework.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Let’s take Lucian’s example :&lt;/p&gt; &lt;p&gt;Dim args As New List(Of ConstantExpression)&lt;br /&gt;args.Add(Expression.Constant(2))&lt;br /&gt;args.Add(Expression.Constant(3))&lt;br /&gt;Dim y = Expression.Call(instance, method, &lt;u&gt;&lt;strong&gt;args&lt;/strong&gt;&lt;/u&gt;) &lt;p&gt;&amp;nbsp; &lt;p&gt;This code fails because the Call method is defined as : &lt;p&gt;&amp;nbsp; &lt;div style="font-size:11pt;background:white;color:black;font-family:consolas;"&gt;&lt;pre style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Shared&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt; [Call](&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; instance &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; Expression, _&lt;/pre&gt;&lt;pre style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; method &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; MethodInfo, _&lt;/pre&gt;&lt;pre style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; arguments &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; IEnumerable(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; Expression)) _&lt;/pre&gt;&lt;pre style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; MethodCallExpression&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp; &lt;p&gt;But if it was defined as follows then the code would work:
&lt;p&gt;&amp;nbsp; &lt;div style="font-size:11pt;background:white;color:black;font-family:consolas;"&gt;&lt;pre style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Shared&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt; [Call](&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; Expression) _&lt;/pre&gt;&lt;pre style="margin:0px;"&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;&amp;nbsp;&amp;nbsp; (&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; instance &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; Expression, _&lt;/pre&gt;&lt;pre style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; method &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; MethodInfo, _&lt;/pre&gt;&lt;pre style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; arguments &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; IEnumerable(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)) _&lt;/pre&gt;&lt;pre style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; MethodCallExpression&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="font-size:11pt;background:white;color:black;font-family:consolas;"&gt;&lt;pre style="margin:0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So where exactly is the problem ?&amp;nbsp; The simple rule is if you want polymorphism (read as “generic variance”) in your code, then you need to expose the types as generic parameters not as concrete types.&lt;/p&gt;
&lt;p&gt;That is, the above is solved by better API design and some simple refactoring.&amp;nbsp; This in fact solves 90% or more of all the cases I have seen.&amp;nbsp; The one place where you can’t do this is when the type is late bound and defined only as Object (more on this in a future post no doubt ;))&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1644183" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category></item></channel></rss>