<?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>Search results for 'app:weblogs' matching tag 'CSharp'</title><link>http://msmvps.com/search/SearchResults.aspx?q=app:weblogs&amp;tag=CSharp&amp;orTags=0&amp;o=DateDescending</link><description>Search results for 'app:weblogs' matching tag 'CSharp'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Your Application Title in .NET</title><link>http://msmvps.com/blogs/deborahk/archive/2012/08/27/your-application-title-in-net.aspx</link><pubDate>Mon, 27 Aug 2012 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1815542</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;You would think that giving an application a title and later retrieving that title would be a straightforward thing to do in VB.NET or C#. But it turns out to be a little complex, especially to find the appropriate place to enter the title then to write the appropriate code to retrieve that title.&lt;/p&gt;  &lt;p&gt;First, enter the title of the application.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Find the project in Solution Explorer. &lt;/li&gt;    &lt;li&gt;Double-click on the Properties node under the project in Solution Explorer. &lt;/li&gt;    &lt;li&gt;Select the Application tab. &lt;/li&gt;    &lt;li&gt;Click the Assembly Information button. &lt;/li&gt;    &lt;li&gt;Enter the desired title into the provided dialog. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4263.image_5F00_5DA0526E.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6254.image_5F00_thumb_5F00_58BD9EB2.png" width="421" height="457" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Find the project in Solution Explorer. &lt;/li&gt;    &lt;li&gt;Double-click on the My Project node under the project in Solution Explorer. &lt;/li&gt;    &lt;li&gt;Select the Application tab. &lt;/li&gt;    &lt;li&gt;Click the Assembly Information button. &lt;/li&gt;    &lt;li&gt;Enter the desired title into the provided dialog. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6354.image_5F00_77941290.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6204.image_5F00_thumb_5F00_68E966AB.png" width="415" height="450" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Second, write the code to retrieve that title. In this example, the title is provided as an ApplicationName property.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Lucida Console"&gt;/// &amp;lt;summary&amp;gt;      &lt;br /&gt;/// Gets the name of the application.       &lt;br /&gt;/// &amp;lt;/summary&amp;gt;       &lt;br /&gt;/// &amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;       &lt;br /&gt;/// &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;       &lt;br /&gt;public static string ApplicationName       &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; get       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var entryAssembly = Assembly.GetEntryAssembly();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var applicationTitle = ((AssemblyTitleAttribute)entryAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0]).Title;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (string.IsNullOrWhiteSpace(applicationTitle))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&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; applicationTitle = entryAssembly.GetName().Name;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return applicationTitle;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Lucida Console"&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;summary&amp;gt;      &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; Gets the name of the application.       &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;       &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;       &lt;br /&gt;Public Shared ReadOnly Property ApplicationName() As String       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Get       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim applicationTitle = My.Application.Info.Title       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; If String.IsNullOrWhiteSpace(My.Application.Info.Title) Then       &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; applicationTitle = My.Application.Info.AssemblyName       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End If       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return applicationTitle       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Get       &lt;br /&gt;End Property&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e"&gt;&lt;font face="Lucida Console"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The C# code defines a static property for the application name. Its getter first determines the entry assembly, which is the first executable that was executed. So even if this property is in a library component, if the application was launched with a WinForms or other UI component, the entry assembly is the UI component and not the library. If the code needs the currently executing assembly, replace GetEntryAssembly with GetExecutingAssembly.&lt;/p&gt;  &lt;p&gt;The C# code then uses GetCustomAttributes to obtain the AssemblyTitleAttribute from the assembly to then retrieve the title.&lt;/p&gt;  &lt;p&gt;If for some reason the title attribute was not set, the code uses the GetName method to retrieve the name of the entry assembly and uses the retrieved name.&lt;/p&gt;  &lt;p&gt;The VB code uses the My namespace to retrieve the application title. The My namespace provides a very nice shortcut to the application&amp;#39;s title attribute. If for some reason the title attribute was not set, the code uses the AssemblyName, also provided within the My namespace.&lt;/p&gt;  &lt;p&gt;In both languages, the application title is &amp;quot;Acme Customer Management&amp;quot; as defined in the Assembly Information dialog.&lt;/p&gt;  &lt;p&gt;Use this technique any time you want to define the application title in the assembly information and retrieve it for display or logging.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item><item><title>Visual Studio toolbar</title><link>http://msmvps.com/blogs/bill/archive/2012/03/07/visual-studio-toolbar.aspx</link><pubDate>Wed, 07 Mar 2012 06:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1807064</guid><dc:creator>bill</dc:creator><description>&lt;p&gt;The beta of Visual Studio 11 is causing a lot of feedback around the grey shade icons.&amp;#160; The use of colour or not has also brought to the forefront the UI for colour-blind people.&amp;#160; So I thought I’d post a picture of my toolbar, along with some links to see the page as seen by those with colour-blindness...&lt;/p&gt;  &lt;p&gt;My toolbar:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill.metablogapi/1033.image_5F00_7AB68892.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill.metablogapi/3554.image_5F00_thumb_5F00_5F31868F.png" width="1230" height="71" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Colour-blind filter web site: &lt;a title="http://colorfilter.wickline.org/" href="http://colorfilter.wickline.org/"&gt;http://colorfilter.wickline.org/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This post on the above site:    &lt;br /&gt;&lt;a title="http://colorfilter.wickline.org/?a=1;r=;l=0;j=1;u=msmvps.com/blogs/bill/archive/2012/03/07/visual-studio-toolbar.aspx;t=p" href="http://colorfilter.wickline.org/?a=1;r=;l=0;j=1;u=msmvps.com/blogs/bill/archive/2012/03/07/visual-studio-toolbar.aspx;t=p"&gt;http://colorfilter.wickline.org/?a=1;r=;l=0;j=1;u=msmvps.com/blogs/bill/archive/2012/03/07/visual-studio-toolbar.aspx;t=p&lt;/a&gt;&lt;/p&gt;</description></item><item><title>VB Quark #7 : Optional Parameters and Dates</title><link>http://msmvps.com/blogs/bill/archive/2011/11/09/vb-quark-7-optional-parameters-and-dates.aspx</link><pubDate>Wed, 09 Nov 2011 06:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1802239</guid><dc:creator>bill</dc:creator><description>&lt;p&gt;Hopefully you already know VB has full support for Optional parameters, both declaring them and calling them, but did you know you can use Dates as Optional parameters ?&lt;/p&gt; &lt;font style="line-height:normal;"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size:10pt;"&gt;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Sub&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; AddNewCustomer(customer &lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;As&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span&gt;&lt;font color="#000088"&gt;Customer&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;,&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;&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;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Optional&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; dateAdded &lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;As&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Date&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; = &lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Nothing&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size:10pt;"&gt;&lt;font color="#000000"&gt;)         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;If&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; dateAdded = &lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Nothing&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Then&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; dateAdded = Now&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt; VB has had this support for Optional parameters in place for the last decade or so in .NET and for years before that back in the COM versions of VB. &lt;/p&gt;  &lt;p&gt;In the last release of .NET (VS 2010), C# finally got support for Optional parameters, so the above in C# would look like:&lt;/p&gt; &lt;font style="line-height:normal;"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size:10pt;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; AddNewCustomer(&lt;/font&gt;&lt;span&gt;&lt;font color="#2b91af"&gt;Customer&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size:10pt;"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; customer,&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;&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;/font&gt;&lt;span&gt;&lt;font color="#2b91af"&gt;DateTime&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; dateAdded = &lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;default&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span&gt;&lt;font color="#2b91af"&gt;DateTime&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size:10pt;"&gt;&lt;font color="#000000"&gt;))         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (dateAdded == &lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;default&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span&gt;&lt;font color="#2b91af"&gt;DateTime&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;)) dateAdded = &lt;/font&gt;&lt;span&gt;&lt;font color="#2b91af"&gt;DateTime&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Now;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;    &lt;br /&gt;&lt;/font&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The Nothing in the VB declaration is the same as default(DateTime) in C#, which equates to the theoretical Gregorian date of 1/1/0001.&lt;/p&gt;  &lt;p&gt;But what if you want to specify a default date ? Well because VB supports date literals, in VB you can, but in C# you can’t.&amp;#160; In VB you can write any date literal for the optional parameter value. For example, you might have some legacy database support, and when the date is unknown you want to use the equivalent of an OLE Date’s zero value:&lt;/p&gt; &lt;font style="line-height:normal;"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size:10pt;"&gt;&amp;#160; &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Sub&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; AddNewCustomer(customer &lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;As&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span&gt;&lt;font color="#000088"&gt;Customer&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size:10pt;"&gt;&lt;font color="#000000"&gt;,         &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;&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;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Optional&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; dateAdded &lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;As&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span&gt;&lt;font color="#3092b1"&gt;Date&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; = #12/30/1899#)&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;When the VB compiler compiles this, it adds a System.Runtime.CompilerServices.DateTimeConstantAttribute to the parameter information with the default value stored as an Int64 (the number of ticks). C# actually sees the optional value in the above example and will use it. That is both VB and C# can call the code taking advantage of the optional value for the date parameter, but only VB let’s you define that value.&lt;/p&gt;</description></item><item><title>Displaying Dates in VS 2010</title><link>http://msmvps.com/blogs/bill/archive/2011/11/08/displaying-dates-in-vs-2010.aspx</link><pubDate>Tue, 08 Nov 2011 06:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1802185</guid><dc:creator>bill</dc:creator><description>&lt;p&gt;From time to time there&amp;rsquo;s discussion about the way dates are displayed in the Visual Studio IDE for Visual Basic. Typically dates are shown using VB&amp;rsquo;s date literal syntax of #MM/dd/yyyy# which is the standard US format.&amp;nbsp; For people outside of the USA this can be confusing or ambiguous at times.&amp;nbsp; The good news is Visual Studio allows you to easily add your own display formatter.&lt;/p&gt;
&lt;p&gt;Simply create a new class library project, add the following attribute to your AssemblyInfo file:&lt;/p&gt;
&lt;p&gt;&lt;span style="line-height:normal;"&gt;&lt;span style="font-family:Consolas;"&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-size:10pt;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;"&gt;&lt;span&gt;&lt;span style="color:#3092b1;"&gt;Assembly&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;: &lt;/span&gt;&lt;span&gt;&lt;span style="color:#000088;"&gt;DebuggerDisplay&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;(&lt;/span&gt;&lt;span style="background-image:none;background-attachment:scroll;background-repeat:repeat;background-position:0% 0%;"&gt;&lt;span style="background-color:#fefff0;color:#a31515;"&gt;&amp;quot;Date: {ToString(&amp;quot;&amp;quot;s&amp;quot;&amp;quot;)}&amp;nbsp;&amp;nbsp; kind={Kind}&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;, Target:=&lt;/span&gt;&lt;span&gt;&lt;span style="color:#3092b1;"&gt;GetType&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;(&lt;/span&gt;&lt;span&gt;&lt;span style="color:#000088;"&gt;DateTime&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;))&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;And then just copy the assembly to your Visualizers directory, eg: &lt;br /&gt;&amp;nbsp; My Documents\Visual Studio 2010\Visualizers&lt;/p&gt;
&lt;p&gt;I added the Kind property to the display so as you can easily see if the Date is a local date, UTC or unspecified.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve attached a sample project.&amp;nbsp; Enjoy &lt;img src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill.metablogapi/3000.wlEmoticon_2D00_smile_5F00_4E15BC0E.png" alt="Smile" class="wlEmoticon wlEmoticon-smile" style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Setting up Separate Visual Studio Instances</title><link>http://msmvps.com/blogs/deborahk/archive/2011/10/23/setting-up-separate-visual-studio-instances.aspx</link><pubDate>Sun, 23 Oct 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1801577</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;You can open Visual Studio multiple times, but each environment has the same settings. With Visual Studio 2010 and experimental instances, you can now have entirely different instances of Visual Studio with different settings.&lt;/p&gt;  &lt;p&gt;If you open up Visual Studio 2010 and make the font larger or install specific extensions, those settings are used every time you open Visual Studio. This assumes that you want to work with Visual Studio the same way every time you use it. But you may have scenarios where this is not the case.&lt;/p&gt;  &lt;p&gt;Say you want to set up your Visual Studio with one set of settings for your daily work and a different set when you do demos to your team or user group. Or you want one set of settings when you work on an ASP.NET application and a different set when you work on Windows Forms. Or one set when you work with client x and another set when you work with client y.&lt;/p&gt;  &lt;p&gt;To support these scenarios, Visual Studio 2010 provides a feature called &amp;quot;experimental instances&amp;quot;. Experimental instances allow you to set up multiple instances of Visual Studio with completely different settings,&amp;#160; options, and extensions.&lt;/p&gt;  &lt;p&gt;To set up an experimental instance, create a short cut to Visual Studio. Include with the path, the option &lt;font face="Consolas"&gt;/RootSuffix XXX&lt;/font&gt;, where XXX is any name you want to give to your alternate instance.&lt;/p&gt;  &lt;p&gt;For example:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;quot;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe&amp;quot; /RootSuffix Demo&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This sets up a new instance of Visual Studio called Demo. You can create any number of these new instances, just give them unique names.&lt;/p&gt;  &lt;p&gt;The following is a screen shot for my demo instance:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3124.image_5F00_4A8F17BD.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4064.image_5F00_thumb_5F00_3B0C05EE.png" width="394" height="555" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Use this technique any time you want to set up multiple instances of Visual Studio.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item><item><title>Opening Visual Studio From the Task Bar</title><link>http://msmvps.com/blogs/deborahk/archive/2011/10/23/opening-visual-studio-from-the-task-bar.aspx</link><pubDate>Sun, 23 Oct 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1801579</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;If you use Visual Studio often, you probably pinned it to the task bar so you can quickly access it. Here is a tip for opening Visual Studio from the task bar using the keyboard.&lt;/p&gt;  &lt;p&gt;First, count the position of Visual Studio in the task bar. Mine is in position #10.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3225.image_5F00_490F9F89.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3324.image_5F00_thumb_5F00_4117FD27.png" width="557" height="36" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Hold down the &lt;font color="#65402e" face="Consolas"&gt;Windows Key + Alt + # of the item&lt;/font&gt;. On my system, this is Windows Key + Alt + 10. Then use the arrow keys to select the desired project.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4747.image_5F00_475ED3B5.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5417.image_5F00_thumb_5F00_71CB04D2.png" width="270" height="416" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;Use this technique any time you want to launch Visual Studio from the Task Bar using the keyboard.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item><item><title>VB Windows Phone Toolkit Aug 11 sample</title><link>http://msmvps.com/blogs/bill/archive/2011/08/19/vb-windows-phone-toolkit-aug-11-sample.aspx</link><pubDate>Fri, 19 Aug 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1797890</guid><dc:creator>bill</dc:creator><description>&lt;p&gt;The &lt;a href="http://silverlight.codeplex.com/releases/view/71550" target="_blank"&gt;Silverlight Windows Phone Toolkit August 2011 (7.1 SDK)&lt;/a&gt; doesn&amp;#39;t contain a working VB sample.&amp;#160; If you try to load the VB sample that does ship, you’ll get hundreds of errors.&amp;#160; So I put together the VB sample that should have shipped.&lt;/p&gt;  &lt;p&gt;&lt;a href="https://skydrive.live.com/?cid=73b8e1011c9738b5&amp;amp;sc=documents&amp;amp;id=73B8E1011C9738B5%21169#" target="_blank"&gt;Download the VB Windows Phone Toolkit samples&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Enjoy &lt;img style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/bill.metablogapi/4370.wlEmoticon_2D00_smile_5F00_2FC4FCFE.png" /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Oh, and Thanks to &lt;a href="http://nicksnettravels.builttoroam.com/" target="_blank"&gt;Nick Randolph&lt;/a&gt; for confirming the SDK doesn’t contain a &lt;em&gt;working&lt;/em&gt; example. &lt;/p&gt;</description></item><item><title>Silverlight Validation: Resource File</title><link>http://msmvps.com/blogs/deborahk/archive/2011/05/03/silverlight-validation-resource-file.aspx</link><pubDate>Tue, 03 May 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1792615</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;Resource files are a great way to manage strings, especially if you need to support multiple languages. This post demonstrates how to use a resource file with the validation attributes used by Silverlight and WCF RIA Services.&lt;/p&gt;  &lt;p&gt;NOTE: This post is part of a set of validation posts &lt;a href="http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-ria-and-validation.aspx"&gt;which starts here&lt;/a&gt; and it uses the sample code from &lt;a href="http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-mvvm-wcf-ria-services-simple-sample-application.aspx"&gt;this prior post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;In &lt;a href="http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-wcf-ria-single-property-validation.aspx"&gt;this prior post&lt;/a&gt;, the code example demonstrated how to use the single property validation attributes available in Silverlight and WCF RIA Services. For example, to validate that a first name is entered and does not exceed 20 characters, the attributes look like this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;[Required(ErrorMessage=&amp;quot;Please enter a first name.&amp;quot;)]      &lt;br /&gt;[StringLength(20, ErrorMessage = &amp;quot;First name cannot exceed 20 characters.&amp;quot;)]       &lt;br /&gt;public string FirstName { get; set; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Notice how the validation error messages are hard-coded strings. This poses a challenge if you need to localize your application.&lt;/p&gt;  &lt;p&gt;A better option is to add the strings to a resource file. The trick here is that the resource file needs to exist both on the server (in the Class Library project if you are using WCF RIA with your own business layer) and on the client (in the Silverlight project). This is done by a process called linking.&lt;/p&gt;  &lt;p&gt;1) In the Class Library project containing your business layer, add a resource file (Add | New Item | Resources File).&lt;/p&gt;  &lt;p&gt;I added mine to a Resources folder in the project.&lt;/p&gt;  &lt;p&gt;NOTE: If you are not using your own business layer on the server, you can add the resource file directly to the Web project instead.&lt;/p&gt;  &lt;p&gt;2) Enter a name for each string along with the string values. Optionally add a comment.&lt;/p&gt;  &lt;p&gt;3) Set the Access Modifier for each resource string to Public.&lt;/p&gt;  &lt;p&gt;The result should look something like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6403.image_5F00_59693BAA.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3107.image_5F00_thumb_5F00_66CF4EB0.png" width="487" height="165" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;4) In the Silverlight project, link to that resource file by selecting Add | Existing Item and then clicking on Add As Link in the Add Existing Item dialog.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4505.image_5F00_6D16253E.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4213.image_5F00_thumb_5F00_70480D26.png" width="467" height="288" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;5) In the Silverlight project, link also to the associated Designer.cs file.&lt;/p&gt;  &lt;p&gt;NOTE: The Add Existing Item dialog allows multiple selection. So you could link both the rex file and the Designer/cs file in one step.&lt;/p&gt;  &lt;p&gt;6) Modify the attribute parameters in the business layer Class Library project to reference the resource file instead of using hard-coded strings. Be sure to add a using for the resource file&amp;#39;s namespace:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;using InStepValidationExample.BL.Resources;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;[Required(ErrorMessageResourceType = typeof(ValidationErrorResources),     &lt;br /&gt;ErrorMessageResourceName = &amp;quot;FirstNameRequired&amp;quot;)]      &lt;br /&gt;[StringLength(20,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ErrorMessageResourceName = &amp;quot;FirstNameLength&amp;quot;,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ErrorMessageResourceType = typeof(ValidationErrorResources))]      &lt;br /&gt;public string FirstName { get; set; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Instead of setting the ErrorMessage parameter to a hard-coded string, this code sets the ErrorMessageResourceType parameter to the type of the resource file (which is the resource file name). The ErrorMessageResourceName parameter specifies the name that you defined for the associated resource string in the resource file.&lt;/p&gt;  &lt;p&gt;7) Now for the tricky part. By default, Visual Studio requires that the two resource files be in the same namespace. If they aren&amp;#39;t, the application won&amp;#39;t find the resources.&lt;/p&gt;  &lt;p&gt;For example, if you use the Silverlight Business Application template, you can see that it puts&amp;#160; the resource file in the BizApp.Web project under a Resources folder. The resources are then in the BizApp.Web.Resources namespace. &lt;/p&gt;  &lt;p&gt;To access the resources from the BizApp Silverlight project, the file is put in a folder hierarchy with a Web folder and then a Resources folder so the resulting namespace is again BizApp.Web.Resources. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0830.image_5F00_3D7806B2.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7380.image_5F00_thumb_5F00_3C9FA0C8.png" width="276" height="650" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In the example for this post, however, the resources are in a Class Library in a business layer separate from the Web project:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0361.image_5F00_54C30B23.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4812.image_5F00_thumb_5F00_2D1C8EF9.png" width="311" height="485" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The namespace of the resources in the business layer is InStepValidationExample.BL.Resources. The namespace of the resources in the Silverlight project is InStepValidatoinExample.SL.Resources.&lt;/p&gt;  &lt;p&gt;So if you run the application at this point, it will crash with a &amp;quot;TargetInvocationException occurred&amp;quot; message. If you look at the exception detail it says &amp;quot;Could not find any resources appropriate for the specified culture or the neutral culture...&amp;quot; Basically, it cannot find the resource file.&lt;/p&gt;  &lt;p&gt;Luckily, we know the secret handshake required to get this to work:&lt;/p&gt;  &lt;p&gt;7a) Right-click on the Silverlight project and select Unload Project.&lt;/p&gt;  &lt;p&gt;7b) Right-click on the Silverlight project again and select to edit the project file.&lt;/p&gt;  &lt;p&gt;7c) Add a &amp;lt;LogicalName&amp;gt; element to the &amp;lt;EmbeddedResource&amp;gt; element in the project file and set it to the namespace and resource name. Mine looked like this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;lt;ItemGroup&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;EmbeddedResource Include=&amp;quot;..\InStepValidationExample.BL\Resources\ValidationErrorResources.resx&amp;quot;&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Link&amp;gt;Resources\ValidationErrorResources.resx&amp;lt;/Link&amp;gt;      &lt;br /&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;LogicalName&amp;gt;       &lt;br /&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;&lt;strong&gt;&amp;#160; InStepValidationExample.BL.Resources.ValidationErrorResources.resources       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/LogicalName&amp;gt;&lt;/strong&gt;      &lt;br /&gt;&amp;#160; &amp;lt;/EmbeddedResource&amp;gt;      &lt;br /&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/font&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;7d) Close the project file.&lt;/p&gt;  &lt;p&gt;7e) Right-click on the Silverlight project and select Reload Project.&lt;/p&gt;  &lt;p&gt;Now when you run, it should find your resource file.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3441.image_5F00_134858CA.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3060.image_5F00_thumb_5F00_0BBCE95D.png" width="440" height="232" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Use a resource file any time you want better management of your strings, especially if you plan to localize your application.   &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item><item><title>Silverlight/WCF RIA Validation: Metadata Class</title><link>http://msmvps.com/blogs/deborahk/archive/2011/05/03/silverlight-wcf-ria-validation-metadata-class.aspx</link><pubDate>Tue, 03 May 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1792664</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;Data annotation attributes are a great way to add single property validation to your Silverlight/WCF RIA application. But what if you don&amp;#39;t want to inject attributes all over your business classes? The purpose of a metadata class is to have a place for all of these attributes external from the business class.&lt;/p&gt;  &lt;p&gt;NOTE: This post is part of a set of validation posts &lt;a href="http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-ria-and-validation.aspx"&gt;which starts here&lt;/a&gt; and it uses the sample code from &lt;a href="http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-mvvm-wcf-ria-services-simple-sample-application.aspx"&gt;this prior post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;If your Silverlight application uses WCF RIA services and your own business objects, then you can set attributes on your business object properties to define single-attribute validation.&lt;/p&gt;  &lt;p&gt;In &lt;a href="http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-wcf-ria-single-property-validation.aspx"&gt;this prior post&lt;/a&gt;, the code example demonstrated how to use the single property validation attributes available to validate that a last name is entered and does not exceed 20 characters, the attributes look like this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;[Required(ErrorMessage = &amp;quot;Please enter a last or family name.&amp;quot;)]     &lt;br /&gt;[StringLength(20, ErrorMessage = &amp;quot;Last name cannot exceed 20 characters.&amp;quot;)]      &lt;br /&gt;public string LastName { get; set; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If you don&amp;#39;t want these attributes in your business classes, you can instead create a metadata file and store all of the attributes there.&lt;/p&gt;  &lt;p&gt;1) Right-click on your business object&amp;#39;s Class Library project and add a new class (Add | New Item | Class).&lt;/p&gt;  &lt;p&gt;In this example, the class was called Student. So the metadata class is named StudentMetadata.cs.&lt;/p&gt;  &lt;p&gt;2) In&amp;#160; this new class, add any of the business object properties and associated attributes.&lt;/p&gt;  &lt;p&gt;Note that the property names defined in the metadata class must exactly match the property names in the original class.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;using System.ComponentModel.DataAnnotations;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;namespace InStepValidationExample.BL     &lt;br /&gt;{      &lt;br /&gt; internal sealed class StudentMetadata      &lt;br /&gt; {      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160; /// Private to ensure this class is not instantiated.      &lt;br /&gt;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160; private StudentMetadata()      &lt;br /&gt;&amp;#160;&amp;#160; {}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160; [Required(ErrorMessage = &amp;quot;Please enter a last or family name.&amp;quot;)]     &lt;br /&gt;&amp;#160; [StringLength(20, ErrorMessage = &amp;quot;Last name cannot exceed 20 characters.&amp;quot;)]      &lt;br /&gt;&amp;#160; public string LastName { get; set; }      &lt;br /&gt; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;TBD&lt;/p&gt;  &lt;p&gt;3) Associate the metadata class with its original class using a MetadataType attribute on the original class definition. This attribute associates the original business object class with the metadata class.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;namespace InStepValidationExample.BL     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [MetadataType(typeof(StudentMetadata))]      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class Student      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;TBD&lt;/p&gt;  &lt;p&gt;When you run the application, the validation should work as before:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1055.image_5F00_69D2F3FB.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1882.image_5F00_thumb_5F00_2930A78C.png" width="480" height="255" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Use this technique any time you want attributes on your business object properties, but want to define these attributes external from the business object classes.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item><item><title>Silverlight/WCF RIA Single Property Validation</title><link>http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-wcf-ria-single-property-validation.aspx</link><pubDate>Sun, 01 May 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1792572</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;When you identify the validation scenarios for your application, you will find that some only require basic single property validation. Examples:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Ensure that a first name is entered. &lt;/li&gt;    &lt;li&gt;Ensure that the first name is not longer than 20 characters &lt;/li&gt;    &lt;li&gt;Ensure that the age is between 16 and 120. &lt;/li&gt;    &lt;li&gt;Ensure that the email address is valid. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;NOTE: This post is part of a set of validation posts &lt;a href="http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-ria-and-validation.aspx"&gt;which starts here&lt;/a&gt; and it uses the sample code from &lt;a href="http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-mvvm-wcf-ria-services-simple-sample-application.aspx"&gt;this prior post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Each of these requirements can be handled by Silverlight&amp;#39;s single field validation using property attributes.&lt;/p&gt;  &lt;p&gt;When you use WCF RIA Services and your own set of business objects, these attributes are set in the business layer on the business object properties. WCF RIA Services then automatically generates a copy of your business object properties with their attributes on the client for use with Silverlight.&lt;/p&gt;  &lt;p&gt;Silverlight performs the validation when the user leaves the field AND before the data is submitted to the server. If there is a validation error, the data is not submitted to the server and a validation error appears.&lt;/p&gt;  &lt;p&gt;Each of the simple validation attributes are discussed below.&lt;/p&gt;  &lt;h2&gt;Required Field Validation&lt;/h2&gt;  &lt;p&gt;Use the Required attribute to mark a property as required. For example, if the first name is required, the first name property is adorned as follows:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;[Required()]      &lt;br /&gt;public string FirstName { get; set; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If you make this change and run the sample application (&lt;a href="http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-mvvm-wcf-ria-services-simple-sample-application.aspx"&gt;from this prior post&lt;/a&gt;), the first name field is automatically validated. Clear the field and you will see this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8640.image_5F00_71764DB8.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0172.image_5F00_thumb_5F00_62CBA1D3.png" width="466" height="265" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Silverlight&amp;#39;s built-in validation automatically kicks in and you see the default required validation error message.&lt;/p&gt;  &lt;p&gt;NOTE: You can modify the Silverlight XAML to specify the ValidatesOnNotifyDataErrors property as part of the binding expression. However, this is not necessary. The default value of this property is true, so the validation errors are reported by default.&lt;/p&gt;  &lt;p&gt;If you don&amp;#39;t like the error message, you can change it by setting one of the named parameters of the Required attribute:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;[Required(ErrorMessage=&amp;quot;Please enter a first name.&amp;quot;)]      &lt;br /&gt;public string FirstName { get; set; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The message then appears as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3324.image_5F00_69127861.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5700.image_5F00_thumb_5F00_0F745BAD.png" width="467" height="273" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Use required field validation any time you want to ensure that the user enters a value into a Silverlight control.&lt;/p&gt;  &lt;h2&gt;String Length Validation&lt;/h2&gt;  &lt;p&gt;Often times the data entered on a page in Silverlight will get stored to a database where a maximum field size is defined. It is helpful for the users to be aware of this maximum before attempting to submit the data to the server.&lt;/p&gt;  &lt;p&gt;For example, if the first name is set to a maximum of 20 characters in the database, you can set the StringLength attribute as follows:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;[Required(ErrorMessage=&amp;quot;Please enter a first name.&amp;quot;)]      &lt;br /&gt;[StringLength(20, ErrorMessage = &amp;quot;First name cannot exceed 20 characters.&amp;quot;)]       &lt;br /&gt;public string FirstName { get; set; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Use string length validation any time you want to ensure that the user does not enter more data than can be stored in the database table or any other time that a string length cannot exceed a maximum value.&lt;/p&gt;  &lt;h2&gt;Range Validation&lt;/h2&gt;  &lt;p&gt;When entering numbers, often times the value must be limited to a specific range of values. For example, in this application the age must be between 16 and 120.&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;[Range(16, 120,      &lt;br /&gt;ErrorMessage=&amp;quot;Please enter your age. You must be 16 or older.&amp;quot;)]       &lt;br /&gt;public int Age { get; set; }&lt;/font&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;This results in the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5808.image_5F00_2EB70280.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0045.image_5F00_thumb_5F00_200C569B.png" width="485" height="240" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;NOTE: The Range attribute has overloads with parameters that are integers or doubles. To validate other types (such as decimal), you need to use the Range overload that takes a type as the first parameter and string values to convert to the defined type. For example:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;[Range(typeof(Decimal),&amp;quot;0&amp;quot;, &amp;quot;40000&amp;quot;)]      &lt;br /&gt;public decimal TuitionPaid{ get; set; }&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;Use range validation any time you want to validate user entry to a range of numeric values.&lt;/p&gt;  &lt;h2&gt;Regular Expression Validation&lt;/h2&gt;  &lt;p&gt;Regular expression validation allows you to perform pattern matching on the entered value. For example, an email address must match a specific pattern with a local part of the address followed by an at sign (@) followed by a domain name. The Regular Expression attribute could look like this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;[Regular(@&amp;quot;^(?(&amp;quot;&amp;quot;)(&amp;quot;&amp;quot;.+?&amp;quot;&amp;quot;@)|&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; @&amp;quot;(([0-9a-zA-Z]((\.(?!\.))|&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; @&amp;quot;[-!#\$%&amp;amp;&amp;#39;\*\+/=\?\^`\{\}\|~\w])*)(?&amp;lt;=[0-9a-zA-Z])@))&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; @&amp;quot;(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; @&amp;quot;(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$&amp;quot;,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ErrorMessage=&amp;quot;Please enter a valid email address&amp;quot;)]&lt;/font&gt;&lt;font color="#65402e"&gt;     &lt;br /&gt;&lt;font face="Consolas"&gt;public string Email { get; set; }&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;NOTE: Replace &amp;quot;Regular&amp;quot; above with &amp;quot;&lt;strong&gt;RegularExpression&lt;/strong&gt;&amp;quot;. For whatever reason, the entire string was blocked in this post if the word &amp;quot;Expression&amp;quot; appeared above.&lt;/p&gt;  &lt;p&gt;Other properties that could use a regular expression include phone numbers, social security numbers, and any other entry that must match a specific pattern.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/hs600312(VS.95).aspx"&gt;You can find more information on regular expressions here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Use regular expressions any time you want to validate a user&amp;#39;s entry based on pattern matching.&lt;/p&gt;  &lt;p&gt;For more complex validation scenarios, see &lt;a href="http://msmvps.com/blogs/deborahk/archive/2011/05/01/silverlight-ria-and-validation.aspx"&gt;this prior post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;        &lt;p&gt;EDIT 5/2/11: Corrected typographical errors. Corrected the regular expression, which did not paste into the post correctly.&lt;/p&gt;</description></item></channel></rss>