<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.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>Cool Client Stuff : .NET - Random Tips</title><link>http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx</link><description>Tags: .NET - Random Tips</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Why doesn't my TypeConverter get called?</title><link>http://blogs.msdn.com/rprabhu/archive/2005/04/25/411615.aspx</link><pubDate>Mon, 25 Apr 2005 11:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:411615</guid><dc:creator>rprabhu</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/411615.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=411615</wfw:commentRss><description>&lt;P&gt;Consider the following code:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;
&lt;P dir=ltr&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;MyControl&lt;/FONT&gt;&lt;FONT size=2&gt; : Control { &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE dir=ltr&gt;
&lt;BLOCKQUOTE dir=ltr&gt;
&lt;P dir=ltr&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;TypeConverter&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;typeof&lt;/FONT&gt;&lt;FONT size=2&gt;(SomePropertyConverter))]&lt;/FONT&gt; &lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Foo&lt;/FONT&gt;&lt;FONT size=2&gt; SomeProperty { &lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; { ... } &lt;BR&gt;} &lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;&lt;FONT face="Courier New"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE dir=ltr&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;[&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#008080 size=2&gt;TypeConverter&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;typeof&lt;/FONT&gt;&lt;FONT size=2&gt;(FooConverter))] &lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Foo &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;{ &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;BR&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;Now here are a couple of questions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV&gt;Let's say both SomePropertyConverter and FooConverter implement conversion to and from String, given an instance of Foo. If I drop MyControl on a Form designer and try to edit SomeProperty in the property grid, which TypeConverter will get called?&lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV&gt;Let's say both SomePropertyConverter and FooConverter implement conversion to &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldesignserializationinstancedescriptorclasstopic.asp"&gt;InstanceDescriptor&lt;/A&gt;, given an instance of Foo. The intention&amp;nbsp;is to control how an object of type Foo gets serialized to code.&amp;nbsp;Which TypeConverter will get called?&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The answer to question 1 is SomePropertyConverter. This is because the property grid will query the TypeConverter off the PropertyDescriptor for SomeProperty. The converter look up for properties gives precedence to TypeConverters attached to the property itself over the TypeConverter attached to the object or type. This allows a class like MyControl to&amp;nbsp;control the behavior of the type Foo in the property grid, as related to SomeProperty.&lt;/P&gt;
&lt;P&gt;What about question 2? One might expect the behavior to be consistent with 1. Well, no, it is not - the correct answer is FooConverter. This is because the serialization code queries the TypeConverter off the object or type itself, not off the PropertyDescriptor.&lt;/P&gt;
&lt;P&gt;It is not immediately obvious why this is the case, and many people wonder if this 'inconsistency'&amp;nbsp;is a bug in the component model. No, it is actually by design. To understand this, let's assume for a moment that the serializer &lt;EM&gt;did&lt;/EM&gt; query the TypeConverter off the PropertyDescriptor. What would happen if the same instance of Foo is assigned to several different properties, each of which had their own TypeConverters specified? How then would the serializer know which TypeConverter to pick? After all, the object itself can be serialized in only one way. It is to avoid such ambiguities that type serializers ignore TypeConverters (and certain other metadata) attached to properties in determining how to serialize objects. This is also why the DesignerSerializerAttribute can only be applied to types, not to properties.&lt;/P&gt;
&lt;P&gt;Note that this doesn't mean MyControl doesn't have a say in the serialization of SomeProperty. As I have explained in an &lt;a href="http://blogs.msdn.com/rprabhu/archive/2005/03/16/396621.aspx"&gt;earlier post&lt;/A&gt;, there are several ways it can control how the property itself is serialized. Note that there is a distinction between &lt;EM&gt;type&lt;/EM&gt; serializers and &lt;EM&gt;member&lt;/EM&gt; serializers. This distinction is made clear in Whidbey by bifurcating the CodeDomSerializer class hierarchy into two base classes, called &lt;A href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/winfx/ref/ns/system.componentmodel.design.serialization/c/typecodedomserializer/typecodedomserializer.asp"&gt;TypeCodeDomSerializer&lt;/A&gt; and &lt;A href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/winfx/ref/ns/system.componentmodel.design.serialization/c/membercodedomserializer/membercodedomserializer.asp"&gt;MemberCodeDomSerializer&lt;/A&gt;, both of which derive from a common base class called &lt;A href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/winfx/ref/ns/system.componentmodel.design.serialization/c/codedomserializerbase/codedomserializerbase.asp"&gt;CodeDomSerializerBase&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=411615" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category><category domain="http://blogs.msdn.com/rprabhu/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Do you really need a custom CodeDomSerializer?</title><link>http://blogs.msdn.com/rprabhu/archive/2005/03/16/396621.aspx</link><pubDate>Wed, 16 Mar 2005 09:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:396621</guid><dc:creator>rprabhu</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/396621.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=396621</wfw:commentRss><description>&lt;p&gt;When you author a new component for .NET for which you want to offer a smooth user experience within the Visual Studio designers, you may find you need to write a few more classes to get it working the way you want. For example, you may need to write a designer for it to customize how it looks and behaves at design time. You&amp;nbsp;may need to write TypeConverters for new types that you add, so that, among other things, they can be configured from the property grid. Maybe you will need to write a UITypeEditor.&lt;/p&gt; &lt;p&gt;Sometimes, you may feel you need to write a custom &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldesignserializationcodedomserializerclasstopic.asp"&gt;CodeDomSerializer&lt;/a&gt; for the component too. Now, the CodeDomSerializer class hierarchy is definitely designed to be extensible and customizable. In fact, in Whidbey, we have refactored this class hierarchy a bit to expose more common functionality you may need in your custom serializer.&lt;/p&gt; &lt;p&gt;However, before you start writing a custom CodeDomSerializer, you should ask yourself this question: do I &lt;em&gt;really &lt;/em&gt;need a custom CodeDomSerializer? After all, very very few of the built in controls and components in Windows Forms have their own custom serializers. Even for the 2-3 components&amp;nbsp;that do, they mostly do only a few lines&amp;nbsp;of work and delegate the rest to the base serializers.&lt;/p&gt; &lt;p&gt;Let me first explain why I believe you should think twice&amp;nbsp;before writing a custom CodeDomSerializer:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;You may not need it in the first place.&amp;nbsp;I will describe below some ways in which&amp;nbsp;you can customize code generation without writing a custom serializer.&lt;/li&gt; &lt;li&gt;Writing a well behaved custom serializer is not trivial. There are many things you need to be careful about. For example, what happens when your component is placed on a Localizable Form? What about if it is in a collection or array? What if someone derives from it and configures some metadata differently? Does your serializer work fine when invoked in a different context than normal code generation - like for undo/redo (in Whidbey)?&lt;/li&gt; &lt;li&gt;What if your component is hosted in a design time environment that doesn't use CodeDom at all? For example, the component may be hosted on a DesignSurface that has a DesignerLoader that uses an xml based serialization scheme&amp;nbsp;(like Xaml). Your custom CodeDomSerializer will not work in this situation, and serialization may not happen as you expect it to.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;How then do you customize code generation? Well, it is mostly through the use of metadata. Here are a few possibilities:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemComponentModelDesignerSerializationVisibilityAttributeClassTopic.asp"&gt;DesignerSerializationVisibilityAttribute&lt;/a&gt; helps you hide properties that you don't want serialized from the serializer and also&amp;nbsp;tell it not to serialize the value, but only its content (typically useful for collections).&lt;/li&gt; &lt;li&gt;The &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldefaultvalueattributeclasstopic.asp"&gt;DefaultValueAttribute&lt;/a&gt; and ShouldSerializeBlah methods (where&amp;nbsp;'Blah' is the name of a property) help control under what conditions to serialize a particular property.&lt;/li&gt; &lt;li&gt;The &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemComponentModelLocalizableAttributeClassTopic.asp"&gt;LocalizableAttribute&lt;/a&gt; controls whether a property is serialized into code or into the resource file when the component is on a Localizable Form.&lt;/li&gt; &lt;li&gt;The &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldesignonlyattributeclasstopic.asp"&gt;DesignOnlyAttribute&lt;/a&gt;, as the name suggests, can be applied to properties that are only meaningful at design time and don't need to be serialized as runtime property sets.&lt;/li&gt; &lt;li&gt;You can write a &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeltypeconverterclasstopic.asp"&gt;TypeConverter&lt;/a&gt; for your component (or any new type you have authored) that knows how to convert to &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldesignserializationinstancedescriptorclasstopic.asp"&gt;InstanceDescriptor&lt;/a&gt; to control how objects of the type are instantiated by the serializer.&lt;/li&gt; &lt;li&gt;You can also control how objects are serialized into resx files by writing a TypeConverter that can convert to and from string, for example.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Now, I do understand there are legitimate scenarios where you will need to implement custom CodeDomSerializers, and this post is not meant to discourage doing so (in fact, as I said, we have made it easier in Whidbey to write these). However, before you implement one, just remember to consider the issues and suggestions mentioned here. I repeat: for our own components, we have extremely few that implement custom serialization and when they do, the serializer is&amp;nbsp;only a few lines of code&amp;nbsp;and lets the base serializer do most of the work.&lt;/p&gt; &lt;p&gt;See also &lt;A href="http://blogs.msdn.com/rprabhu/archive/2004/02/03/66560.aspx"&gt;this post&lt;/a&gt; that explains some serialization rules. If you are new to this topic, you will find this excellent &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/custcodegen.asp?frame=true"&gt;article&lt;/a&gt; by Shawn Burke very useful.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=396621" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category><category domain="http://blogs.msdn.com/rprabhu/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Win32 &lt;-&gt; .NET API Mapping</title><link>http://blogs.msdn.com/rprabhu/archive/2005/02/15/372845.aspx</link><pubDate>Tue, 15 Feb 2005 08:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:372845</guid><dc:creator>rprabhu</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/372845.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=372845</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://msdn.microsoft.com/netframework/programming/interop/default.aspx?pull=/library/en-us/dndotnet/html/win32map.asp"&gt;This&lt;/a&gt; is another of those links that you simply must add to your favorites if you develop using .NET. This&amp;nbsp;page tells you when&amp;nbsp;&lt;em&gt;not&lt;/em&gt;&amp;nbsp;to use that other very&amp;nbsp;handy website -&amp;nbsp;&lt;a href="http://www.pinvoke.net/"&gt;PInvoke.net&lt;/a&gt;. So before you go the p/invoke route, make sure there isn't already a .NET equivalent API available.&lt;/p&gt; &lt;p&gt;Someday, when you can do everything you want purely in managed code and everyone has forgotten Win32, these links will become irrelevant. But today, they are definitely useful!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=372845" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category></item><item><title>Smart Client in focus again</title><link>http://blogs.msdn.com/rprabhu/archive/2005/02/09/369712.aspx</link><pubDate>Wed, 09 Feb 2005 10:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:369712</guid><dc:creator>rprabhu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/369712.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=369712</wfw:commentRss><description>&lt;p&gt;Good to see that Soma's keynote at &lt;a href="http://www.ftponline.com/conferences/vslive/2005/sf/"&gt;VSLive! San Francisco&lt;/a&gt;&amp;nbsp;brings the concept of 'smart client' back in focus. This is something I am personally passionate about and it is also the&amp;nbsp;theme of this blog. &lt;A href="http://blogs.msdn.com/somasegar/archive/2005/02/06/368264.aspx"&gt;Here&lt;/a&gt; is Soma's blog post on the topic and you can view the keynote video &lt;a href="http://www.ftponline.com/reports/vslivesf/2005/multimedia/soma.asx"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Still not sure what a smart client is as opposed to a simple client application or a 'rich client'? I don't blame you - there are too many of these terms floating around. Believe it or not, 'smart client' isn't just a fancy new term for the same old thing - it is indeed a new kind of application model that attempts to combine the best of the client and web worlds.&amp;nbsp;Check out the &lt;a href="http://msdn.microsoft.com/smartclient/"&gt;Smart Client Developer Center&lt;/a&gt; on MSDN to understand exactly what smart client means.&lt;/p&gt; &lt;p&gt;With features like ClickOnce and Client Settings,&amp;nbsp;not to mention the very significant advances in Windows Forms, .NET Framework 2.0 is going to be a great platform for smart client application development!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=369712" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category><category domain="http://blogs.msdn.com/rprabhu/archive/tags/Whidbey/default.aspx">Whidbey</category></item><item><title>Windows Forms and Avalon roadmap</title><link>http://blogs.msdn.com/rprabhu/archive/2004/12/04/275175.aspx</link><pubDate>Sun, 05 Dec 2004 03:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:275175</guid><dc:creator>rprabhu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/275175.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=275175</wfw:commentRss><description>&lt;p&gt;If I am planning to write a Windows client application in the coming months, what technology should I target - Windows Forms or Avalon? This is a question that comes up every so often and results in a&amp;nbsp;lengthy debate, but no clear conclusion. In an attempt to clarify, John Montgomery has &lt;A href="http://blogs.msdn.com/johnmont/archive/2004/11/27/271026.aspx"&gt;posted&lt;/a&gt; a set of guidelines that have been reviewed by both teams. (via &lt;a href="http://www.sellsbrothers.com/news/showTopic.aspx?ixTopic=1607"&gt;Chris Sells&lt;/a&gt;)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=275175" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category><category domain="http://blogs.msdn.com/rprabhu/archive/tags/Windows+Vista/default.aspx">Windows Vista</category></item><item><title>Smart Client Developer Center reloaded</title><link>http://blogs.msdn.com/rprabhu/archive/2004/12/04/274918.aspx</link><pubDate>Sat, 04 Dec 2004 08:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:274918</guid><dc:creator>rprabhu</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/274918.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=274918</wfw:commentRss><description>&lt;p&gt;Check out the new and improved&amp;nbsp;&lt;a href="http://msdn.microsoft.com/smartClient/"&gt;MSDN Smart Client Developer Center&lt;/a&gt; page - it is a great place to start if you are looking for information about client application development. Jonathan, who is co-editor for the site with &lt;a href="http://www.sellsbrothers.com/"&gt;Chris Sells&lt;/a&gt;, has more information about it in his &lt;A href="http://blogs.msdn.com/onoj/archive/2004/12/03/274799.aspx"&gt;blog post&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=274918" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category></item><item><title>.NET Framework SPs now available on Windows Update</title><link>http://blogs.msdn.com/rprabhu/archive/2004/09/08/226876.aspx</link><pubDate>Wed, 08 Sep 2004 16:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226876</guid><dc:creator>rprabhu</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/226876.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=226876</wfw:commentRss><description>The final versions of .NET Framework 1.1 SP1 and 1.0 SP3 are now available for download on &lt;a href="http://windowsupdate.microsoft.com"&gt;Windows Update&lt;/a&gt;.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=226876" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/General/default.aspx">General</category><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category></item><item><title>.NET Framework SPs - Tech Preview announced</title><link>http://blogs.msdn.com/rprabhu/archive/2004/07/08/176288.aspx</link><pubDate>Thu, 08 Jul 2004 08:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:176288</guid><dc:creator>rprabhu</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/176288.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=176288</wfw:commentRss><description>Technical previews of .NET Framework 1.1 SP1 and 1.0 SP3 are out. You can find links to download, newsgroups and information about what's in the service packs &lt;A href="http://msdn.microsoft.com/netframework/downloads/updates/sptechpreview/default.aspx"&gt;here&lt;/A&gt;.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=176288" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category></item><item><title>Smart Client Developer Center</title><link>http://blogs.msdn.com/rprabhu/archive/2004/06/28/167613.aspx</link><pubDate>Mon, 28 Jun 2004 09:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:167613</guid><dc:creator>rprabhu</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/167613.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=167613</wfw:commentRss><description>&lt;P&gt;If you haven't seen it already,&amp;nbsp;check out&amp;nbsp;the &lt;A href="http://msdn.microsoft.com/smartclient/"&gt;Smart Client Developer Center&lt;/A&gt;&amp;nbsp;on MSDN launched earlier this month. It's a great place to start if you are looking for any kind of information relating to client application development. It also has an &lt;A href="http://msdn.microsoft.com/smartclient/rss.xml"&gt;RSS feed&lt;/A&gt;. &lt;A href="http://msdn.microsoft.com/smartclient/windowsforms/"&gt;Here&lt;/A&gt; is the Windows Forms section.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=167613" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/General/default.aspx">General</category><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category></item><item><title>Brian explains Components, Containers and Services</title><link>http://blogs.msdn.com/rprabhu/archive/2004/04/20/116594.aspx</link><pubDate>Tue, 20 Apr 2004 07:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:116594</guid><dc:creator>rprabhu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/116594.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=116594</wfw:commentRss><description>Brian &lt;A href="http://www.urbanpotato.net/default.aspx/document/969"&gt;blogs&lt;/A&gt; about the fundamental concepts of the .Net component model. The post is typical of Brian - his explanation is always crystal clear!&amp;nbsp;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=116594" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category><category domain="http://blogs.msdn.com/rprabhu/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>How to create non-rectangular Windows Forms applications</title><link>http://blogs.msdn.com/rprabhu/archive/2004/04/03/107214.aspx</link><pubDate>Sun, 04 Apr 2004 00:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:107214</guid><dc:creator>rprabhu</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/107214.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=107214</wfw:commentRss><description>Ever wanted to write an app with forms that have arbitrary shapes rather than the usual rectangular windows? Mike Harsh &lt;A href="http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20040401WinFormsMH/manifest.xml"&gt;describes&lt;/A&gt; on MSDN TV&amp;nbsp;how&amp;nbsp;you can accomplish this in Windows Forms, without writing a single line of code,&amp;nbsp;using the &lt;A href="http://windowsforms.net/articles/usingregionmastercontrols.aspx"&gt;RegionMaster&lt;/A&gt; controls available for download on &lt;A href="http://www.windowsforms.net/"&gt;WindowsForms.net&lt;/A&gt;.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=107214" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category></item><item><title>Why are the interop definitions in System.Windows.Forms internal?</title><link>http://blogs.msdn.com/rprabhu/archive/2004/03/25/96135.aspx</link><pubDate>Thu, 25 Mar 2004 16:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:96135</guid><dc:creator>rprabhu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/96135.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=96135</wfw:commentRss><description>&lt;P&gt;In a &lt;A href="http://blogs.msdn.com/brada/archive/2004/03/23/95039.aspx#96019"&gt;comment&lt;/A&gt; on BradA's blog, Chris wonders why Windows Forms didn't expose the structures and p/invoke declarations it uses for interop. This would have saved users from having to redefine them for their own use.&lt;/P&gt;
&lt;P&gt;I guess there were mainly two reasons:&lt;/P&gt;
&lt;P&gt;1) These declarations were put together&amp;nbsp;on an &amp;#8220;as necessary&amp;#8220; basis. Whenever we needed to call some Win32 API to implement a Windows Forms class, we added some p/invoke declarations. Obviously, the list isn't quite complete - there are many declarations you might need that aren't there. We didn't really want to expose an incomplete set of declarations.&lt;/P&gt;
&lt;P&gt;2) Since the declarations were added for internal use by Windows Forms, chances are we expose a managed way to accomplish&amp;nbsp;whatever you need the declarations for in the first place. So, in most cases, you will probably not find the p/invoke declarations you need in our set.&lt;/P&gt;
&lt;P&gt;That said, we do realize that defining p/invoke structures and functions can&amp;nbsp;be difficult to get right. The CLR team has put together a list of common Win32 definitions you may need.&amp;nbsp;You will find the link (and&amp;nbsp;many other useful resources)&amp;nbsp;&lt;A href="http://www.gotdotnet.com/team/clr/bcl/TechArticles/TechArticles/PInvokeHelp/FAQ.aspx"&gt;here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=96135" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category></item><item><title>Windows Forms Markup</title><link>http://blogs.msdn.com/rprabhu/archive/2004/03/08/86105.aspx</link><pubDate>Mon, 08 Mar 2004 20:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:86105</guid><dc:creator>rprabhu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/86105.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=86105</wfw:commentRss><description>&lt;P&gt;Check out Mike Harsh's&amp;nbsp;&lt;A href="http://blogs.msdn.com/mharsh/archive/2004/03/08/86052.aspx"&gt;post&lt;/A&gt;&amp;nbsp;about&amp;nbsp;Windows Forms Markup Language (WFML). The sample and &lt;A href="http://windowsforms.net/articles/wfml.aspx"&gt;article&lt;/A&gt; by Joe Stegman are up on &lt;A href="http://windowsforms.net/"&gt;windowsforms.net&lt;/A&gt;. Note that this is based on .Net Framework v1.1, so you can try&amp;nbsp;it out today!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=86105" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category></item><item><title>How does the designer decide what properties to persist on a given component?</title><link>http://blogs.msdn.com/rprabhu/archive/2004/02/03/66560.aspx</link><pubDate>Tue, 03 Feb 2004 09:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:66560</guid><dc:creator>rprabhu</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/66560.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=66560</wfw:commentRss><description>&lt;P&gt;Any component has a bunch of properties on it. For example, the WinForms Button control has properties like BackColor, ForeColor, Text, Name, BackgroundImage and so on. When you place a Button on the Form in the VisualStudio designer and look at the generated code, you will find only&amp;nbsp;a subset of the properties are persisted in code. Typically, these are the properties for which you explicitly set a value. What is the mechanism the designer uses to achieve this behavior?&lt;/P&gt;
&lt;P&gt;First of all, the object that controls this is the &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldesignserializationcodedomserializerclasstopic.asp"&gt;CodeDomSerializer&lt;/A&gt; associated with the component. It decides how the component should be&amp;nbsp;persisted to code. Here are some of the rules that the CodeDomSerializer associated with common controls&amp;nbsp;like Button uses (well, more accurately,&amp;nbsp;the serializer leaves the decision to the &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodelpropertydescriptorclasstopic.asp"&gt;PropertyDescriptor&lt;/A&gt; associated with the property and our implementation of the latter uses these rules):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If the property has a &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemComponentModelDesignerSerializationVisibilityAttributeClassTopic.asp"&gt;DesignerSerializationVisibilityAttribute&lt;/A&gt; attached to it, then the serializer will use it to decide whether to serialize or not (like Visible or Hidden), and how to serialize (Content).&lt;/LI&gt;
&lt;LI&gt;For a property called XXX, if the component implements a method called ShouldSerializeXXX, we make a late bound call to it to determine whether to serialize or not. For example, for BackColor, the method we look for will be called ShouldSerializeBackColor().&lt;/LI&gt;
&lt;LI&gt;If the property has a &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldefaultvalueattributeclasstopic.asp"&gt;DefaultValueAttribute&lt;/A&gt; specified, it is compared with the&amp;nbsp;current value&amp;nbsp;on the component. The property is serialized&amp;nbsp;only if the current value is non-default.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Further, the&amp;nbsp;designer associated with the component can also play a part in making this decision by &amp;#8220;shadowing&amp;#8220; properties or by implementing ShouldSerializeXXX methods.&lt;/P&gt;
&lt;P&gt;Not happy with this mechanism? Want to serialize your component in a different way? Sure! All you need&amp;nbsp;to do is write your own Serializer class that derives from CodeDomSerializer and associate it with your component using the &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldesignserializationdesignerserializerattributeclasstopic.asp"&gt;DesignerSerializerAttribute&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;By the way, Whidbey is not just about cool new controls, layout, configuration, improved visual styles support, better design time experience&amp;nbsp;etc. There are a ton of&amp;nbsp;improvements to the designer infrastructure too, as we mentioned briefly at the PDC:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;A new architecture that makes it much simpler to host designers&lt;/LI&gt;
&lt;LI&gt;Improvements to the localization model (I didn't mention above how Localizable properties get serialized - that's a topic for another time)&lt;/LI&gt;
&lt;LI&gt;A bunch of new classes that make it easier to write custom serializers&lt;/LI&gt;
&lt;LI&gt;A provider based model that makes it easier to plugin custom &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeltypedescriptorclasstopic.asp"&gt;type descriptors&lt;/A&gt;.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Some of these new classes are already documented at &lt;A href="http://longhorn.msdn.microsoft.com"&gt;http://longhorn.msdn.microsoft.com&lt;/A&gt;. Look under the System.ComponentModel.* and System.*.Design namespaces.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=66560" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category><category domain="http://blogs.msdn.com/rprabhu/archive/tags/Whidbey/default.aspx">Whidbey</category><category domain="http://blogs.msdn.com/rprabhu/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>On using Windows Forms controls as ActiveX controls</title><link>http://blogs.msdn.com/rprabhu/archive/2004/01/15/59142.aspx</link><pubDate>Thu, 15 Jan 2004 21:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:59142</guid><dc:creator>rprabhu</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/rprabhu/comments/59142.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rprabhu/commentrss.aspx?PostID=59142</wfw:commentRss><description>&lt;P&gt;&lt;EM&gt;[Update: Reformatted and edited the quote below]&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Here is a great summary by Mark Boulter (Tech Lead on .NET Client Team): &lt;/P&gt;
&lt;P&gt;To summarize our official position on using Windows Forms controls as ActiveX controls:&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN-LEFT: 0.5in"&gt;v1.0 of Windows Forms only supports using Windows Forms controls in Windows Forms and IE 5.x&lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN-LEFT: 0.5in"&gt;In v1.1 of the Framework we extended our hosting support to include using Windows Forms controls in MFC 7.x and up or any container that is fully compatible with the MFC 7.x ActiveX control container.&lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN-LEFT: 0.5in"&gt;However we do &lt;STRONG&gt;not&lt;/STRONG&gt; support registration of Windows Forms controls as ActiveX controls and we do not support CoCreateInstance of Windows Forms controls. We only support managed activation of the Windows Forms controls. Once the controls are created they can be hosted in MFC just as you would any other ActiveX control. &lt;A href="http://msdn.microsoft.com/msdnmag/issues/03/03/WindowsForms"&gt;This&lt;/A&gt;&amp;nbsp;article by &lt;A href="http://www.sellsbrothers.com/spout/"&gt;Chris Sells&lt;/A&gt;&amp;nbsp;explains how to do this.&amp;nbsp;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=59142" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rprabhu/archive/tags/.NET+-+Random+Tips/default.aspx">.NET - Random Tips</category></item></channel></rss>