Visual Studio 2008: Tips, tricks and all the info about Microsoft Visual Studio 2008, tricks and all the info about Microsoft Visual Studio 2008enThe New Zealand ALM Conference 2011 (Application Life Cycle Management) and tricksThu, 27 Jan 2011 04:24:00 PSTFor you folks interested in application development, management the <strong><a href="">New Zealand ALM Conference 2011</a></strong> should be interesting. It's happening 6th &amp; 7th April 2011, at The Duxton Hotel, Wellington. <br /><br /> Some of the sessions being presented:<br> <ul> <li>Building reliable software with .NET 4 Code Contracts </li> <li>Building and Deploying Cloud Apps with Windows Azure and VS2010 </li> <li>SharePoint Tools Tailor made to suit your development scenarios </li> <li>MVVM based Silverlight development with VS2010 </li> <li>Continuous Integration for SharePoint Development </li> <li>Enhancing your testing capability using Coded UI tests in VS 2010 </li> <li>Panel Discussion: Real world benefits using ALM tools and practices </li> <li>Breaking the Dev/Test Barrier with Visual Studio 2010 </li> <li>Turbo charging TFS with things not in the box </li> <li>Team Foundation Server 2010 for Successful Project Management </li> <li>Windows Phone 7 Development with VS2010 and Expression Blend </li> <li>Building Business Programming Toolkits with VS2010 </li> <li>Automated Builds in TFS: Beyond the Basics </li> <li>Web Application Security from Day 0</li></ul><img src="" height="1" width="1" alt=""/> your own Html Helpers for the ASP.NET MVC Framework and tricksSun, 22 Mar 2009 00:00:00 PDTAnyone who's dipped a toe in the ASP.NET MVC Framework will have encountered Html Helpers. These remove the need to drop large chunks of code into your markup to generate common elements that can't be hard-coded by giving you the means to use small chunks of code instead. Which is better.<br /><br />For example, if you have the framework scaffold a &quot;List&quot; view template for you, by default you'll get Edit and Details links for each item in the Model. The end result looks something like this:<br /><br /><img src="" alt="" width="583" height="73" /><br /><br />OK, admit it: How many of you when you first saw this sort of thing in the MVC Framework threw up your hands, said &quot;It's ASP all over again&quot; and ran away screaming? Trust me, it's really not that bad. The helper methods solve the problem of producing markup from the Model or other dynamic content, and actually remove the need to inject a lot of code into the markup (which would be uncomfortably like the bad old days with ASP, at least as many people wrote it) by wrapping it up in a compact bundle. <br /><br />The output generated at runtime from the fragment above is gloriously simple and uncluttered. For example:<br /><br /><img src="" alt="" width="349" height="68" /><br /><br />(In this case I based my view on a PeopleController. The links will invoke the Edit and Details Actions respectively for the item with Id=1).<br /><br />It needs to be stressed that these extensions are not controls: they are as their name implies helper methods that generate vanilla markup based on any arguments you supply them. They have in themselves no page lifecycle, no state and certainly no event model. In some ways they could be compared with macros. <br /><br />The output of most HTML Helpers is simply a string containing markup. The same is true of course of server controls, but with HTML Helpers the markup produced is not the kind that makes View Source the stuff of nightmares. This is because generating a string of HTML is all they do, so there is no need for hidden elements or script to enable a complex relationship between the generated markup and things that happen on the server. <br /><br />Additionally, because they are not controls, it follows that they are not composite controls, so you are not confronted with markup containing element ids longer than a sentence by Marcel Proust.<br /><br />So how do you write your own?<br /><br />First you need to have a basic understanding of Extension Methods &ndash; if you don't know what extension methods are then clearly you've wasted your life and there's nothing I can do for you (Oh come on, that was a joke, so no sulking &ndash; extension methods are defined in the Visual Studio and .NET Framework glossary this way &quot;A static method that can be invoked by using instance method syntax. In effect, extension methods make it possible to extend existing types and constructed types with additional methods&quot;).<br /><br />A typical HTML Helper is an extension method applied to the View's instance of the HtmlHelper class. Consequently if you're using C# your method signature will typically start with something like &quot;(this HtmlHelper htmlHelper&quot;, followed by any other parameters required.<br /><br />For my example I'm going to create an HTML Helper that generates a list of Technorati tags surrounded by a DIV element and preceded by the words &quot;Technorati tags: &quot;. <a href="" target="_blank">Technorati tags are described here</a>.<br /><br />I'm assuming a scenario where your MVC application is something like a blog or a CMS where it is useful to have posts or articles accompanied by tags, and consequently your model will include a property such as &quot;TagList&quot;, representing a comma-delimited list of tags (if you want anything more structured it probably makes more sense to use fixed categories).<br /><br />So, our HTML Helper will need to take a Model property which for any given instance might contain something such as this: &quot;rambling, arrant nonsense&quot; and output HTML like this:<br /><br /><img src="" alt="" width="686" height="40" /><br /><br />(I know there's more you'd probably want to include, and I'll come to that shortly).<br /><br />To build the markup my first impulse was to use an HtmlTextWriter in conjunction with a StringWriter, but the TagBuilder object provided with the MVC Framework has some useful characteristics that we can take advantage of to good effect.<br /><br />Here's the first version:<br /><br /><img src="" alt="" width="807" height="542" /><br /><br />In this case I've used TagBuilders to create the anchor tags, aggregated the results with a StringBuilder and placed the results in the InnerHtml property of an outer TagBuilder for the DIV.<br /><br />Note also that I've used the HtmHelper object's AttributeEncode and Encode methods .<br /><br />The problem with the HTML this code produces (which I showed earlier) is that it is effectively sealed: if you want to apply CSS styling to it or manipulate it with jQuery you're out of luck. <br /><br />We could of course supply hard-coded id and class values for the DIV, but you know in your belly (ewww...) that that's a bad idea, and it would of course mean that anyone using this helper would need to see its output or examine the code to know what element id or CSS class they should be referring to. It's much better to let the developer specify these values when they're using your helper extension. <br /><br />Rather than supplying parameters for &quot;id&quot; and &quot;class&quot; and then adding others that you realise you've forgotten, there is a pattern used by the built-in helper methods that you can refer to.&nbsp; So I'll overload my extension method to support two versions of an htmlAttributes parameter, one an object and the other a dictionary:<br /><br /><img src="" alt="" width="839" height="214" /><br /><br />This is where the TagBuilder really comes into its own: we can use the MergeAttributes method of the TagBuilder to add attributes from the dictionary into its collection of attributes, and these are then rendered with the rest of the element.<br /><br />The attributes themselves can be specified using object initaliser syntax, so (again assuming C#) I can add an id and a style to my DIV this way:<br /><br /><img src="" alt="" width="738" height="35" /><br /><br />This gives us the following HTML:<br /><br /><img src="" alt="" width="621" height="63" /><br /><br />But you probably don't want to use inline styles, instead you want to use a class defined in an external CSS file so designers won't snub you at parties (ignoring for now the fact that developers don't get invited to the same parties as designers). And here's where we run into one of those &quot;Why is life never simple?&quot; issues &ndash; &quot;class&quot; is a C# keyword, and is not allowed in an object initialiser in C#. Which in this particular case is a bit of a shame.<br /><br />You can of course use &quot;Class&quot; instead, but if you're like me you'll recoil at the thought of upper case in attribute names (and justifiably worry about XHTML compliance). My solution was decidedly hacky but it works (although I addressed &quot;class&quot; directly rather than taking a more general approach). I threw in &quot;_class&quot; as well for good measure.<br /><br /><img src="" alt="" width="610" height="235" /><br /><br />In this case the attribute is still specified as &quot;Class&quot; or even the doesn't-mean-anything &quot;_class&quot;, but is then replaced in the TagBuilder's attribute collection by the preferred &quot;class&quot;. You are welcome of course to use a better approach.<br /><br />The end result is a TechnoratiTagList HTML Helper that not only happily generates the appropriate HTML from our tag list string but is also acceptably addressable and stylable, while still producing vanilla HTML without any bloat.<br /><br />And that's nice.<br /><br />The full source of the <a href="" target="_blank">TechnoratiTagList helper can be downloaded from Skydrive</a>.<br /><br /><br /><strong>Download Visual Studio 2008 90 day trial</strong><br />For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Visual Studio webpage</a>. <br /><br /><strong>About the Author</strong><br /><em><img style="margin: 10px" src="\blog\vs2008\intro/kev.jpg" border="0" alt="" width="100" height="149" align="left" />Kevin Daly has been programming professionally for almost 22 years. He has been using .NET and C# continuously since the Beta 2 in 2001, which probably explains the bags under the eyes. Other examples of his views, rants and even the odd code sample can be found on his blog at <a href="" target="_blank" title="Kevin Daly"></a>.&nbsp; He will work for money.&nbsp; He will now stop talking about himself in the third person because it&rsquo;s frankly a bit weird.</em><img src="" height="1" width="1" alt=""/> Visual Studio 2008 and tricksSun, 15 Mar 2009 00:00:00 PDTThis is ultimately going to be a demonstration on how to develop macros to automate <a href="" target="_blank">Visual Studio 2008</a>, but before we get to that I would like to take a second to talk about Visual Studio proper.<br /><br /><strong>Visual Studio Features we can&rsquo;t live without<br /></strong>Developing code with Visual Studio is a breeze compared to other Integrated Development Environments (IDE&rsquo;s) due to the many features it provides: <br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Efficient Navigation:<br /></strong>Visual Studio&rsquo;s Code Editor provides efficient means to navigate around large files (using collapsible code blocks), large projects (using Bookmarks) that contain large numbers of classes and/or properties (using Object Explorer) as well as solutions that contain numerous projects (using Solution Explorer). <br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Syntax Coloring:</strong><br />Coloring the Code Editor&rsquo;s text improves code comprehension, increasing productivity. It&rsquo;s difficult to explain how useful this is &ndash; but it&rsquo;s immediately apparent once you have to do without it when going back to a more primitive code editor.<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Background Compilation:</strong><br />In addition to syntax coloring, Visual Studio provides immediate syntax warnings and errors (as green and red wavy underlines) by compiling newly entered code in the background.<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Code Completion:</strong><br />Many other IDE&rsquo;s provide some form of code completion &ndash; but none as complete and intuitive as IntelliSense.&nbsp; Not only does Visual Studio&rsquo;s code completion system work for all the built in languages (C++, C#, VB.NET, and next year -- in 2010 -- F# and PHP as well) but also XML, CSS, XAML, and any other number of languages for which extensions for Visual Studio are available.<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Code Creation:</strong><br />It was named Visual Studio, rather than Code Studio, or Text Studio, because in addition to the traditional text based way of entering code, it also offers a Visual way of developing the code and metadata necessary to describe UI&rsquo;s, schemas, classes and mappings. <br /><br />It does this by providing intuitive graphical designers for developing UI forms and controls for WinForm, WPF, Web, and Silverlight applications, making the process trivially easy by supporting drag and drop placement of standard and custom controls, separation of design layout code and logic code, with automatic event wiring between the two following the event driven programming model, support for databinding, as well as custom popup property editors and design tasks.<br /><br />In addition to UI designers, Visual Studio provider database schema designers (to graphically create and design database schemas as well as queries), a class designer (to graphically develop or document classes and their interactions), and a mapping designer (to graphically design the mapping between database schemas and the code entities that encapsulate the data).<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Code Commenting:</strong><br />Anybody who has had to pick up and continue the work of others &ndash; or had to go back to their own code after six months -- knows the importance of documentation. Visual Studio&rsquo;s use of XML based comment tags was a fantastic addition to our arsenal. <br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Code Reuse:<br /></strong>Although not a great fan of code snippets (saved templates for repetitive code) because I believe that the increased effort required to create and maintain them introduces code latency (bugs found and fixed in production code are not often reapplied to the original templates as well), Visual Studio offers a built in code snippet creation and management solution. <br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Code Refactoring:</strong><br />Beginning with VS2005, several refactoring tools are built directly into the IDE, which are accessible from the Code Editor&rsquo;s context menu, or the main menu&rsquo;s <em>Refactor</em> menu (which is only visible when the Code Editor has focus).<br /><br />The refactoring tools offered are sparse, but helpful: <br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <strong>Extract Method:</strong> Defines a new method, based on a selection of code statements.<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <strong>Encapsulate Field:</strong> Turns a public field into a private field, wrapping it with a public property.<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <strong>Extract Interface:</strong> Defines a new interface based on the current class&rsquo; public properties and methods.<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <strong>Reorder Parameters:</strong> Provides a way to reorder member parameters, as well as the arguments of all references to it throughout a project.<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <strong>Remove Parameters:</strong> Removes a member&rsquo;s parameter, and the argument from of all references to it throughout a project.<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <strong>Rename:</strong> This allows you to rename a code token (method, field, etc.), and all references to it throughout&nbsp; a project.<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <strong>Promote Local Variable to Parameter:</strong> Moves a local variable to the parameter set of the defining method.<br /><br /><strong>Visual Studio Automation<br /></strong>In addition to the above mentioned features, Visual Studio&rsquo;s IDE is also completely automatable, in much the same way as any Microsoft Office product. Automation is achieved by using the DTE (design-time environment) object model to manage the following: <br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Window objects (used to close, rearrange, or otherwise manipulate open windows)<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Document objects (used to edit text) <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Solution and project objects (used to manage the underlying files and project collection) <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Code-manipulation objects (used to analyze your project&rsquo;s code constructs) <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Tool-window objects (used to configure the IDE&rsquo;s interface) <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Debugging objects (used for tasks such as creating breakpoints and halting execution) <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Event objects (used to react to IDE events) <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Automation can be achieved with full blown Extensions for Visual Studio, or in a more ad-hoc way, using Macros.<br /><br /><strong>Extensions<br /></strong>The exposure of the DTE means that in addition to Visual Studio&rsquo;s built in tools and features (such as Code Snippets and Refactoring tools), one can download and install a whole selection of extension tools. Their quality range from the truly mediocre (and worse) to the very useful.<br /><br /><em><strong>Note:</strong> In many ways, this is Microsoft&rsquo;s distribution strategy: they provide a fantastic extensible shell, with enough features to be better than their competitors, but still leave as much space for 3rd parties to develop extensions to provide additional value. This can sometimes be a little infuriating, as one would sometimes like to see them add features we think of as essential, but also understandable, from their business point of view.<br /></em><br />Two non-free extensions that are constantly highly rated by end users are <a href="" target="_blank">Resharper (R#) v4.1</a> and&nbsp;<a href="" target="_blank">CodeRush</a>. Resharper takes refactoring to a completely higher level, and CodeRush provides a more seamless means of creating, managing, and using code templates.<br /><br /><em><strong>Note:</strong> Although not an extension, if you are satisfied with the code snippet solution provided in Visual Studio 2008, and not interested in using CodeRush, you may be interested in <a href="" target="_blank">Snippet Editor</a>.</em><br /><br />Another extension that is very highly appreciated -- and happens to be free -- is <a href="" target="_blank">Roland Weigelt's GhostDoc</a>, which improves the Code Commenting capabilities of Visual Studio, by automatically documenting your code with text heuristically developed from the name and type of the Property itself, producing output similar to the following:<br /><br /><font face="courier new,courier">#region Properties<br />private Uri _ImagePath;<br /><br />/// <br />/// Gets or sets the image path.<br />/// <br />/// The image path.<br />public Uri ImagePath {<br />&nbsp; get { return _ImagePath; }<br />&nbsp; set { _ImagePath = value; }<br />}<br />#endregion</font><br /><br />Even if GhostDoc can easily be abused to make absolutely useless documentation (garbage in / garbage out) &ndash; it can save an enormous amount of time under certain circumstances. <br /><br /><em><strong>Note:</strong> At the very least it ultimately leads to developers choosing clearer names for their properties and methods &ndash; if only to nudge GhostDoc in the right direction, which adds clarity to code in general.</em><br /><br /><strong>Macros<br /></strong>Finally, even though there are many free and not so free extensions available for Visual Studio, the results they produce may not be to your liking.&nbsp; Sometimes the task you wish to achieve is specific to your work environment, and therefore you never will find an extension that will do it.<br />You could develop your own extension to fulfill your needs, but the development time required to create a full blown extension is not trivial. <br /><br />In many cases the creation of a custom macro is a more appropriate solution.<br /><br /><strong>A Macro to decorate Control Properties with ComponentModel Attributes<br /></strong>An example of an automatable task that would not be worth the trouble of developing a complete extension, but could appropriately be addressed by a macro is the decoration of control properties with ComponentModel attributes.<br /><br />For example, in the above code example, the ImagePath property, if part of a Control, needs to be decorated with at least one or two attributes: <br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; System.ComponentModel.CategoryAttribute<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; System.ComponentModel.DescriptionAttribute<br /><br />and potentially, with:<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; System.ComponentModel.BrowsableAttribute (only required if the public property should be hidden from the Properties Window, since its default value is true anyway)<br /><br />In addition to the above attributes, the following should also be considered (they will depend to some degree on whether the control is for intended for use in WinForms or WebForms): <br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; System.ComponentModel.EditorAttribute<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; System.ComponentModel.DesignerSerializationVisibilityAttribute<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; System.Web.UI.PersistenceModeAttribute<br /><br /><em><strong>Note:</strong>To keep things simple, we won&rsquo;t be addressing these last 3 attributes in this demonstration. <br /><br /></em>The final result could look something like:<br /><font face="courier new,courier"><br />/// <br />/// Gets or sets the image path.<br />/// <br />/// The image path.<br />[<br />Category(&quot;Appearance&quot;),<br />Description(&quot;Gets or sets the image path.&quot;),<br />DefaultValue(null), <br />]<br />public Uri ImagePath { get; set; }</font><br /><br />Leaving this to be done by hand is error prone at best, and the kind of task that an automation macro is perfect for. <br /><br />Let&rsquo;s create one.<br />&nbsp;<br /><strong>Launching the Macro IDE<br /></strong>The process of creating a macro for Visual Studio, will be familiar to anyone who has created macros for Microsoft&rsquo;s Office products (Excel, Word, Outlook, etc.).<br /><br />The Visual Studio&rsquo;s Macro Editor is launched either by pressing <em>Alt-F11</em>, or selecting <em>Tools/Macros/Macro IDE</em>&hellip; from Visual Studio&rsquo;s menu:<br />&nbsp;<br /><img src="" alt="" width="560" height="403" /><br />&nbsp;<br />For this example, we&rsquo;re start by creating a new Module file to contain our public subroutine, and call it <em>XSS_AttributeManagement</em>:<br />&nbsp; <br /><img src="" alt="" width="560" height="504" /><br /><br /><strong>Macros are simply Public Parameter less Methods within Modules<br /></strong>For your macro to be later callable from a Visual Studio button or Shortcut key, it has to be defined as <em>Public</em> and a <em>Sub</em> that takes no arguments, so we&rsquo;ll create in our newly created <em>Module</em>, a <em>Sub</em> called <em>AutoAttributeControlProperty</em>, and as long as its parameter less, and public, it will immediately become visible in Visual Studio&rsquo;s Macro explorer:<br /><br /><img src="" alt="" width="362" height="370" /><br />&nbsp; <br /><strong>The Goal of the Macro<br /></strong>Breaking down the functionality we need to achieve, we need a macro that does basically the following:<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Figures out what Document is currently being shown in the Code Explorer (ie, the DTE.ActiveDocument) <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Figure out the CodeElement the cursor is over<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; See if the CodeElement can be typed as a CodeProperty (rather than a CodeVariable or CodeFunction, or white space within a CodeClass) before continuing.<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Figuring out where the start of the CodeProperty is, and create an EditPoint from it.<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Insert new Attributes at the new EditPoint.<br /><br />The following annotated code does this:<br /><br /><font face="courier new,courier">Imports System<br />Imports EnvDTE<br />Imports EnvDTE80<br />Imports EnvDTE90<br />Imports System.Diagnostics<br /><br />'Add ref to System.Xml Namespace<br />'after having added System.XML.dll<br />'as a Reference to 'MyMacros':<br />Imports System.Xml<br /><br /><br />Public Module XSS_AttributeManagement<br /><br />&nbsp;&nbsp;&nbsp; 'Macro to add Attributes to properties for IDE integration.<br /><br />&nbsp;&nbsp;&nbsp; Sub AutoAttributeControlProperties()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim fileCodeModel As FileCodeModel = _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DTE.ActiveDocument.ProjectItem.FileCodeModel<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Get the current selection, within the<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' current document:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim selection As TextSelection = _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DTE.ActiveDocument.Selection<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' From the selection, get the active point <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' which is the current cursor location:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim point As TextPoint = selection.ActivePoint<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Try to get the code element -- of type Property --<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' at the current location:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim codeElement As CodeElement<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Try<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; codeElement = _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fileCodeModel.CodeElementFromPoint( _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; point, vsCMElement.vsCMElementProperty)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch ex As Exception<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'CodeElementFromPoint is a bit rude, and <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'throws an exception if it doesn't work...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; codeElement = Nothing<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Try<br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'If it's null...then we're not on a Property:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If (codeElement Is Nothing) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox( _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String.Format( _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;Place cursor on a Property before running this macro ('{0}').&quot;, _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Reflection.MethodBase.GetCurrentMethod().Name), _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBoxStyle.Exclamation)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Return<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Good...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'The element we are on is a Property,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'so let's type it for easier subsequent use:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim codeProperty As CodeProperty = codeElement<br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'From the property, extract its name for later use:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim propName As String = codeProperty.Name<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'For comparison purposes only, let's lowercase it:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim propNameLowered = propName.ToLower()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Right...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Let's start trying to fill in the bits...<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'If all goes well, we want a Category and Description<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'for the property:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim category As String = String.Empty<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim description As String = String.Empty<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Note to self...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Is there a Switch/Case in VB.NET ?<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If (propNameLowered.StartsWith(&quot;border&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Appearance&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.StartsWith(&quot;background&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Appearance&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.EndsWith(&quot;width&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Appearance&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.Contains(&quot;color&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Appearance&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.EndsWith(&quot;height&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Appearance&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.Contains(&quot;image&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Appearance&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.EndsWith(&quot;icon&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Appearance&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.StartsWith(&quot;show&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Appearance&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.Contains(&quot;style&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Appearance&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.StartsWith(&quot;allow&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Behavior&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.StartsWith(&quot;use&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Behavior&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf (propNameLowered.EndsWith(&quot;data&quot;)) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; category = &quot;Data&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Right...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'should have a piece of text suitable for a CategoryAttribute<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'But don't yet have a suitable piece of text for a decent<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'DescriptionAttribute...<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'One place I would look for one is try to reuse the description <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'that was already put on the property by the programmer...<br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Did the Property have a comment already associated to it?<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If (codeProperty.DocComment &lt;&gt; String.Empty) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Yes...the Property has an associated comment...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'so, theoretically, it should <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'be an Xml document that can be parsed...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'So load it up!<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim xmlDoc As System.Xml.XmlDocument = _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; New System.Xml.XmlDocument()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlDoc.LoadXml(codeProperty.DocComment)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'And look for a node called summary:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim xmlNode As System.Xml.XmlNode = _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlDoc.SelectSingleNode(&quot;//summary&quot;)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Not (xmlNode Is Nothing) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'If there was a node, then we want the inner text<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'we don't want any para tags or other stuff <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'in the DescriptionAttribute:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; description = xmlNode.InnerText<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'And we don't want newlines that will cause havoc<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'with the built in Xml documentation:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; description = _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; description.Replace(System.Environment.NewLine, &quot;&quot;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Where are we?<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'We have a Category and we have a Documentation <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '(although both could be string.Empty...)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Let's inject it in...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim indentLevel As Integer = 2<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'We want to insert attributes just above <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'the code description, but under any <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'code comments that may or may not <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'already be there...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim insertPoint As EditPoint = _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; codeProperty.StartPoint.CreateEditPoint()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'insertPoint.LineUp(1)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(&quot;[&quot;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(System.Environment.NewLine)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Indent(Nothing, indentLevel)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(&quot;#if (!CE) &amp;&amp; (!PocketPC) &amp;&amp; (!pocketPC) &amp;&amp; (!WindowsCE)&quot;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(System.Environment.NewLine)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Indent(Nothing, indentLevel)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(&quot;// Attributes not available in Compact NET&quot;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(&quot; (cf: DesignTimeAttributes.xmta)&quot;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(System.Environment.NewLine)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Indent(Nothing, indentLevel)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(&quot;System.ComponentModel.Browsable(true),&quot;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(System.Environment.NewLine)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Indent(Nothing, indentLevel)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(String.Format(&quot;System.ComponentModel.Category(&quot;&quot;{0}&quot;&quot;),&quot;, category))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(System.Environment.NewLine)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Indent(Nothing, indentLevel)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(String.Format(&quot;System.ComponentModel.Description(&quot;&quot;{0}&quot;&quot;),&quot;, description))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(System.Environment.NewLine)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Indent(Nothing, indentLevel)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(&quot;#endif&quot;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(System.Environment.NewLine)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Indent(Nothing, indentLevel)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(&quot;System.ComponentModel.DefaultValue(null), //TODO:Set this.&quot;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(System.Environment.NewLine)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Indent(Nothing, indentLevel)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(&quot;]&quot;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Insert(System.Environment.NewLine)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertPoint.Indent(Nothing, indentLevel)<br />&nbsp;&nbsp;&nbsp; End Sub<br /><br />End Module<br /><br /></font>You&rsquo;ll notice that the code references the <em>System.Xml</em> namespace to extract the property&rsquo;s description &ndash; but the <em>System.XML.dll</em> assembly is not automatically referenced by the Macro environment, so you first will have to add the reference to your project before it will be useable:<br />&nbsp;<br /><img src="" alt="" width="560" height="505" /><br />&nbsp;<br /><strong>Taking your Macro out for a first spin<br /></strong>Once that has been accomplished, your module should compile, and you&rsquo;re ready to take it for a test run.&nbsp; Return to your User Control&rsquo;s definition in Visual Studio proper, click anywhere within the Property we intend to decorate, and invoke the Macro by clicking the macro&rsquo;s name in the Macro Explorer: <br />&nbsp;<br /><img src="" alt="" width="362" height="370" /><br /><br />If all works out as intended, it analyses the code under the cursor, and fills in the missing attributes.<br /><br /><font face="courier new,courier">#region Properties<br />/// <br />/// Gets or sets the image path.<br />/// <br />/// The image path.<br />[<br />#if (!CE) &amp;&amp; (!PocketPC) &amp;&amp; (!pocketPC) &amp;&amp; (!WindowsCE)<br />// Attributes not available in Compact NET (cf: DesignTimeAttributes.xmta)<br />System.ComponentModel.Browsable(true),<br />System.ComponentModel.Category(&quot;Appearance&quot;),<br />System.ComponentModel.Description(&quot;Gets or sets the image path.&quot;),<br />#endif<br />System.ComponentModel.DefaultValue(null), //TODO:Set this.<br />]<br />public Uri ImagePath { get; set; }<br />#endregion<br /></font>&nbsp;<br />&nbsp;<br /><strong>Making it easier to invoke the Macro: creating a custom Toolbar Button<br /></strong>When you have debugged and tweaked the macro to your satisfaction, it&rsquo;s probable you will wish to have it available for use in the future. <br /><br />Although the Macro Explorer is perfectly suitable, you may prefer a faster way to invoke the macro, such as creating a button for it.<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; select from the menu <em>Tools</em>, then <em>Customize</em>. <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Pick the <em>Command</em> Tab from the <em>Customize</em> dialog that comes up. <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Select <em>Macros</em> from the <em>Categories</em> list, and the macro you just created from the <em>Commands</em> list:<br />&nbsp;<br /><img src="" alt="" width="560" height="439" /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Drag and drop the macro on to any menu bar:<br /><br /><img src="" alt="" width="500" height="374" /> <br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Right-click the new button you&rsquo;ve just created, and use the context menu to change the button&rsquo;s name and icon:<br />&nbsp;<br /><img src="" alt="" width="500" height="410" /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Close the Customize dialog, to see the results:<br />&nbsp; <br /><img src="" alt="" width="225" height="150" /><br /><br />Click your new button while the cursor is within a Property in the Code Editor&hellip;presto!<br /><br /><strong>Better Yet &ndash; Hook it up as a Keyboard Shortcut<br /></strong>Buttons are fun&hellip;but not as practical as keyboard shortcuts. <br /><br />To hook your Macro up to a keyboard shortcut, do the following: <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Select <em>Tools</em>, <em>Options</em><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; In the Options dialog that pops up, expand the Environment, and select Keyboard<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; In the text box labelled Show commands containing, start typing the word &lsquo;macro&rsquo;, then the name of your macro, the macro becomes highlighted in the list below. Select it.<br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Update the value within the Use new shortcut in&nbsp; dropdown to state Text Editor.&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Within the Press shortcut keys press a key combination. I chose Ctrl-Shift-Alt-D, as it was very similar to GhostDoc&rsquo;s Ctrl-Shift-D:<br /><br /><img src="" alt="" width="560" height="324" /> <br /><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; Hit Ok, and give it a spin. <br /><br /><strong>Where to go from here<br /></strong>The above Sub macro was intentionally kept simple in order to introduce the concept of macro development. <br /><br />One can add more complex logic to add the other attributes mentioned, namely System.ComponentModel.EditorAttribute, System.ComponentModel.DesignerSerializationVisibilityAttribute and System.Web.UI.PersistenceModeAttribute.<br /><br />There are many macro samples online to help you get where ever you wish to go, including <a href="" target="_blank">some examples at my website</a> you may find useful getting started.&nbsp; <br />&nbsp;<br />Links:<br />&nbsp;&nbsp;&nbsp;&nbsp; <a href="" target="_blank">Visual Studio 2008</a><br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Visual Studio Features:<br /></strong>&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank"></a>&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">Refactoring C# Code Using Visual Studio 2005</a><br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Visual Studio 3rd Party Language Packages:</strong><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; PHP for Visual Studio:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="" target="_blank"><br /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="" target="_blank"><br /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="" target="_blank">Phalanger, PHP for .NET: Introduction for .NET developers<br /></a><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Visual Studio Extensions:<br /></strong>&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">Visual Studio Gallery of Extensions for Visual Studio</a><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">Visual Studio Add-Ins Every Developer Should Download Now</a><br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Other Editors:<br /></strong>&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">Emonics</a><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank"></a><br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Development Resources:<br /></strong>&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">My blog&rsquo;s Visual Studio Macro posts</a><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">Automation and Extensibility Reference</a><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">EnvDTE Namespace</a><br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; <strong>Attributes for properties in Control development:<br /></strong>&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">System.ComponentModel.CategoryAttribute</a><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">System.ComponentModel.DescriptionAttribute</a><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">System.ComponentModel.BrowsableAttribute</a> <br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">System.ComponentModel.EditorAttribute</a><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">System.ComponentModel.DesignerSerializationVisibilityAttribute</a><br />&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp;&nbsp;&nbsp; <a href="" target="_blank">System.Web.UI.PersistenceModeAttribute</a><br />&nbsp;&nbsp;&nbsp;&nbsp; <br /><strong>Download Visual Studio 2008 90 day trial</strong><br />For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio webpage</a>. <br /><br /><strong>About the Author<br /></strong><a href="" target="_blank">Sky Sigal</a> has been programming on and off for 25 years, over 10 of those professionally, creating enterprise solutions in various languages, on different platforms. You can read about what he's currently taking apart and putting back together at <a href="" target="_blank"></a>. <br />&nbsp;<img src="" height="1" width="1" alt=""/> Azure Table Storage - Getting Started - Part 2 and tricksTue, 03 Mar 2009 23:00:00 PSTIn <a href="" target="_blank">Part 1</a>, we went through the basics of Windows Azure Table Storage. In Part 2, we will be creating a simple application to demonstrate the Windows Azure Table Storage. <br /><br />The sample application we are going to create is a small guestbook app which will allow your site visitors to enter some information.<br /><br /><strong>Creating the Project</strong><br /><br />Open <a href="" target="_blank">Visual Studio 2008</a> and create a Web Cloud Service project.<br />&nbsp;<br /><img src="" alt="" width="808" height="571" /><br /><br /><strong>Updating Service Definition<br /></strong><br />The first step to do is to update the service definition and service configuration files to include the storage account. Edit your service definition file found in the Guestbook project and enter these settings<br /><br /><img src="" alt="" width="567" height="219" /><br /><br /><strong>AccountName</strong><br /><br />This specifies your Windows Azure account name<br /><br /><br /><strong>AccountSharedKey<br /></strong><br />The shared key used to authenticate requests made against your Windows Azure account<br /><br /><strong>TableStorageEndpoint<br /></strong><br />The base URI of the table storage service<br /><br /><strong>Updating Service Configuration<br /></strong><br />After setting the properties in our service definition, we need to set the values of those properties in our service configuration file found in the Guestbook project<br /><br /><img src="" alt="" width="698" height="219" /><br />&nbsp;<br /><strong>AccountName <br /></strong><br />devstoreaccount1<br /><br /><strong>AccountSharedKey<br /></strong>&nbsp;<br />Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==<br /><br /><strong>TableStorageEndpoint<br /></strong><br /><br /><br />All the values reflect your local development storage and nothing in the cloud. The development storage supports only the above fixed account and is same for everyone.<br /><br />We should be able to test our azure application locally in the local development storage before deploying it to the cloud.&nbsp; Testing your application locally will also help you to debug your applications.<br /><br /><strong>Creating&nbsp; the Table Schema<br /></strong><br />Defining the table schema is as easy as creating classes. The idea here is to create a class, where the class name corresponds to the table name and the properties correspond to the table properties. The local development storage environment uses ADO.NET to create tables in the local environment, whereas this is not needed when we host our application in the cloud.<br /><br />Creating these classes are made simple by using the StorageClient library provided in the Windows Azure SDK<br /><br /><img src="" alt="" width="572" height="269" /><br />&nbsp;<br />You can add the StorageClient project to our Guestbook solution or just reference the library.<br /><br />Below is our class which represents the Guestbook table:<br /><br /><img src="" alt="" width="244" height="201" /><br />&nbsp;<br />As you can see in the above screenshot, our class <strong>GuestDataModel</strong> inherits <strong>TableStorageEntity</strong>. This <strong>TableStorageEntity</strong> class is available in the StorageClient library and defines some of the properties such as partition key and row key that is required for each entity in the table.<br /><br />The GuestDataModel consists of three properties:<br /><br />1) Message<br />2) Name<br />3) Url<br /><br />And our simple constructor where we initialize the partition key and row key:<br /><br /><img src="" alt="" width="467" height="201" /><br />&nbsp;<br />As the local storage uses ADO.NET we are going&nbsp; to create class <strong>GuestDataServiceContext</strong> which inherits from&nbsp; TableStorageDataServiceContext from the StorageClient library. The <strong>TableStorageDataServiceContext </strong>represents the runtime context of our ADO.NET service.<br /><br /><img src="" alt="" width="631" height="292" /><br />&nbsp;<br />Now having the data model and the data context in place, its very easy to query our storage and perform the usual insert, delete operations<br /><br />We create a <strong>GuestDataSource</strong> which is going to help interact with the data context and insert, delete and get all the <strong>GuestDataModel</strong> entities<br />&nbsp;<br /><img src="" alt="" width="745" height="452" /><br /><br />As you can see, it's pretty straight forward. Below are insert and delete methods:<br />&nbsp;<br /><img src="" alt="" width="675" height="386" /><br /><br /><strong>Creating our Tables<br /></strong><br />We saw how to insert, delete and get all our entities from the table using a simple data source, but where are we actually creating the table?<br /><br /><img src="" alt="" width="668" height="130" /><br /><br />We are going to create the table on the first request to the website which can be done by adding the appropriate code into the global application class. <br />&nbsp;<br /><strong>Executing this guestbook sample<br /></strong><br />Executing this guestbook sample is just as same as executing a normal application! Hit <strong>F5</strong> and <a href="" target="_blank">Visual Studio 2008</a> will take care of everything - from starting the local development storage, creating the tables and debugging the application.<br /><br />Below is a screenshot of our guestbook app:<br /><br /><img src="" alt="" width="605" height="251" /><br />&nbsp;<br /><strong>Deploying Guestbook to the Cloud<br /></strong><br />To deploy this sample in the cloud, you should have a Windows Azure storage account. For more information on deploying a service on Windows Azure, <a href="" target="_blank">visit here</a>.<br /><br />I have already deployed this application to the cloud. So, if you are interested to try it out, please visit <a href="" target="_blank"><br /></a><br />You can download the Guestbook sample below:<br />&nbsp;<br /><a href="" target="_blank"><img src="" alt="" width="319" height="143" /></a><br /><br /><a href="" target="_blank">Visual Studio 2008</a> simplifies building Windows Azure applications using the Windows Azure tools for Visual Studio. It also allows us to debug Windows Azure applications.<br /><br /><strong>Download Visual Studio 2008 90 day trial</strong><br />For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio webpage</a>. <br /><br /><strong>About the Author<br /></strong><img src="" border="0" alt="" align="left" /><em>Chaks is currently working for Intergen as a Software Developer. Chaks works extensively in Microsoft Platform. His knowledge covers various Microsoft Technologies like WCF, SharePoint, Windows Azure, ASP.NET. Chaks also writes for <a href="" target="_blank">Neowin</a>, one of the Microsoft featured communities. You can contact Chaks via his blog - <a href="" target="_blank">Chaks' Corner</a></em>.<img src="" height="1" width="1" alt=""/> Azure Table Storage - Getting Started - Part 1 and tricksSun, 01 Mar 2009 23:00:00 PSTWindows Azure provides simple data storage services like blobs, tables and queues to store your data in the cloud. These can be accessed using a Windows Azure Storage Account.<br /><br /><img src="" alt="" width="687" height="130" /><br />&nbsp;<br />In this Part 1, we are going to look into the Windows Azure Table Storage which provides a structured storage in the cloud.<br /><br /><strong>Pre-requisites<br /></strong>1) To get started with Windows Azure programming, you can have a <a href="" target="_blank">read at my previous blog post</a><br />2) You need to have a Windows Azure Storage Account to program Windows Azure Storage. You can <a href="" target="_blank">apply for one here</a><br /><br /><strong>Check your Table Service in the Development Storage<br /></strong>Using the Development Storage tool,&nbsp; Azure SDK simulates the Azure Tables in your local machine than in the cloud. The Table Service may fail to start and you won't be able to choose a proper Table Service Database. None of the SDK samples which uses the local Table Service would also not work.<br /><br />The problem is that running the Development Storage tool initially created the Database (DevelopmentStorageDB)&nbsp; (Azure SDK searches for a .\SQLEXPRESS instance by default) , but not the required Schemas. To install the required schemas, Traverse to where you had extracted the SDK Samples and execute the <em>rundevstore.cmd</em> script<br />&nbsp;<br /><img src="" alt="" width="419" height="384" /><br /><br />Running the above script will create the necessary schemas for the SDK samaples and also will start the Table Service in your Development Storage<br />&nbsp;<br /><img src="" alt="" width="615" height="214" /><br /><br /><strong>Windows Azure Table Storage<br /></strong><br /><img src="" alt="" width="455" height="323" /><br /><br /><br />&bull; Each account has a Table<br />&bull; The Table has an Entity<br />&bull; An Entity contains Columns<br />&bull; Entity can be considered to be the row and Columns as values<br />&bull; An Entity always contains these properties: <br />&nbsp;&nbsp; o Partition Key<br />&nbsp;&nbsp; o Row Key<br />&nbsp;&nbsp; o Timestamp<br />&bull; The Partition Key and Row Key identify a row or an Entity<br /><br />As you may have guessed it already, partition key and row key is the first column of your table. All entities in a table with the same partition key value live in the same partition.<br /><br />However, you can use either partition key or row key or both or do not use both. <br /><br />Here is a simple guide on how to use partition key and row key<br /><br /><em><strong>PK=empty, RK=empty</strong></em> - One partition, One row<br /><em><strong>PK=data, RK=empty</strong></em> - Multiple partitions, One row per partition<br /><em><strong>PK=empty, RK=data</strong></em> - One partition, Multiple rows for the one partition<br /><em><strong>PK=data, RK=data</strong></em> - Multiple partitions, Multiple rows for each partition<br /><br />In our next blog post, we shall get into developing the sample guestbook application.<br /><br /><a href="" target="_blank">Visual Studio 2008</a> simplifies building Windows Azure applications using the Windows Azure tools for Visual Studio. It also allows us to debug Windows Azure applications.<br /><br /><strong>Download Visual Studio 2008 90 day trial</strong><br />For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio webpage</a>. <br /><br /><strong>About the Author<br /></strong><img src="" border="0" alt="" align="left" /><em>Chaks is currently working for Intergen as a Software Developer. Chaks works extensively in Microsoft Platform. His knowledge covers various Microsoft Technologies like WCF, SharePoint, Windows Azure, ASP.NET. Chaks also writes for <a href="" target="_blank">Neowin</a>, one of the Microsoft featured communities. You can contact Chaks via his blog - <a href="" target="_blank">Chaks' Corner</a></em>.<img src="" height="1" width="1" alt=""/> and XSLT in Visual Studio 2008 and tricksSat, 21 Feb 2009 23:00:00 PST<a href="" target="_blank">Visual Studio 2008</a> has some great support for debugging XML and XSLT. It is not a well-known piece of functionality but it is there and although simple it does its job well.<br /><br />XSLT is not a difficult technology to grasp but when you don&rsquo;t have a decent IDE to back you up debugging can be long and painful and impair productivity.<br /><br />In this article I&rsquo;ll cover off the very basics and provide a few useful tips. <br /><br /><strong>A Simple Example<br /></strong><br />Here's a simple example. I have a piece of XML that defines some static content:<br /><br /><img src="" alt="" width="346" height="100" /><br /><br />I want to do is render this page as HTML. The XSLT looks like this:<br /><br /><img src="" alt="" width="477" height="299" /><br /><br />After opening each of these in <a href="" target="_blank">Visual Studio 2008</a>, you&rsquo;ll notice an &ldquo;XML&rdquo; top-level menu. Clicking this will give you the options of debugging the transformation or showing the output.<br /><br />&nbsp;<br /><img src="" alt="" width="175" height="148" /><br />XML file selected<br />&nbsp;<br /><br /><img src="" alt="" width="174" height="123" /><br />XSLT file selected<br /><br />Selecting &ldquo;Debug XSLT&rdquo; will display an Open File dialog letting you select the other file to complete the transformation. For example, if you have an XML file selected then you will select an XSLT file for the transformation.<br /><br />The output will be:<br /><br /><img src="" alt="" width="298" height="170" /><br /><br />(The parameter value hasn&rsquo;t been picked up in this instance, but I&rsquo;ll get to that shortly.)<br /><br />Along the way you&rsquo;ll get many of the usual debugging aids you are used to; stepping and value inspection.<br />&nbsp;<br /><img src="" alt="" width="499" height="337" /><br /><br />And that&rsquo;s all there is to it, really.<br /><br /><strong>Tip #1 XML or XSLT First?<br /></strong><br />Whether you start with the XML or the XSLT you end up with transformed XML. The IDE remembers the second file selected so you can repeat the transformation.&nbsp; Unless you close the first file you do not get a chance to reselect the second file to complete the transformation.<br /><br />If you have one example of XML but several XSLTs then select each XSLT first. As you initiate each transformation for the first time select the same XML file. Each time you modify the XSLT or XML you can simply re-run the transformations.<br /><br />In the opposite scenario when you have you have one XSLT and multiple XML examples select each XML and when given the option select the XSLT file.<br /><br /><strong>Tip #2 Including XSLT<br /></strong><br />Your solution may end up using several XSLT files some of which may be dependent on others.<br /><br /><img src="" alt="" width="397" height="27" /><br /><br />Be aware that Visual Studio resolves such dependencies without you having to do anything. When it comes to using these XSLTs in your application you will have to ensure that dependent XSLTs can get picked up.<br /><br />Just for the record, use the XslCompiledTransform class and call the Transform method.<br /><br />public void Transform(<br />&nbsp; XmlReader input,<br />&nbsp; XsltArgumentList arguments,<br />&nbsp; XmlWriter results,<br />&nbsp; XmlResolver documentResolver)<br /><br />You will have to derive a class from XmlResolver with appropriate logic to locate any additional XSLTs.<br /><br /><strong>Tip #3 Parameters Workaround</strong><br /><br /><img src="" alt="" width="274" height="21" /><br /><br />When it comes to passing parameters to an XSLT you have a little more work to do.<br /><br />Place a breakpoint at the start of the XSLT and start debugging. In your Locals window the parameter will show up letting you edit the value.<br /><br />When the appropriate element is reached this will pick up your edited parameter value.<br /><br /><strong>Tip #4 Ignore the times in the Output window<br /></strong><br />After running a transformation two times are shown in the Output window.<br /><br /><img src="" alt="" width="325" height="70" /><br /><br />Ignore both of these. The load time isn&rsquo;t really all that important and the execution time is misleading.<br /><br />When you work with XSLT in the .NET Framework (2.0 and later) you'll be using the XslCompiledTransform class. This class compiles the XSLT into IL and then jitters it on its first run. Visual Studio repeats this process in its entirety each time. Your application however, will probably take advantage of the compiled nature of the class and all transformations thereafter will only take one or two milliseconds.<br /><br /><strong>Summary<br /></strong><br />&bull;&nbsp;&nbsp;&nbsp; Visual Studio 2008 has some lightweight, but effective support for developing XML and XSLT.<br />&bull;&nbsp;&nbsp;&nbsp; Choosing whether to debug XML or XSLT can be an important choice for productivity.<br />&bull;&nbsp;&nbsp;&nbsp; Parameters can be achieved.<br />&bull;&nbsp;&nbsp;&nbsp; The final XSLT will transform faster in your application than in the IDE.<br /><br /><strong>Further Reading<br /></strong><br />Intellisense for XSLT: As I was putting this post together I came across <a href="" target="_blank">this article</a>. Although I haven&rsquo;t implemented this myself it looks good for productivity. I'll investigate further at some point, you may want to as well.<br /><br />Profiling XSLT: If you are lucky enough to have the Developer Edition of <a href="" target="_blank">Visual Studio 2008</a> there is a profiler add-in that you can add to Visual Studio. <a href="" target="_blank">This article</a> covers the profiler in detail. This is well worth pursuing if your solution has a lot of XSLT you think may be a bottleneck.<br /><br /><br /><br /><strong>Download Visual Studio 2008 90 day trial</strong><br />For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio webpage</a>. <br /><br /><strong>About the Author<br /></strong><img style="margin: 10px" src="" border="0" alt="" width="180" height="151" align="left" /><em>Scott is a C# developer. He takes great pleasure in producing more business value for less code. <br /><br />He&rsquo;s always on the look-out for better and more elegant ways of doing things and uses these in any one of the dozen or so side-projects he has on the go. Genuinely appreciates being told better ways of doing things and actively seeks such criticism.<br /><br />&bull; <a href="" target="_blank"></a> (technical)<br />&bull; <a href="" target="_blank"></a> (personal)<br />&bull; <a href="" target="_blank"></a> (a work in progress that isn&rsquo;t working)<br /><br /></em><img src="" height="1" width="1" alt=""/> to New SQL Server Data Services and tricksWed, 18 Feb 2009 23:00:00 PST<strong>Web-based Data Storage in a Cloud<br /></strong>This document is for developers with at least a basic idea of what &quot;Cloud Computing&quot; is and are familiar with Microsoft developer tools (e.g. <a href="" target="_blank">Microsoft Visual Studio 2008</a>). You must have experience designing and/or implementing systems deployed in &quot;traditional&quot; hosted environments.<br /><br /><strong>Overview of Windows Azure Services Platform<br /><em><br />Windows Azure Platform at a Glance<br /></em></strong>The Windows Azure Platform consists of infrastructure and APIs sourced from Microsoft, which allow developers to integrate new web developments on top of this platform.&nbsp; <br /><br />In turn, these new tools that you create can either be standalone applications, or add-ins into Microsoft's other popular end-user applications such as Office Live, Exchange Online or SharePoint Online.<br /><br /><img src="" alt="" width="360" height="200" /><br /><br /><em><strong>What Do I Get &quot;in the Box&quot;?</strong></em><br />By hooking into the functionality exposed by the Azure platform, developers are able to take advantage of such services as Live Services (for Identity, Contacts &amp; Devices), .NET Services (for Service Bus, Workflow and Access Control) and SQL Services (for Database, Analytics and Reporting).<br /><br />Windows Azure will manage the process of deploying and localising storage.&nbsp; It will also manage the process of load balancing.&nbsp; You just code the application.&nbsp; Microsoft (via Azure) will maintain the infrastructure.<br />&nbsp;<br /><img src="" alt="" width="360" height="250" /><br /><br /><strong>Overview of Microsoft SQL Server Data Services (SSDS)<br /></strong><br /><em><strong>SQL Services - Extending the SQL Data Platform to the Cloud<br /></strong></em>SQL Services are the data services tier of the Azure Services Platform.&nbsp; They are built on Microsoft SQL Server foundation, with broad data platform capabilities as a service such as friction-free provisioning and scaling;&nbsp; and significant investments in scale, high availability, lights-out operation, and total cost of ownership.<br /><br />At this stage of the Beta programme, only the database and Data Sync functions are offered.<br /><br /><img src="" alt="" width="267" height="200" /><br />&nbsp;<br /><em><strong>Your Data Any Place, Any Time<br /></strong></em>This tag line from Microsoft means your data can follow you around. There are 3 propositions to make this happen:<br /><br /><ul><li>Agility means there is no schema.&nbsp; This means you code using completely flexible entities. </li><li>Scalability means future growth is built in (and can be scaled back and forth daily, if your usage rate requires it). </li><li>SLA means Microsoft will guarantee availablity, reliability and security. </li></ul><br /><img src="" alt="" width="560" height="285" /> <br /><br /><strong>Shape of the Service<br /></strong><br /><em><strong>SSDS Service Architecture<br /></strong></em>SSDS is Microsoft's response to the question &quot;How to extend SQL Server to the Cloud?&quot; and implemented in the mid-tier.&nbsp; The conceptual service architecture model is your client application will interact with the SSDS storage tier via either REST or SOAP (your choice) web calls. <br /><br />The SSDS Feature Areas are:<br /><ul><li>Data and Storage Models </li><li>Web service API (REST, SOAP, resource and formats) </li><li>Provisioning </li><li>Query Model </li><li>Security </li></ul><img src="" alt="" width="560" height="317" /><br /><br /><em><strong>The ACE Concepts<br /></strong></em>- Authority <br /><ul><li>Unit of geo-location and billing </li><li>Collection of containers </li></ul><br />- Container <br /><ul><li>Unit of consistency/search </li><li>Collection of entities </li><li>No schema requried </li></ul><br />- Entity <br /><ul><li>Property bag or name/value pairs </li><li>Unit of update/change </li><li>No schema </li></ul><br /><img src="" alt="" width="280" height="323" /><br /><br /><em><strong>Concepts: Entity<br /></strong></em>- Flexible Entity Model <br /><ul><li>No schema required </li><li>Smallest unit of storage (unit of update) </li></ul><br />- Metadata properties <br /><ul><li>ID - unique name within parent container </li><li>Kind - track user type (e.g. JobListing, Resume, Car, Circle, etc) </li><li>Version - update timestamp on each operation </li></ul><br />- Flex properties <br /><ul><li>Can change instance type or add additional properties </li><li>Support for simple types: decimal, string, blob, etc. </li><li>All properties are indexed </li></ul><img src="" alt="" width="560" height="265" /> <br /><br /><em><strong>REST Support<br /></strong></em>- Representational State Transfer <br /><ul><li>Pure HTTP-based solution </li><li>All resources are directly accessible from Internet URLs </li><li>HTTP Verbs mapped directly to SSDS operations (UML: Create, Read, Update, Delete; SQL: INSERT, SELECT, UPDATE, DELETE; REST: POST, GET, PUT, DELETE)</li></ul><br />- Very broad accessibility from almost any environment <br />- Simple XML-based payloads or plain old XML (POX) <br /><br /><em><strong>Query Language<br /></strong></em><ul><li>Textual query language through Web-service head, passed in as literal text string </li><li>Lanuage patterned after C# LINQ syntax </li><li>Operator semantics handles variant values </li><li>Query supported over metadata and data properties </li></ul><strong>About the beta<br /></strong>There is a Technical Preview available now:<br /><br />- Open release of the desktop software development kit <br />- Limited preview of the cloud infrastructure with free usage and quotas <br />- Key Features <br /><ul><li>Virtual machines with dedicated resources </li><li>Automated service management </li><li>Simple service architectures </li><li>Microsoft ASP.NET Web sites, managed code &quot;workers&quot; </li><li>Storage </li><li>Single, large data centre on the US West Coast </li></ul><br /><strong>SSDS Takeaways<br /></strong><ul><li>Scale, cost and operations excellence </li><li>Learn about customer and partner usage patterns </li><li>Built on proven Windows Server and SQL Server technology </li><li>Industrial strength servers; years of experience running large-scale MSN and Windows Live services </li><li>Novel distributed data fabric for massive scale out and lights-out operation </li><li>Service will evolve based on feedback and partnerships </li></ul><br /><br /><strong>For More Information<br /><em>Blogs <br /></em></strong><a href="" target="_blank"></a> <a href="" target="_blank"><br /></a><br /><a href="" target="_blank"></a><br /><br /><em><strong>Landing pages <br /></strong></em><a href="" target="_blank"></a><br /><a href="" target="_blank"></a><br /><a href="" target="_blank"></a><br /><br /><br /><strong>Download Visual Studio 2008 90 day trial</strong><br />For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio webpage</a>. <br /><br /><strong>About the Author<br /></strong><img style="margin: 10px" src="" border="0" alt="" align="left" /><em>James Hippolite started programming in 1983 on an Apple IIe, at the age of 14. After graduating with a bachelor degree in Information Systems from Victoria University of Wellington in New Zealand in 1990, he started working with small systems relational databases, like dBase, Paradox, FoxPro and finally Microsoft Access. <br /><br />In 1991 he founded Mana Information Systems, a company for SME who couldn&rsquo;t afford their own IT departments. As the lead developer, he developed small to medium WinForms applications using SQL Server, Visual Basic and latterly ASP.&nbsp; In 2003 James developed in C# his first .NET web application, an internal metrics reporting tool for his new employer, Telecom New Zealand, utilising SQL Server stored procedures and .NET classes. <br /><br />Due to the worldwide success of SubSonic, James converted in 2008 to this O/R mapper, which is currently one of the market-leading data-access solutions for .NET, C# and VB.NET. James has been a trainer and contributed lectures on Microsoft Certification and SQL Server Reporting Services to the .NET community.&nbsp; James has received for his community efforts no MVP reward (yet). <br /><br />He lives in Wellington and is currently employed full time in a large corporate and loving the regular hours that non-consultants enjoy.<br /><br /><br /></em><img src="" height="1" width="1" alt=""/> the Visual Studio 2008 Profiler and tricksMon, 16 Feb 2009 23:00:00 PSTSo you&rsquo;ve got a performance problem?&nbsp; Your application is taking up far too much memory, or it&rsquo;s running far too slowly?<br /><br />Sometimes this is easy to diagnose: the problem code path consists of a nice simple sequence of method calls whose timings are easily measured with a bit of Stopwatch action and a few Debug.WriteLine calls.&nbsp; When you find that the Sort method is taking 30 seconds and everything else is taking milliseconds, it&rsquo;s pretty obvious what needs fixing.<br /><br />Sometimes, however, the cause is more mysterious.&nbsp; Okay, Sort is taking 30 seconds, but there&rsquo;s nothing obvious in the Sort method that explains why it should be taking 30 seconds.&nbsp; Too many developers roll up their sleeves, guess where the problem must &ldquo;obviously&rdquo; be (&ldquo;Maybe it&rsquo;s because it allocates a lot of Point objects!&rdquo;), and dive in.&nbsp; Sometimes this works.&nbsp; <br /><br />More often, they spend hours turning nice simple code into a horribly complicated mess (&ldquo;Let&rsquo;s implement our own Point class, make it a mutable reference type and have a pool of them we can reuse them instead of allocating new ones!&rdquo;), and end up shaving off a fraction of a percent &ndash; or even making things worse.&nbsp; (If you catch a colleague proposing to unroll a loop in order to make it go faster, call security and have them gently escorted away from their keyboard.)<br /><br />Wiser developers know that their intuition about performance can easily lead them astray.&nbsp; So instead they use a profiler to measure where the application is spending its time or allocating its memory.&nbsp; A profiler can tell you information like how many times each method is called, how much time is spent in any given method, how many objects are alive and how much memory they&rsquo;re taking up.&nbsp; Guided by these measurements, developers can focus their attention where it&rsquo;s going to have a real effect &ndash; on a bug or a method or class that doesn&rsquo;t scale, or an algorithm that is leaking references.<br /><br />Profiling your application used to require third-party tools, but <a href="" target="_blank">Visual Studio 2008</a> includes a profiler (though not in all editions).&nbsp; So now there&rsquo;s no excuse for guessing instead of measuring.<br />Let&rsquo;s look at an example.&nbsp; <br /><br />Unfortunately, it&rsquo;s a bit hard to come up with a performance problem that&rsquo;s easy enough to explain in a blog post but hard enough to require a profiler to diagnose, so the example I&rsquo;m going to use is embarrassingly artificial &ndash; so bear in mind that the point is to illustrate the use of the profiler, not to crack a real-world problem!<br /><br />Our scenario is a program which, given a number n, creates string of asterisks whose lengths are the first n Fibonacci numbers and saves these to disk, presumably as part of some sort of research into whether file system drivers get bored.&nbsp; (I did say it was artificial.)&nbsp; <br /><br />It runs fine in all our test cases, but users are reporting that when n is 40 or more, the program appears to hang, chewing up 100% of the CPU.&nbsp; We do some testing of our own and find that we can reproduce the problem.&nbsp; Now to track it down!<br /><br />Here&rsquo;s the code for the program:<br />&nbsp;&nbsp;&nbsp; private static void SaveFibonacciStrings(int maxIndex)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 1; i &lt; maxIndex; ++i)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string s = Stringonacci(i);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string filename = String.Format(&quot;fibo{0:3}.txt&quot;, i);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Save(s, filename);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; } <br /><br />The program constructs each string, then saves it to a suitably named file.&nbsp; So which bit is slow, the construction or the saving?<br /><br />Clearly this example is trivial enough that we could answer this using the &ldquo;Stopwatch and Debug.WriteLine&rdquo; technique, but let&rsquo;s use the profiler anyway.&nbsp; You can find this on the Analyze menu, and you can launch it in a number of ways.&nbsp; The easiest way to get started is the Launch Performance Wizard command.<br /><br />The Performance Wizard first asks you which project you&rsquo;d like to profile, and reminds you to switch the configuration to Release, because a debug build may have distorted performance characteristics, for example because of the debugger keeping objects alive for longer, or because certain optimisations are turned off in debug mode.<br /><br />Then the wizard asks whether you&rsquo;d like to profile using sampling or instrumentation.&nbsp; Sampling is an relatively coarse technique which involves taking snapshots of the program, like clicking the Pause button every so often and having a look at the call stack; instrumentation is finer grained but more intrusive and more heavyweight, like adding logging code into the program to record and time every method entry or exit.<br /><br /><img src="" border="0" alt="" width="433" height="373" /><br /><br />For this example, we choose Sampling and finish the wizard.<br />When we return to Visual Studio, we find a new window displayed: Performance Explorer.&nbsp; Right now, there&rsquo;s not a lot going on here.&nbsp; It lists the profiling targets we&rsquo;ve created &ndash; just the one so far &ndash; and provides some command buttons for using the profiler:<br /><br /><img src="" border="0" alt="" width="257" height="131" /><br /><br />The most interesting command button is the third one along, Launch with Profiling.&nbsp; This runs our application under the profiler.&nbsp; Before we charge in and press it, however, note that if you drop this button down, you get another option, Launch with Profiling Paused.&nbsp; This is often more handy in the real world.&nbsp; <br /><br />Suppose you have a Windows Forms or WPF application, and users are complaining that the application runs slow when they perform a particular action or when a particular situation occurs.&nbsp; If you ran the application under the profiler, your results would be distorted by all the steps you had to take to get to the point where things slowed down.&nbsp; (Also, if you are using instrumentation, profiling slows down your application a lot, so if you had to step through a lot of GUI actions to get to the trouble spot, it would be very, very tedious.)&nbsp; <br /><br />So what you&rsquo;ll typically do in such situations is launch the application with profiling paused, get it to the stage where you&rsquo;re ready to reproduce the problem, and then turn profiling on (using the Start/Stop button) only for the duration of the problem code.<br /><br />In our trivial example, the only thing the program does is call the SaveFibonacciStrings function, so we may as well run the whole program under the profiler.&nbsp; So we click Launch with Profiling, the program runs, and when it finishes, Visual Studio clunks away for a while analysing the sampling logs and then displays a performance report.<br /><br /><img src="" border="0" alt="" width="503" height="419" /><br /><br />The initial Summary view shows us which functions are consuming the most run time.&nbsp; We can see from the top list that over 96% of our program&rsquo;s run time was spent within the Stringonacci method, and we can switch to the Functions view for more detail:<br /><br /><img src="" border="0" alt="" width="518" height="358" /><br /><br />So, 96.7% in Stringonacci, and 2.4% in Save.&nbsp; I guess there&rsquo;s not much point optimising our file save code then.<br /><br />The report tells us a bit more than this though.&nbsp; Although the program spends 96% of its time in Stringonacci, it spends only 15% of its time in Stringonacci itself.&nbsp; (Look at the lower chart in the Summary view, or the Exclusive Samples % column in Functions view.)&nbsp; The other 81% of the time is spent in the methods called by Stringonacci.&nbsp; In fact, the Functions table tells us we&rsquo;re spending 81% of our time in String.Concat (and the functions it internally calls).<br /><br />Our opportunities for optimisation, however, end with Stringonacci.&nbsp; We can&rsquo;t improve the performance of String.Concat because it&rsquo;s part of the .NET Framework.&nbsp; We can only change Stringonacci to call a more efficient function instead, or to make fewer calls to String.Concat.<br /><br />The profiler has located the problem, but it can&rsquo;t solve it for us.&nbsp; Fortunately, one obvious fix presents itself.&nbsp; Everybody knows string concatenation is inefficient!&nbsp; We&rsquo;ll just switch over to StringBuilders!&nbsp; Unfortunately, in this case, it turns out that this &ldquo;call a more efficient function&rdquo; strategy helps, but not very much: it just means the program grinds to a halt around n=42 instead of n=40.&nbsp; Are we going to be forced to fall back on using our brains?<br /><br />Whoa, let&rsquo;s not panic here.&nbsp; Let&rsquo;s switch over to instrumentation mode and see if the profiler can give us some more detail.&nbsp; You can easily do this using the Performance Explorer window:<br /><br /><img src="" border="0" alt="" width="254" height="101" /><br /><br />Here&rsquo;s the instrumentation summary for n=30:<br /><br /><img src="" border="0" alt="" width="516" height="264" /><br /><br />Stringonacci2Helper is the method which recursively builds up the string in a StringBuilder.&nbsp; It is called 2.7 million times for n=30.&nbsp; That seems awfully high, and merits further investigation.&nbsp; If we rerun the program under instrumentation for different values of n, the profiler tells us that Stringonacci2Helper is called 242000 times for n=25, 392000 for n=26, 635000 for n=27&hellip;&nbsp; It&rsquo;s an exponential increase.&nbsp; No wonder the program is grinding to a halt when n gets into the forties, and no wonder the improvement from using StringBuilder got eaten up so quickly!<br /><br />Again, the profiler can&rsquo;t identify the problem directly, but it has given us an enormous clue.&nbsp; An exponential increase probably means Stringonacci2Helper is calling itself, directly or indirectly, more than once.&nbsp; A quick look at the code confirms this:<br /><br />&nbsp;&nbsp;&nbsp; private static void Stringonacci2Helper(int i, StringBuilder builder)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (i == 1 || i == 2)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; builder.Append(&quot;*&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stringonacci2Helper(i - 1, builder);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stringonacci2Helper(i - 2, builder);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br /><br />The culprit is found.&nbsp; The profiler still can&rsquo;t tell us how to fix the problem, but it has led us directly to the cause.&nbsp; We can now investigate a variety of possible optimisations such as memoisation, direct calculation and sacking the bozo who wrote it this way in the first place.<br /><br />Finally, let me mention a couple of things we&rsquo;ve not covered in this overview.<br /><br />First, we&rsquo;ve not talked much about the Performance Explorer window and the Analyze menu except as ways for launching the profiler.&nbsp; Performance Explorer records your profiling sessions so you can review different runs of the program.&nbsp; You can also compare different runs, and save the profiling information to a file &ndash; useful if you need to pass it on to another developer to review, or if your customer is savvy enough for you to ask them to run the profiler on their machine and send you the data.&nbsp; Similarly, we&rsquo;ve only looked at a couple of the views that the Visual Studio profiler offers of the profiling data.&nbsp; Have a play around, or read the Visual Studio documentation, to see what more you can do with the profiler.<br /><br />Second, I want to emphasise that the profiler is a diagnostic tool, not a prophylactic one.&nbsp; I once had a boss who, after a customer had identified a performance issue and we had solved it using a profiler, suggested we should profile everything before releasing it.&nbsp; This is totally impractical.&nbsp; Profiling is expensive.&nbsp; You don&rsquo;t use it unless you need to.&nbsp; <br /><br />At the trivial end , instrumentation is insanely expensive in run time: on my machine, the Fibonacci example normally conked out around n=40, but I had to use n=30 and below for instrumentation tests, it was that much slower.&nbsp; More important, profiling is expensive in programmer time.&nbsp; It takes time to perform a profiling run, to interpret the results and to determine what needs fixing and how to fix it.&nbsp; Worst of all, speculative profiling tempts you to fix things that don&rsquo;t need fixing.&nbsp; You&rsquo;ll always have a &ldquo;most expensive&rdquo; function: the question is not whether one of your methods is using more time than others, but whether it&rsquo;s using more time than is acceptable to users.<br /><br />With that caveat, though, the <a href="" target="_blank">Visual Studio 2008</a> profiler is a jolly useful tool to have around.&nbsp; You won&rsquo;t need it every day, but when you do need it, it can be a lifesaver.<br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio webpage</a>. <br /><br /><strong>About the Author</strong><br /><br /><br /><em>Ivan Towlson is a developer at Wellington ISV Mindscape (</em><a href=""><em></em></a><em>), specialising in Windows Presentation Foundation.&nbsp; He is a regular speaker at .NET user groups and Code Camps, and a C# MVP.&nbsp; He writes at </em><a href=""><em></em></a><em> and </em><a href=""><em></em></a><em>.</em><img src="" height="1" width="1" alt=""/> started with Windows Azure and tricksSun, 15 Feb 2009 23:00:00 PSTSo, you have heard about the buzzword - <a href="" target="_blank">Windows Azure</a> - and want to start developing azure applications?&nbsp; Then, this blog post is for you :)<br /><br />The Azure Services Platform is designed to help developers quickly and easily create, deploy, manage, and distribute web applications and services. Windows Azure is a cloud services operating system that serves as the development, service hosting, and service management environment for the Azure Services Platform. <br /><br />Windows Azure provides developers with on-demand compute and storage to host and manage web applications on the internet through Microsoft data centers.<br /><br /><strong>How do I get started?<br /></strong>Below are the tools you need to install in your development machine to get started with Windows Azure<br /><br />&bull;&nbsp;&nbsp;&nbsp; <a href="" target="_blank">Visual Studio 2008</a><br />&bull;&nbsp;&nbsp;&nbsp; <a href="" target="_blank">Windows Azure SDK</a><br />&bull;&nbsp;&nbsp;&nbsp; <a href="" target="_blank">Windows Azure Tools for Microsoft Visual Studio</a><br /><br />The Windows Azure SDK has all the necessary binaries, libraries and documentation that you need to build Windows Azure applications.<br /><br />Windows Azure Tools for <a href="" target="_blank">Visual Studio 2008</a> extends Visual Studio to build, debug, package Windows Azure applications.<br /><br /><strong>The local Cloud depot</strong><br />In order to publish your applications to the cloud, you need to have a valid Windows Azure account. You can <a href="" target="_blank">apply for your account here</a>, but in the meantime, you can make use of the local development fabric from the Windows Azure SDK.<br /><br /><img src="" alt="" width="263" height="274" /><br />&nbsp;<br />The development fabric simulates Windows Azure cloud (fabric) in your local development machine and allows to run and test your Windows Azure applications.<br /><br /><strong>Windows Azure Roles<br /></strong>Windows Azure roles are discrete scalable components built with managed code. There are two roles available in Windows Azure<br /><br />&bull;&nbsp;&nbsp;&nbsp; Web Role<br />o&nbsp;&nbsp;&nbsp; A web role is an application that listens and responds for web requests via a HTTP or HTTPS endpoint.<br /><br />&bull;&nbsp;&nbsp;&nbsp; Worker Role<br />o&nbsp;&nbsp;&nbsp; A worker role is an application which runs as a background processing application and does not expose any endpoints<br />o&nbsp;&nbsp;&nbsp; The worker role cannot be accessed via the web<br /><br />Every Windows Azure application we build is always associated either with a web role or worker role or both.<br /><br /><strong>Windows Azure Visual Studio Templates<br /></strong>Windows Azure tools for Visual Studio install the necessary Windows Azure templates which makes it easy to start developing Windows Azure applications using Visual Studio.<br /><br />After installing the SDK and Azure tools for Visual Studio, you can see the templates in the New Project menu in Visual Studio<br />&nbsp;<br /><img src="" alt="" width="560" height="338" /><br /><br /><strong>Visual Studio Templates Explained<br /></strong>Windows Azure tools for Visual Studio installs several templates that you can make use of building Windows Azure applications.&nbsp; Lets take a look at each of the template installed:<br /><br /><strong><em>Blank Cloud Service Template<br /></em></strong>This template creates a Windows Azure service project without any roles in it. You have to manually add the roles later.<br /><br /><em><strong>Web Cloud Service Template<br /></strong></em>This template creates a Windows Azure service project with a&nbsp; web role and a web role web application project.<br /><br /><em><strong>Worker Cloud Service Template<br /></strong></em>This template creates a Windows Azure service project with a worker role and a worker role application project<br />Web and Worker Cloud Service Template.<br /><br />This template creates a Windows Azure service project with both web role, worker role and web role web application project and a worker role application project.<br /><br />In addition to the above Cloud Service template, Visual Studio also has Roles templates.<br />&nbsp;<br /><img src="" alt="" width="560" height="198" /><br /><br /><em><strong>Web Role Template<br /></strong></em>This template creates a web role web application project. You can later associate this web role web application project to a web role and cloud service.<br /><br /><strong><em>Worker Role Template<br /></em></strong>This template creates a worker role application project. You can later associate this worker role application project to a worker role and cloud service.<br /><br /><strong>Building our 'Hello Cloud' Sample<br /></strong>It's already time for us to build our 'Hello Cloud' application<br /><br />For this blog post, lets create a simple web role web application project whose job is to just greet users with a text - <em>Hello Cloud</em>.<br /><br />Open Visual Studio 2008 (as administrator) and choose to create a new Project:<br /><br /><img src="" alt="" width="458" height="154" /><br />&nbsp;<br />Choose the Web Cloud Service template from Cloud Service templates:<br /><br /><img src="" alt="" width="560" height="167" /><br />&nbsp;<br />Name the project as <em>HelloCloud<br /></em><br />Visual Studio will create two projects for you <br /><br />1) <em>HelloCloud</em> - The cloud service project with the web role<br /><br />2) <em>HelloCloud_WebRole</em> - The web role web application project<br /><br /><img src="" alt="" width="277" height="270" /><br />&nbsp;<br />The web role - <em>HelloCloud_WebRole</em> -&nbsp; in the <em>HelloCloud</em> service project is associated to your <em>HelloCloud_WebRole </em>web application project<br /><br />Open the Default.aspx and type - <em>Hello Cloud</em> - <em>Welcome to my first Windows Azure application!</em> - in the HTML editor.<br />&nbsp;<br /><img src="" alt="" width="545" height="161" /><br /><br />Your 'Hello Cloud' Windows Azure application is now ready to be tested!<br /><br />Hit F5 to debug the application.<br /><br />Visual Studio will start the local development fabric and host the 'Hello Cloud' web role web application project. You can see the development fabric icon in the taskbar.<br />&nbsp;<br /><img src="" alt="" width="182" height="75" /><br /><br />And our first Windows Azure web application:<br /><br /><img src="" alt="" width="411" height="150" /><br />&nbsp;<br />Double click on the development fabric icon in the taskbar to open the development fabric window. Here, you can see the roles currently running and hosted along with a verbose screen showing the current status or any other events.<br /><br /><img src="" alt="" width="560" height="422" /><br />&nbsp;<br /><br />As you can see in the above screenshot, our <em>webrole HelloCloud</em> is hosted in the development fabric and its status on the verbose window<br /><a href="" target="_blank"><br />Visual Studio 2008</a> simplifies building Windows Azure applications using the Windows Azure tools for Visual Studio. It also allows us to debug Windows Azure application which I think is a big boost to many developers.<br /><br /><strong>Download Visual Studio 2008 90 day trial</strong><br />For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio webpage</a>. <br /><br /><strong>About the Author<br /></strong><img src="" border="0" alt="" align="left" /><em>Chaks is currently working for Intergen as a Software Developer. Chaks works extensively in Microsoft Platform. His knowledge covers various Microsoft Technologies like WCF, SharePoint, Windows Azure, ASP.NET. Chaks also writes for <a href="" target="_blank">Neowin</a>, one of the Microsoft featured communities. You can contact Chaks via his blog - <a href="" target="_blank">Chaks' Corner</a></em>.<img src="" height="1" width="1" alt=""/> consider sitting for an MCTS or MCP Certification and tricksMon, 09 Feb 2009 23:00:00 PSTI have to admit up front that for many years I didn&rsquo;t think much of sitting for IT certifications, thinking that such rot was only for people who had just left school, before they found a job to add to their resume.<br /><br />The simple truth is that I had not sat for any certifications myself, and didn&rsquo;t know what I was talking about.<br /><br /><strong>What Certifications are Good For<br /></strong>IT Certifications are useless in terms of proving how good of a programmer you are -- they will never demonstrate how efficient you are at breaking problems down into addressable parts, and coming up with creative targeted solutions.&nbsp; But that's not what certification is about or for.&nbsp; IT certifications are only good indicators of how much you know about the <em>technology</em> you are using.&nbsp; <br /><br /><strong>Don't Need No Stinkin' Certification</strong><br />&quot;<em>What rot! Look: I eat CSS for breakfast, spit Flash for fun, dream in HTML, clean the shower stall with AJAX, and I don&rsquo;t need no stinkin&rsquo; certification!</em>&quot; <br /><br />This may be true. There are a lot of great coders out there.&nbsp; And there are a lot of great weekend mechanics out there too. Both groups are very talented, creative, and resourceful, delivering solutions that get the job done, and last at least 6 months.<br /><br /><strong>UberStickinStuffinTubinShpit <br /></strong>But good as they are, there is a limit to the amount of trust I am willing to put into an auto-didactic genius. <br /><br />I'll let my gregarious cousin Freddy fix my pickup truck any day of the week (it&rsquo;s not only fun to be around Freddy, but he doesn't charge as much as <em>Shlick&rsquo;s German Imported Cars</em> down town), but the <em><u>heck</u></em> if I'm letting him work on my (imaginary, unfortunately) Porsche.<br /><br />Because there's something to be said about having it worked on by a person who has slogged away at successfully passing a whole bunch of Porsche certifications, and knows precisely what he&rsquo;s talking about -- even the useless stuff (he actually knows that &quot;UberStickinStuffinTubinShpit&quot; means something specific in German, and that it comes in 3 sizes too, and &ndash; more importantly &ndash; what it&rsquo;s for, exactly). <br /><br />Which is a marked contrast to Freddy, who thinks that all engines are &quot;basically the same thing, so if you&rsquo;ve seen one of them, you've seen them all&quot;. <br /><br />In Freddy&rsquo;s case, this (I assume) means that he would work on Porsches with the same gusto and creativity as he fixes lawn-mowers.&nbsp; If he were a coder, it might mean that he would build an ASP.NET website with a PHP mindset, that somehow works, but who knows for how long.<br /><br /><strong>Because I'm Not (Yet) Stranded On an Island<br /></strong>Don&rsquo;t get me wrong. I like resourceful people who can figure out how to start an engine just by poking around a bit --&nbsp; and I definitely want that person with me if I'm ever stuck on an island with an electric generator, a ball of string, and some tin foil.<br /><br />But right now, I'm not on an island.&nbsp; More importantly, my clients are not on an island and they can pick and choose who they want to do their work.&nbsp; In other words, in this day and age, less and less can one get away with delivering software that works only for 3-6 months between 'tune-ups'.&nbsp; <br /><br /><strong>Yet, it&rsquo;s not the Certification that&rsquo;s Important<br /></strong>And it&rsquo;s not the certification itself that's important (getting PPPP&rsquo;ed isn&rsquo;t going to get you a date &ndash; having an actual Porsche might be more useful in that regard).&nbsp; It&rsquo;s the <em>studying</em> for the certification that is important.<br /><br />Maybe not right away, but the pedantic, in depth, studying (even if it was just to pass an exam) pays off at some point in time.&nbsp; An example of this might be the tracking down of why using a <em>SymmetricAlgorithm</em> with <em>ASCII</em> encoding works... but only <em>some</em> of the time. <br /><br />Non-certified coders might start poking around with the cipher mode or padding (if you don't believe me, go look at how many posts there are on CodeProject, etc on that very subject), whereas certified professionals will spot the cause generally faster, which will be the Encoding used.&nbsp; <br /><br />They wll find it faster, because they have studied symmetrical algorithms in general, including the <em>CipherMode </em>and <em>PaddingMode enumerations</em>, but also Encoding (which has nothing to do Symmetrical algorithms and would probably not have been mentioned if you just Googled about using the <em>SymmetricAlgorithm</em> classes). <br /><br /><strong>Who Has Time for all that studying? I've got work to do!<br /></strong>You're absolutely right in wondering about that point: the 80/20 rule would imply that if you are unburdened with all that lost time studying for a useless exam, and only producing some bugs, and only once in a while, that you might as well just continue writing code who's bugs mostly get caught either in the beta cycle, or by end users (creating a market for Version 2.x anyway, right)?<br /><br />I guess it really depends on the complexity of the deployment and the quality you aim for. <br /><br />If it&rsquo;s just JavaScript, that can be updated instantly, go right ahead with that methodology for as long as you can get away with it (maybe...).<br /><br />But if it&rsquo;s a occasionally connected mobile app you are working on, it&rsquo;s going to be absolute hell updating any code that you got wrong.&nbsp; Do you <em>really</em> want to be the person who is known internally as the hot-rod goof that ended up causing 1 million dollars worth of tech support? Especially when you find out it was an absolutely preventable error -- if you had only looked and studied the documentation more than a minute?<br /><br /><strong>The Studying can only Help -- even if you are the WhizKid<br /></strong>Even if you are the office whiz kid, it doesn't hurt to actually get certified (I mean <em>study</em>) as well.&nbsp; You&rsquo;ll be pleasantly surprised at how many parts you don&rsquo;t know as well as you thought, and the extra studying can only help you write more precise code in the long run anyway, without sacrificing any of your god-given talents at writing creative solutions.<br /><br />Start <a href="" target="_blank">here</a>.<br /><br /><strong>Download Visual Studio 2008 90 day trial</strong><br />For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio webpage</a>. <br /><br /><strong>About the Author<br /></strong><a href="" target="_blank">Sky Sigal</a> has been programming on and off for 25 years, over 10 of those professionally, creating enterprise solutions in various languages, on different platforms. You can read about what he's currently taking apart and putting back together at <a href="" target="_blank"></a>. <br />&nbsp;<img src="" height="1" width="1" alt=""/> testing .Net Compact Framework applications with Visual Studio 2008 and tricksSat, 07 Feb 2009 23:00:00 PSTMicrosoft first provided unit testing tools with Visual Studio 2005. However, these were only offered as part of the Team Developer or Tester SKUs or with Team Suite. No testing support was provided for Windows Mobile applications.<br /><br /><a href="" target="_blank">Visual Studio 2008</a> marked an improvement in this as in many other areas: the basic testing tools are included with Visual Studio 2008 Professional, and this time the .NET Compact Framework is supported.<br /><br />So what do Windows Mobile developers get and how do they go about using it? I thought you&rsquo;d never ask (and I&rsquo;d be surprised if you did, since I&rsquo;m sitting here by myself).<br /><br />I do want to get one thing out of the way: before anyone says &ldquo;You&rsquo;re not doing TDD&rdquo; I would like to say, pre-emptively, &ldquo;No, I&rsquo;m not&rdquo;. I&rsquo;m talking about using the tools, not any particular approach to how you go about doing development. That&rsquo;s up to you (and while you&rsquo;re about it don&rsquo;t let the Rails kids bully you).<br /><br />So anyway, for demonstration purposes I&rsquo;ve created a mobile application for calculating the Gregorian Easter. The solution contains a class library that implements the algorithm for calculating Easter (based on an <a href="" target="_blank">example given by Claus T&oslash;ndering</a>, in turn based partly on Oudin&rsquo;s algorithm) and another containing the UI.&nbsp; <br /><br />The calculation of Easter is a handy example partly because it&rsquo;s currently on the way to being topical (as you&rsquo;ll see), and partly because there are plenty of ways of introducing errors which we can use to illustrate the tools.<br />So here&rsquo;s my solution in its initial glory and simplicity:<br /><br /><img src="" alt="" width="243" height="289" /><br /><br />The process of adding a unit test project for the Compact Framework will be familiar to anyone who&rsquo;s used the desktop version of the tools. In this case I&rsquo;m creating tests for existing code so I bring up a context menu within the code window and select &ldquo;Create Unit Tests&rdquo;:<br /><br /><img src="" alt="" width="449" height="140" /><br /><br />After a while you&rsquo;ll be presented with a dialog that allows you to select which methods and classes to test. <br /><br /><img src="" alt="" width="371" height="278" /><br />(I should apologise at this point for having a class file called EasterCalculator.cs while the class itself is called GregorianEasterCalculator &ndash; normally I keep the two strictly aligned, but I mucked up the editing. Which takes a bit of doing).<br /><br />When you create unit tests this way any method where the cursor was positioned when you right-clicked will be selected by default, but obviously you can deselect this one and/or select others. You can repeat this process at any time, but you should bear in mind that right-clicking to bring up the dialog again and then de-selecting the selected method will not cause an existing test method to be removed (while leaving it selected and continuing will cause an additional test method to be generated for that method).<br /><br />And here&rsquo;s my test method as it is generated:<br /><br /><img src="" alt="" width="640" height="186" /><br />Since the first thing I want to test is that the code works for expected values (you need to deal with the unexpected ones as well of course but we want to establish whether it works as intended) I will enter a known year value (in this case 2009), add checks for values and remove the Assert.Inconclusive(..). I will also rename the method to reflect what I am actually testing (normally naming it with an actual data value would be overly specific but I think this example is a special case):<br /><br /><img src="" alt="" width="640" height="214" /><br /><br />You should note that while the user interface gives no indication of this, the normal options for debugging unit tests have no effect for smart device projects because the code executes remotely. Debugging smart device tests requires following the <a href="" target="_blank">steps described here</a>.<br /><br />Tests can be executed from the Test View (available for instance via Test-&gt;Windows-&gt;Test View), and results are displayed in the Test Results window also in the same way as for desktop projects.<br /><br />The following is the result of running a test where Ash Wednesday is being incorrectly calculated as 40 days before Easter Sunday (it should be 46):<br /><br /><img src="" alt="" width="640" height="111" /><br /><br /><strong>Limitations</strong><br />Perhaps the most serious limitation (as I indicated above when talking about debugging) is that <a href="" target="_blank">Visual Studio 2008</a> gives no real indication of what the limitations are, because the UI displayed for testing is the Visual Studio testing user interface. This is perfectly understandable of course, but it does mean some time can be wasted finding out what you can and can&rsquo;t do.<br /><br />The form displayed for .testrunconfig files for instance shows Code Coverage as an option, but this is not in fact available for smart devices and will not do anything.&nbsp; To be fair, the form in question shows options that could be relevant for any test run configuration file, so the issue of displaying irrelevant or unavailable options is not actually a problem with the smart device implementation as such.<br /><br /><strong>Conclusion<br /></strong>In a sense the hardest part about demonstrating smart device unit testing support in <a href="" target="_blank">Visual Studio 2008</a> is that for anyone familiar with the desktop version there&rsquo;s nothing new: apart from the fact that this is a special case of executing a remote test, there&rsquo;s really nothing that&rsquo;s done differently &ndash; it&rsquo;s more a matter of bearing in mind the features such as Code Coverage that aren&rsquo;t available, and remembering what you have to do to enable debugging.<br /><br />The question may arise as to what you can do to make mobile applications more easily testable.<br /><br />I&rsquo;ll annoy a few people when I say this, but I wouldn&rsquo;t recommend going overboard with dependency injection in a mobile application: you don&rsquo;t really have the luxury of being able to afford to execute code that strictly speaking doesn&rsquo;t need to be there (on the other hand the way I&rsquo;ve split my application into separate projects imposes an assembly loading penalty, but I only did that for clarity in my examples).<br /><br />Some things that are helpful: I personally find the Model-View-Presenter pattern a good fit for the Compact Framework, and Presenter classes are easily testable without mucking around with UI elements. <a href="" target="_blank">Alex Yakhnin&rsquo;s</a> <a href="" target="_blank">MVC framework for the Compact Framework</a> is well worth a look as well (in fact I might switch to it once I&rsquo;ve had time to try it out).<br /><br />On the whole though this is definitely not rocket science, so try it out and see what works for you (which is really the only criterion that matters).<br /><br />But there I&rsquo;m straying slightly off topic, which means it must be time to stop. So I will.<br /><br /><strong>Download Visual Studio 2008 90 day trial</strong><br />For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Visual Studio webpage</a>. <br /><br /><strong>About the Author</strong><br /><em><img style="margin: 10px" src="\blog\vs2008\intro/kev.jpg" border="0" alt="" width="100" height="149" align="left" />Kevin Daly has been programming professionally for almost 22 years. He has been using .NET and C# continuously since the Beta 2 in 2001, which probably explains the bags under the eyes. Other examples of his views, rants and even the odd code sample can be found on his blog at <a href="" target="_blank" title="Kevin Daly"></a>.&nbsp; He will work for money.&nbsp; He will now stop talking about himself in the third person because it&rsquo;s frankly a bit weird.</em><img src="" height="1" width="1" alt=""/> Services... Jumpstart and tricksTue, 03 Feb 2009 23:00:00 PSTThis article will explain for developers who are interested in building applications on the Azure Platform with the help with <a href="" target="_blank">Visual Studio 2008</a> how to get started.&nbsp; <br /><br /><img style="margin: 10px" src="" alt="" width="300" height="191" align="right" /><a href="" target="_blank">Live Services</a> (previously Windows Live Dev) is a development centre and supplier of software development kits for the <strong>Windows Live</strong> and <strong>Azure Services Platforms</strong>.&nbsp; <br /><br />It provides information on getting started with Windows Live services, latest documentation and APIs, samples, access to community areas and relevant blogs, and announcements of future releases and innovations.<br /><br />Live Services are a set of building blocks for handling user data and application resources.&nbsp; Live Services provides developers with an easy on-ramp to build rich social applications and experiences that can connect with over 460 million Windows Live users.&nbsp; Live Services includes Mesh technologies for synchronising user&rsquo;s data and extending web applications across multiple devices.<br /><br /><img style="margin: 10px" src="" alt="" width="250" height="58" align="right" /><a href="" target="_blank">Windows Live</a> is the collective brand name for a set of services and software products from Microsoft.&nbsp; A majority of these services are Web Applications, accessible from a browser, but there are applications that need installing as well:<br /><br />&bull; Hotmail, Messenger<br /> &bull; Live Search, Spaces<br /> &bull; Alerts, Sky Drive<br /> &bull; One Care, Writer<br /> &bull; Photo Gallery, Events<br /> &bull; Live Search Maps<br /> <br /><img src="" alt="" width="560" height="442" /><br /><br />There are three ways in which Windows Live services are offered: Windows Live Essentials applications, web applications and mobile services.<br /><br />Microsoft&rsquo;s <a href="" target="_blank">Azure Services Platform</a> is a cloud platform (cloud computing platform as a service) offering that &ldquo;provides a wide range of internet services that can be consumed from both on-premises environments or the internet.&rdquo;&nbsp; It is significant in that it is Microsoft&rsquo;s first step into cloud computing following the recent launch of the Microsoft Online Services offering:<br /><br /><img style="margin: 10px" src="" alt="" width="250" height="191" align="right" /><a href="" target="_blank">Live Mesh</a> is a data synchronisation system from Microsoft that allows files and folders to be shared and synchronised across <a href="" target="_blank">multiple devices</a>.&nbsp; Live Mesh consists of a software component that allows synchronisation relationships to be created among different devices.&nbsp; <br /><br />Once a folder is set for synchronisation, it will be available in all devices, and any changes made to the content of the folder will be reflected across all devices.&nbsp; <br /><br />Live Mesh uses FeedSync to convey the changes made in each device so that the changes can be synchronised.&nbsp; The information about devices and folders participating in a synchronisation relationship is not stored locally but at the service-end.&nbsp; Devices in a sync relationship are collectively referred to as a Mesh.<br />Live Mesh is part of Live Services, one of the building blocks of Microsoft&rsquo;s Azure Services Platform &ndash; a &ldquo;cloud&rdquo; platform hosted at Microsoft data centres.<br />&nbsp;<br /><strong>So what&rsquo;s the diff?</strong><br /><br />&bull; Google <br />&nbsp;&nbsp;&nbsp;&nbsp; o Offer Software As A Service (SAAS).<br />&nbsp;&nbsp;&nbsp;&nbsp; o Revenue stream from advertising<br /><br />&bull; Microsoft <br />&nbsp;&nbsp;&nbsp;&nbsp; o Offer Software + Services (S+S).<br />&nbsp;&nbsp;&nbsp;&nbsp; o Revenue stream still from shrink wrapped applications<br />&nbsp;&nbsp;&nbsp;&nbsp; o As well as new stream from SLA on cloud architecture<br /><br />According to Microsoft, the state of the world is that people are increasingly &ldquo;on-the-go.&rdquo;&nbsp; We are using more devices.&nbsp; Connectivity is proliferating.&nbsp; Life-styles and work-styles are blending.&nbsp; People are working and playing together more digitally.&nbsp; All of this is leading to an increasing expectation (demand) for complete end-to-end experiences.<br /><br />What if you had one integrated platform designed to support the rich-client experience in a standard, open way?&nbsp; Live Services is Microsoft&rsquo;s answer to getting us off our digital islands.&nbsp; It&rsquo;s a connected experience through services and devices working together, recognizing that connectivity and communication is everything.&nbsp; The Live Framework (LiveFx) connects devices, data and applications through a consistent, approachable framework.<br /><br />The key concept behind LiveFx is it&rsquo;s the uniform way for programming Live Services: any platform, any programming language, any application or device.&nbsp; LiveFx makes it easy to build S+S applications. .NET developers can use the LiveFx API kits to build applications.<br /><br />The design principle behind LiveFx is it&rsquo;s user-centric to the core.&nbsp; It is a S+S distributed platform, which means it has universal reach, but with an emphasis on &ldquo;experience first.&rdquo;&nbsp; It is designed for humans and code.&nbsp; It has Internet scale, and re-uses proven assets (e.g. SQL Server).<br />&nbsp;<br /><strong>How Do I Use It?<br /></strong><br />Either you can integrate Live Services into your applications (opting in to as much of the Live Framework as you like) or you can export your applications as Mesh Applications onto the Azure Platform.<br /><br />For developers with an existing Windows Live ID, you can log onto this site to <a href="" target="_blank">start downloading the SDK</a>. <br /><br /><strong>Everything needs an ID &ndash; Why LiveID?</strong><br />&bull; You the end user don&rsquo;t have to worry about setting up and maintaining the back end infrastructure required for AuthZ and AuthN<br />&bull; LiveID Services takes care of it for you.<br />&bull; LiveID Services is always online, secure, backed up and available<br />&bull; Based on Open standards and platform neutral<br />&bull; Easy to provision, access and use<br />&bull; Technology agnostic<br />&bull; Move seamlessly across multiple applications/services &ndash; A Single Sign In service<br />&bull; Last but not least &ndash; largest collection of users on system &ndash; close to half a billion users already use LiveID. So it&rsquo;s easy to tap into this vast existing user base for your customer base or audience.<br /><br />The beneficial features offered by Mesh Application include:<br />&bull; Access anywhere<br />&bull; Data everywhere<br />&bull; Data sharing<br />&bull; News<br />&bull; Deployment<br />&bull; Security<br /><br />Once you&rsquo;ve sign up on Azure, the process for installing and running your applications couldn&rsquo;t be simpler:<br />&bull; Open Live Desktop<br />&bull; Go to Apps tab<br />&bull; Choose a Mesh Application<br />&bull; Click &ldquo;Add to mesh&rdquo;<br />&bull; Name the instance<br />&bull; Open on the Live Desktop<br /><br />The Software Development Lifecycle thus becomes much simplified:<br />&bull; Development<br />&bull; Zip/upload<br />&bull; Deploy<br />&bull; Rinse &amp; Repeat<br />o Now deploy = auto upgrade!<br />Prior to upload, your deployment package has several requirements:<br />&bull; Application Code<br />&nbsp;&nbsp;&nbsp;&nbsp; o JavaScript<br />&nbsp;&nbsp;&nbsp;&nbsp; o SilverLight<br />&bull; Manifest<br />&bull; HTML start page<br /><br />The Manifest file consists of XML tags which define the following elements:<br />&bull; HTML start page<br />&bull; Application name<br />&bull; Application description<br />&bull; Return URL (optional)<br />&bull; Version<br />&bull; Single/Multi Instance allowed<br />&bull; Delegated Auth info<br />&bull; Default data feeds<br /><br /><strong>Download Visual Studio 2008 90 day trial</strong><br />For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio webpage</a>. <br /><br /><strong>About the Author<br /></strong><img style="margin: 10px" src="" border="0" alt="" align="left" /><em>James Hippolite started programming in 1983 on an Apple IIe, at the age of 14. After graduating with a bachelor degree in Information Systems from Victoria University of Wellington in New Zealand in 1990, he started working with small systems relational databases, like dBase, Paradox, FoxPro and finally Microsoft Access. <br /><br />In 1991 he founded Mana Information Systems, a company for SME who couldn&rsquo;t afford their own IT departments. As the lead developer, he developed small to medium WinForms applications using SQL Server, Visual Basic and latterly ASP.&nbsp; In 2003 James developed in C# his first .NET web application, an internal metrics reporting tool for his new employer, Telecom New Zealand, utilising SQL Server stored procedures and .NET classes. <br /><br />Due to the worldwide success of SubSonic, James converted in 2008 to this O/R mapper, which is currently one of the market-leading data-access solutions for .NET, C# and VB.NET. James has been a trainer and contributed lectures on Microsoft Certification and SQL Server Reporting Services to the .NET community.&nbsp; James has received for his community efforts no MVP reward (yet). <br /><br />He lives in Wellington and is currently employed full time in a large corporate and loving the regular hours that non-consultants enjoy.</em><img src="" height="1" width="1" alt=""/> Driven Development with Visual Studio 2008 and tricksSun, 01 Feb 2009 23:00:00 PST[I feel this post needs a disclaimer here, this is not a post on Agile methodologies, but rather a post on how tools can be harnessed to aid you meet a more agile development life-cycle while using <a href="" target="_blank">Visual Studio 2008</a>.]<br /><br />Agile software development has become quite the darling of the development community around the world. It promises to help teams create a product that gets to market quicker, has more value to customers or simply a project that's more fun to be part of. <br /><br />This post is not about Agile development or the pros and cons of agile. What Agile means to different people can be subjective (that's both the beauty and the pitfall of the methodologies that call themselves Agile) and as such is best treated in a separate post.<br /><br />Try the <a href="">Agile Mainfesto</a> as a starting point, then maybe try and read up on eXtreme Programming and Scrum to learn some of the more commonly understood methodologies. <br /><br />Rather, I wanted to give some tips, some reviews and some exposure to the huge ecosystem of tools and techniques from Microsoft and also from the myriad of external developers, that make these techniques easier to follow. <br /><br /><a href="" target="_blank">Visual Studio 2008</a> is generally agreed to be one of the most feature complete, extensive IDEs for development available. From IntelliSense to built in easy debugging the power of <a href="" target="_blank">Visual Studio 2008</a> is open for all to see. However there are a number of things that aren't quite as supported out of the box, but thanks to its great extensibility model (and the hard work of a number of developers) there are a myriad of tools out there to help you out. <br /><br />I'll focus on two techniques made popular through agile development, Test Driven Development and Continuous Integration, and try and give some pointers as to how you can get into these techniques easily while using <a href="" target="_blank">Visual Studio 2008</a>. <br /><br /><strong>Test Driven Development </strong><br /> Test Driven Development is one of the cornerstones of many of Agile development methodologies, and one that I personally try and practice (and preach) on all of my own projects. There are a number of tools out there to help you, but if you've never done TDD before the biggest piece of advice is to find someone who has and ask for a primer. Once you're ready to get going with TDD, you'll want to pick a testing framework, and the integration into your workflow and ease of use should be one of the considerations when picking the framework for your tests. <br /><strong><br /><em><a href="">MS Test</a></em></strong> <br />If you're using the Professional or Team editions of Visual Studio you don't have to go very far. Support for Microsoft's home grown test framework MSTest is built right into the IDE. MSTest is a unit testing framework with a very similar syntax to NUnit, but it's only available built into the Pro and Team Suite Editions of Visual studio so you may need to find a 3rd Party solution if you're using standard or express editions of visual studio. <br /><br /><img src="" alt="" /><br /><br /><em><strong><a href="">NUnit</a></strong></em> <br />NUnit is the grand daddy of .Net unit testing frameworks, and probably the framework that most people will have heard of or used. NUnit itself comes with very little tooling to help you out from within Visual Studio but the stand alone runner and command line runner are a stalwart of many TDD practitioners <br /><br /><em><strong><a href="">MbUnit</a></strong></em> <br /> MbUnit was, for a long period of time, the only real alternative to NUnit. It still has one of the most active followings of all the unit testing frameworks out there. The syntax is very similar to NUnit and MSTest but has a number of other abilities that go beyond the other frameworks (although NUnit is catching up) RowTest was for a long time the reason someone would pick MbUnit over the others. MbUnit is also tied into Gallio, a test runner that will run tests in most frameworks, and the runner that I personally use on most of my projects. <br /><br /><strong><em></em><br /></strong> is a recent entry into the .net unit test framework world, and aimed to be more than just a Unit Testing framework. it's very opinionated (see <a href="">Make Opinionated Software</a>) and is probably one of the most real departures from the standard test frameworks listed above. The syntax and the style of writing tests are quite radically different. I strongly recommend reading why the designers of the framework made the decisions they did. At least to understand their beef with existing frameworks and why they felt a change was needed, even if you aren't intending to use itself. Another great way to integrate testing into your Visual Studio experience is with a tool called <a href=""></a> this lightweight tool gives you a context sensitive menu that allows you to run tests right from your code and report on test failures as errors. Well worth checking out. But test driven development is not about just the tests (many people who are used to TDD see TDD as less about the Testing and more about the Design). There are a number of things you will find that happen once you are familiar and running with TDD. <br /><br /><strong>Refactoring </strong><br />Get used to refactoring, it'll be here to stay for you if you run with an agile methodology. Even if you don't follow TDD you'll be wanting tools and techniques that allow you to quickly rewrite parts of your code as more requirements crop up and changes need to be made. <br /><br />I personally recommend you try out tools such as ReSharper or <a href="">Refactor! Pro</a> both of these tools are a great aid to generating method stubs, increasing the power of Visual Studio IntelliSense and giving you guidance as to cleanly refactor your code and keep the impact of future changes low. <a href="">ReSharper</a> is my tool of choice simply because it used to be the front runner in terms of functionality, however that gap is closing if not non existent now and a lot of people swear by Refactor! Pro. <br /><br />I don't know enough about Refactor! Pro to do it justice, i suggest you check out one of the many reviews that can be found using your search engine of choice. But I would advise getting one of these tools, your wrists will be happier from the reduced key strokes to get the job done. ReSharper also has a great in built test runner.<br /><br />&nbsp;<img src="" alt="" /> <br /><br /><strong>Continuous Integration</strong><br />Continuous integration is another great tool to have under your belt. Basically going hand in hand with TDD to ensure that the code in your source repository is at a certain standard at any point in time. The first step to this is learning the build script language. Previously the only real choice was to learn <a href="">Nant</a> an xml language based on Ant. It's a very full featured build scripting language and can pretty much do anything you need it to do, from xcopy-ing to compiling to running tests and reporting on the results. However with <a href="" target="_blank">Visual Studio 2008</a> there was a compelling case to learn the alternative build scripting language from Microsoft: <a href="">MSBuild</a>. <br /><br />If you open up any of the .proj files within a <a href="" target="_blank">Visual Studio 2008</a> project you'll be confronted with MSBuild. Visual Studio uses it as its own build language. All builds in VS2008 just use msbuild under the covers. <br /><br />Why is this important? Simply put because you want your developers running the same builds as the build server so they can check things build before checking in (where errors become more about environment, forgotten files and simple oversight). If you get to grips with MSBuild you can get a build process together that runs both in VS2008 and on the build server itself. (You can do this with Nant too but takes a little more setting up) Once you've got to grips with a build script, you need a build server (which simply monitors your source repository for changes, checks out the code and runs a build, reporting on the results and notifying of failures), see more about CI <a href="">here</a>. <br /><br /><em><strong><a href="">Team foundation server</a><br /></strong></em>Team Foundation Server&nbsp; is Microsoft's fully featured build/source control/project management server. It's an all singing and all dancing solution that does great for integration into Visual Studio's workflow. however it can have a very unwieldily set-up process and can cost too much for smaller teams to justify. <br /><br /> <strong><em><a href="">TeamCity</a><br /></em></strong> TeamCity is a build server from JetBrains (makers of ReSharper). It has a very easy to set up configuration and can be used for building code in .net as well as many languages outside of .net. There's also a nice plug-in for Visual Studio that allows you to run a Personal Build (code isn't checked in until the build passes) and monitor results of other check-ins you've made to the code base. There's a free version that will allow you to run up to 20 build configurations. <br /><br /><em><strong><a href="">Cruise</a></strong></em><br />There used to be a product called which was a port of CruiseControl to .net by Thoughtworks. however Thoughtworks now have a product called <a href="">Cruise</a> which is touted as a fully featured CruiseControl server. I've not used it myself so I'll refrain from giving it an inaccurate review. At the time of writing I couldn't get to the <a href=""></a> page however if it's still available is a heavily xml driven continuous integration server. <br /><br />High on features, but also heavy on configuration. It's open source, free and has a strong community of users. <br /><br />These are just a few tools that people who are looking to get into TDD and CI should look at. This is just the tip of the iceberg in terms of techniques and tools to go with. <br /><br />I strongly recommend understanding the driving force behind Agile even if you aren't going down that route yourself. Read up on the <a href="">Agile Mainfesto</a>. <br /><br />Learn what Scrum and eXtreme Programming are all about (along with Crystal Clear, Lean Development and the myriad of other agile methods).<br /><br />I hope that the information above has piqued someone's interest and they want to take it further and read up on the tools and techniques mentioned. If not, or you feel somethings been missed feel free to leave a comment. The web is all about open discussions.<br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio 2008 webpage</a>. <br /><br /><strong>About the Author</strong><br /><br /><img style="margin: 10px" src="" alt="" align="left" /><em>Owen Evans is a software developer and agile evangelist, currently working at <a href="">Xero</a>. He's a strong advocate for Behaviour Driven Development, and unit testing. You can find his blog <a href="">here</a>.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></em><img src="" height="1" width="1" alt=""/> Visual Studio 2008 blog is back Studio 2008Sat, 31 Jan 2009 23:00:00 PSTAlmost a year ago we started posting on this sponsored blog about <a href="" target="_blank">Microsoft Visual Studio 2008</a>.<br /><br />During a full month experienced developers, designers and software architects from Australia and New Zealand gave us tips, insights and advice on how to use <a href="" target="_blank">Visual Studio 2008</a> to its full extent.<br /><br />That experience was incredible with a great number of visits, comments and downloads.<br /><br />Based on the success and feedback, Microsoft is once again sponsoring this blog so we will be posting new articles from those experts.<br /><br />In this blog you will find a new post every second day during the months of February and March 2009, and an initial list of posts include the following topics:<br /><br />- Unit Testing Windows Mobile Applications <br />- Using Dynamic Data and the Entity Framework<br />- Fun with Code Metrics <br />- ASP.NET MVC Framework <br />- creating your own helper extension methods <br />- Editing tips - Debugging tips - Navigation tips <br />- Beginning Windows Azure Programming <br />- Beginning .Net Service Bus Programming<br />- Live Services Jumpstart <br />- SQL Server Data Services <br />- Tools and Techniques to aid agile development in Visual Studio 2008 <br />- The Certification Process <br />- Mobile Development <br /><br />Before we start posting you might want to recap the most read topics in our previous series. These are the top five topics:<br /><br />- <a href="" target="_blank">Unit testing with Visual Studio 2008</a><br />- <a href="" target="_blank">New WCF features in Visual Studio 2008</a><br />- <a href="" target="_blank">Using AJAX and ASP.Net extensions with .Net 3.5 and Visual Studio 2008</a><br />- <a href="" target="_blank">Visual Studio 2008 with WPF for creating Interactive 3D Applications<br /></a>- <a href="" target="_blank">Visual Studio 2008 support for building Silverlight applications</a><br /><br />I suggest you <a href="" target="_blank">subscribe to our RSS feed</a> to keep receiving the new posts.<br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href="" target="_blank">Microsoft Visual Studio 2008 webpage</a>.<img src="" height="1" width="1" alt=""/> testing with Visual Studio 2008 and tricksTue, 01 Apr 2008 00:00:00 PDTOne of the great improvements of <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>&nbsp;brought to developers is the built in support for unit testing. With Unit Testing support, it is very easy for developer to create, execute and repeat unit test cases. <br /><br />Setting up a test project in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> is extremely easy. All it requires is adding a test project into a solution by selecting Test Project template under Test project type.<br /><br /><img src="" border="0" alt="" width="683" height="440" /><br />&nbsp;<br />A test class is generated once the Test project is created. Visual studio automatically mark the test class and method with <strong>TestClassAttribute</strong> and <strong>TestMethodAttribute</strong>.&nbsp; <br /><br /><img src="" border="0" alt="" width="552" height="281" /><br /><br /><strong>Adding a unit test<br /></strong>It is recommended to create one test class per class to be tested. A test class can be added by either selecting from Add New Test popup or by selecting Unit Test from Add menu.&nbsp;<br />&nbsp;<br /><img src="" border="0" alt="" width="504" height="426" /><br /><br />Alternatively, Unit test can be added by right clicking the method name and select &ldquo;Create Unit Tests&rdquo; in context menu.&nbsp; This brings up the Create Unit Tests screen where multiple methods to be tested can be selected.<br />&nbsp;<br /><img src="" border="0" alt="" width="680" height="510" /><br /><br />By default <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> appends &ldquo;UnitTest&rdquo; in front of ClassName as the test file name and class name and &ldquo;Test&rdquo; in front of MethodName as the test method name -&nbsp;bearing in mind these are all configurable by clicking Settings button located on the left bottom corner of the popup.<br /><br /><img src="" border="0" alt="" width="310" height="338" /><br />&nbsp;<br /><strong>Unit testing support for ASP.NET website/application<br /></strong><a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> allows developers create test cases for methods defined in ASP.NET website or applications. Even better, tests are running under ASP.NET context which means settings from Web.config file are automatically picked up once the test case starts running. <br /><br />This is really handy for applications that contain a lot of applications settings such as database connections, logging configurations, Active Directory etc as duplicating all the settings in the testing project is no longer needed. The following code illustrates what the test method looks like. (this test method just for demo, I can&rsquo;t imagine anyone would unit test a button click event handler.)<br /><br /><img src="" border="0" alt="" width="680" height="267" /><br />&nbsp; <br />It worth pointing out two attributes <strong>HostTypeAttribute</strong> and <strong>UrlToTestAttribute</strong>. HostType makes sure that test case is running ASP.NET host process. <strong>UrlToTest</strong> specifies URL to test when test is run. <br /><br />If the application requires authentication, there might be problem relates to VSEnterpriseHelper.axd when test is run. This is due to the test context is not authenticated. To solve the problem, permission to access VSEnterpriseHelper.axd need to be granted by adding following code in Web.config file.<br /><br /><img src="" border="0" alt="" width="517" height="124" /><br />&nbsp;<br /><strong>Execute test method<br /></strong>Test method can be started by right clicking the test method name and select Run Tests.&nbsp;<a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> displays test results in Test Result output window.<br />&nbsp;<br /><img src="" border="0" alt="" width="680" height="174" /><br /><br />If all test cases in a single test class need to be run, just simply right click the test class name select Run Tests from the context menu. The results look like this:<br /><br /><img src="" border="0" alt="" width="680" height="225" /><br />&nbsp;<br /><strong>Debugging support in Unit Testing<br /></strong>All test classes/methods can be run under debug mode. Simply put a break point where the code needs to stop and start the test by clicking &ldquo;Debug Tests in Current Context&rdquo; button located in the toolbar or &ldquo;Tests in Current Context&rdquo; menu of Debug option under Test menu.<br /><br /><img src="" border="0" alt="" width="680" height="351" /><br />&nbsp;<br /><strong>Execute tests in a predefined order<br /></strong>In real life, it is mostly likely for a test project contains a set of test methods which form test cases. Making sure test methods are run in a particular order could be a pain. <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> allows developers to predefine an Ordered Test in which the sequence of test methods is run.<br /><br />An ordered test can be added into a test project either by selecting Ordered Test template from Add New Test popup or add Ordered Test directly from Add option of a test project:<br /><br /><img src="" border="0" alt="" width="680" height="376" /><br />&nbsp;<br /><br />Adding an Ordered Test brings up an Ordered Test Editor where the test methods are included and the order is specified.<br /><br /><img src="" border="0" alt="" width="680" height="273" /><br />&nbsp;<br /><br />In the Ordered Test Editor, test methods can be selected from the Available tests list then added into to the Selected tests list by clicking the right arrow. <br /><br />To run the ordered test, go to the Test list editor check the newly created ordered test. Click the Run checked test button located on the top left corner of the Test list editor.<br /><br /><img src="" border="0" alt="" width="680" height="489" /><br />&nbsp;<br /><strong>Conclusion<br /></strong><a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> makes creating and managing unit testing real easy. On top of what has been discussed here, it provides configuration support for deployment, setup/cleanup and host etc.&nbsp; Compare with previous versions of Visual Studio, this is definitely one step forward.<br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Microsoft Visual Studio webpage</font></a>. <br /><br /><strong>About the Author</strong><br /><em><img style="margin: 10px" src="" border="0" alt="" width="100" height="118" align="left" />Nathan Li is a senior .NET developer at Datacom. Over the past few years, Nathan has been designing and delivering enterprise solutions in various industries. Recently, he is working as a technical lead on a solution in .NET 3.5. He is also running the Datacom .NET user group. He organises and presents in monthly seminars around leading edge Microsoft technologies.</em><img src="" height="1" width="1" alt=""/> Studio 2008 with WPF vs. Visual Studio 2005 with XNA for creating Interactive 3D Applications and tricksSun, 30 Mar 2008 00:00:00 PDTWith <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>&rsquo;s in built WPF, developers have the ability to easily create windows applications that are powered with all the latest features offered by Direct X. Apart from the purely visual enhancements this offers over, say, a traditional windows forms app developed using Visual Studio 2005, this also permits full 3D interactive applications to be developed with far greater ease than before. <br /><br />Traditionally considered the province of game development only, Direct X, OpenGL and similar technologies permit the creation of applications that put traditional forms to shame, especially when developers explore the possibilities offered by creating complex 3D environments for their users to explore and interact with. <br /><br />In the past this meant building a costly and time consuming 3D engine, usually in C++ or similar, but a few years ago Microsoft released the highly acclaimed XNA which, while targeted at game development nevertheless could be used for in any application to easily get a 3D accelerated scene. Initially built into a specialized version of Visual Studio 2005 express, XNA 2.0 today can be installed with any version of Visual Studio 2005. <br /><br />Perhaps the key technology of <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> is WPF, and this provides a definite challenge to XNA&rsquo;s 3D superiority. WPF is a technology that is entirely powered by DirectX and which seamlessly merges 2D with 3D in a windows environment, which leads to the question: when developing a 3D application, which is the better platform to develop with? Visual Studio 2008, or Visual Studio with XNA? <br /><br />If you forget for a second that WPF is &ldquo;targeted&rdquo; at windows development whereas XNA, which can compile seamlessly for the Xbox 360 is &ldquo;targeted&rdquo; at game dev, ultimately they&rsquo;re two highly sophisticated, highly evolved platforms for creating DirectX powered windows applications. There are a number of differences encountered between developing in each, and I believe that these lead to the conclusion that the ultimate choice is determined by your applications needs. <br /><br />In traditional 3D engines, including those implemented through XNA, a central render loop forms the core of the application. This loop contains a draw method where each element of your scene is rendered, before the final image is flipped to the screen. In developing a 3D application in Visual Studio 2005 with XNA you construct your scene from 3D elements and sprites, and then make adjustments and render it on every call of the draw method. By counting the number of times this method is called each second the frame rate can be calculated, which with XNA the frame rate tends to sync with your screens refresh rate. <br /><br />When starting a XNA application you are given a near blank slate, with the central game class containing the overridden draw method, along with methods for loading and unloading content. Defining the screen size or resolution is all done within the code, and the properties of your XNA window are largely irrelevant. <br /><br />In <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>, when starting a new WPF project you will find that most of this low level engine behaviour is hidden. Much like when developing a windows application, where after adding a button to a form you don&rsquo;t then have to catch the windows render method and ensure the button is painted, in a WPF project whether you add a 2D element or a 3D element, once added to the canvas they will be rendered on every frame automatically. <br /><br />On top of this, the built in z-order rendering and transparency both make putting together a 3D scene almost as easy as putting together a 2D one. When constructing a scene a programmer need only define where each object is in 3D space, and where the camera is, in order to have a perfectly ordered scene show without any further configuration, complete with 2D elements appearing in the overlay. <br /><br />This can be done in the code or with XAML on the canvas, and with predefined 2D elements like buttons and textboxes dropping elements with <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>&rsquo;s visual editor feels very similar to Windows Forms in VS2K5, only with far more power and control. <br /><br /><img src="" border="0" alt="" width="663" height="673" /><br /><br />This XAML above in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>&rsquo;s visual designer shows how easy it is to throw together a 3D scene complete with a camera and a directional light. <br /><br />In comparison to construct a scene in XNA through Visual Studio 2005 requires a lot more work, especially in terms of interface elements. In a traditional graphics engine everything is 3D, and the best method to get an interface element on screen is to render it as a sprite, then apply it to a thin 3D object that is projected outside of the Z order, and therefore painted last over all other elements. <br /><br />While this is a workable solution and with a bit of work easily achievable in .NET 2.0, developers will find throwing together a WPF equivalent in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> much, much easier. <br /><br /><img src="" border="0" alt="" width="553" height="411" /><br /><br />Dropping a button on the screen, defining an event handler and properties and then having it work seamlessly with a 3D backdrop makes a very strong case for Visual Studio 2008 over any traditional 3D development platform. <br /><br />In any interactive or animated scene the elements that make it up and the camera through which the user sees them often have to be moved and rotated, or created and destroyed. The way objects are moved and rotated in WPF is a little easier than doing the same in XNA, thanks to the addition of wrapper objects in Visual Studio 2008 like RotateTransform3D, where an object can be rotated along its axis through a one line command as simple as: <br /><br />model.Transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), rotation), new Point3D(2.5, 2.5, 2.5)); <br /><br />Where the axis is set by the first vector, the amount (in degrees, not radians) is set by the variable rotation and the point to rotate around is set by the Point3D instance. Even such a simple thing as using degrees in a double instead of radians in a float demonstrates the central philosophy behind WPF and Visual Studio 2008; that of making things easier and more inline with traditional windows form programming, rather than following the precise and lower level conventions of graphics engine development as followed in XNA. <br /><br />The big advantage of an XNA application over a WPF form is performance, and this may be critical in choosing between the two for a prospective 3D application. As XNA is essentially a graphics engine with extra bits tacked on, it has no need to &lsquo;play nice&rsquo; with Windows like WPF and <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> need to, and as such free from any such responsibilities it can run a lot faster when windowed or full screen. <br /><br />Also, because the draw method is readily available in the auto generated classes created by VS2K5, code to alter the scene at runtime based on caught user input or whatever can be included in there, allowing the entire application to effectively run on one thread. <br /><br />In WPF in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> by contrast two threads run by default, one for input and one for rendering, and if you wish to add scene altering behaviour via a timer or whatever the processor time allocated to your app starts to get sliced pretty thin. <br /><br />This can lead to timer ticks becoming less precesise and in the worse case scenario interface response times getting a little laggy. XNA also makes use of XACT and a content pipeline, which while impractical in some situations has the advantage that it streamlines the process of loading content for rendering. In WPF the amount of power required to do something like this is many magnitudes greater than that used by XNA: <br /><br /><img src="" border="0" alt="" width="640" height="491" /><br /><br />On top of this, while WPF and the libraries of .NET 3.0 packaged with <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> possess all the basic Direct3D abilities, some of the more advanced stuff offered by DirectX is not available, such as complex filters. This puts it at a definite disadvantage to XNA and Visual Studio 2005 in terms of what level of graphical fidelity is available. <br /><br />However in contrast, many of the more complex abilities supported by XNA rely on external tools beyond Visual Studio 2005, the most obvious is XACT for creating XNA Audio, a rather clumsy tool that comes packaged with XNA 2.0. <br /><br />Other tools, for example Nvidia&rsquo;s Filter Designer, are only available from third parties. Integrating content into a WPF application with <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>, by way of comparison, is as simple as adding images and sounds to your project through the solution explorer. What <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> sacrifices in 3D power, it makes up for in usability. <br />Ultimately when choosing what platform to develop a 3D application in the choice between the <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> with WPF and Visual Studio 2005 with XNA boils down to scale and ease. When your app requires more advanced, more precise rendering and/or requires a lot of power to run, the more fundamental XNA is your best bet. However, aside from performance, <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>&rsquo;s WPF is superior to XNA in many ways, including in ease of development, integration with windows, and coding simplicity. <br /><br />A simple WPF 3D app developed in Visual Studio 2008 can be developed in a fraction of the time it takes to do the same in VS2K5 with XNA 2.0, and will usually look just as good running side by side.<img src="" height="1" width="1" alt=""/> up for Office Development and tricksThu, 27 Mar 2008 00:00:00 PDT<a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> includes the third version of Visual Studio Tools for Office (VSTO), a set of libraries and designers for developing applications and add-ins for Microsoft Office 2003 and 2007.&nbsp;This is the first time VSTO has been bundled into Visual Studio, and it also represents a significant step forward in usability, a major factor in getting .NET programmers to adopt Office as a platform. <br /><br /><br />Office programming in .NET has always been bedevilled by ugly APIs and inadequate tooling.&nbsp; The Office API dates back to the COM era and to Visual Basic for Applications, and many of its interfaces are designed specifically for the VBA language with its built-in support for named and optional parameters, loose typing, etc.&nbsp; <br /><br />Converted to .NET, however -- raise your hand if the phrase &quot;Office 2003 Primary Interop Assemblies&quot; brings you out in hives -- this results in methods with some two dozen parameters, where all of them are typed as object, and all except the fifteenth are always Type.Missing.&nbsp; <br /><br />This worked well in VB Classic with named parameters, optional parameters and evil type coercion, but was a complete pain in strict languages like C# and VB.NET.&nbsp; <br /><br />Meanwhile, on the tooling front, all Visual Studio has offered is a Ribbon schema for the XML editor.&nbsp; It's not exactly the Windows Forms designer.&nbsp; All in all, I've not felt particularly enthusiastic about trying to build Office applications using .NET.<br /><br />Last year, however, I was working on an application for a major logistics company we'll call New Zealand Toast.&nbsp; I can't talk about the real application, but translated into the universal language of toast, the idea was that bread producers could arrange for the logistics company to pick up pieces of bread, and deliver them in toast form to customers around the world.&nbsp; (If this sounds like a bad business model, or a recipe for a cold, late breakfast, bear in mind that the universal language of toast, while it works well for grilled bread products, doesn't translate so well to the competitive world of international logistics.&nbsp; The real application was, well, a bit more realistic.)&nbsp; <br /><br />The application enabled Toast's customers to create consignment notes -- addressing and customs documents -- for their bread packages via a Web interface instead of having to write them out by hand.&nbsp; <br /><br />For larger bread producers,&nbsp; the application allowed users to upload multiple orders in a CSV file -- assumed to be exported from Excel -- rather than entering them by hand.<br /><br />This worked fine, but it wasn't a seamless experience for users.&nbsp; Users had to work on the file in Excel, then remember to save the file as CSV, then switch to the Web application to upload it.&nbsp; It seemed to me that one way around these problems was to allow users to work entirely within Excel using a provided template.&nbsp; <br /><br />If we could put a &quot;Toast&quot; button on the Excel ribbon, users could work in a suitably friendly template, then click the button when they were ready.&nbsp; No need to save as CSV, no need to switch to the Web browser, much less scope for things to go wrong.&nbsp;<br /><br />Fortunately the real application was built as a set of Web services, and with .NET it would be just as easy to call those from Excel as from our Web application.&nbsp; So I fired up <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> and started throwing together a proof of concept.<br /><strong><br />Getting Started<br /></strong>The first thing I noticed in VSTO 2008 was that the Office 2007 option seemed to be disabled!&nbsp; The reason was that <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> supports targeting different versions of the .NET Framework, and I had selected .NET 2.0.&nbsp; This is okay for Office 2003, but if you want to target Office 2007, you need to select .NET 3.5.&nbsp; Once I'd done that, I got the following options in the New Project dialog:<br /><br /><img src="" border="0" alt="" width="640" height="384" /><br /><br />For my proof of concept, I decided to go with an add-in.&nbsp; I could also have created a template, which has the advantage that the Toast button wouldn't appear on spreadsheets that had nothing to do with toast, but the customer was thinking in terms of users exporting CSV from their own order tracking systems, and I wanted to show that Excel could support that.&nbsp; If users had to import their CSV data into a specific Excel template, they wouldn't be gaining much over loading the CSV file up to the Web site.<br /><br /><strong>Creating the User Interface<br /></strong>The boilerplate generated for an add-in was about as minimal as you get, but things got a bit more interesting when I right-clicked the project and chose Add New Item.&nbsp; The New Item dialog now included a &quot;Ribbon (Visual Designer)&quot; item:<br /><br /><img src="" border="0" alt="" width="640" height="384" /><br /><br />This allows you to create Ribbon items using (you guessed it) a visual design surface instead of editing XML files.&nbsp; Visual Studio starts you off with a single empty group which will go into the Add-Ins tab.&nbsp; You can of course change this to use a different tab, or to create a new tab just for your commands.&nbsp; <br /><br />In fact, if the functionality you're adding logically affects more than one tab, you can put all of those tabs into the same Ribbon definition.&nbsp; You can also add items to the Office menu itself.&nbsp; <br /><br />One teasing option is to mark your ribbon as &quot;start from scratch&quot;: this hides the built-in Ribbon tabs and shows only yours, like the Blog Post template in Word.&nbsp; This would be very evil and wrong to do for an application-level add-in, and even for a template add-in you'd do it only if the majority of application commands didn't make sense in your template's context.&nbsp; (The Word Blog Post template gets away with it because things like mail merge, page layout and revision tracking aren't applicable to blog posts.)<br /><br />Within each tab, you can create groups, buttons and other Ribbon elements using the toolbox and the drag-drop-edit-the-properties method familiar to all Windows Forms developers.<br /><br />Here's a snippet of the Ribbon designer.&nbsp; I've renamed the group that Visual Studio has created for me, and I'm about to drag a command button on from the Toolbox:<br /><br /><img src="" border="0" alt="" width="529" height="406" /><br /><br />Once that was done, I wanted to make the button look pleasantly Office-like.&nbsp; By default, <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> creates a small, text-only button, but this is the primary (indeed sole) way for users to access the Toast functionality, so I thought we needed a large graphical button.&nbsp; (I might use small text buttons for ancillary actions like setting options, accessing address books, etc., but the main function deserved a big button.)&nbsp; To do this, I went to the Properties window, change the ControlSize to RibbonControlSizeLarge, and set the Image property to a suitable graphic.<br /><br /><img src="" border="0" alt="" width="339" height="284" /><br /><br />When I hit the Debug button, Visual Studio launched Excel with my add-in loaded:<br /><br /><img src="" border="0" alt="" width="640" height="195" /><br /><br />There's really not all much more to say.&nbsp; Finally building the user interface for an Office application is as easy as building a Windows Forms UI.&nbsp; I could have added more controls such as Office galleries, and hooked up features like Office 2007's &quot;super tips&quot; (multiline tooltips), but it's just variations on a theme:<br /><br /><img src="" border="0" alt="" width="234" height="234" /><br /><br />VSTO 2008 also supports other Office UI idioms.&nbsp; Although there's no dedicated support for task panes, you can create them as Windows Forms user controls.&nbsp; If you're packing your application as a template or document, you can also create document action panes, which give you a prominent place to display commands or data that are specific to your document.&nbsp; I didn't need either of these features, though if I'd gone for the template approach I could have used the action pane to step users through the consignment creation process instead of letting them find it on the Ribbon.<br /><br /><strong>Writing the Code<br /></strong>Of course, so far, none of my buttons actually does anything.&nbsp; That's easily fixed though.<br /><br />To create a Click handler for a button, all I had to do was double-click it in the designer.&nbsp; (You can also use the Events tab in the Properties window; that's useful for creating or assigning handlers for less common events.&nbsp; But, as with Windows Forms, Visual Studio knows that most of the time, with buttons, we're interested in the Click event.)&nbsp; <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> created a stub method in the code-behind file, hooked it up to the button's Click event, and displayed the stub method ready for me to edit.<br /><br />And now the real work began, of writing the code to actually create the consignment notes from the contents of the workbook.&nbsp; In my case, this was a matter of copying data from the cells into a Web service message, and sending it to the New Zealand Toast Web services.&nbsp; I'm not going to say much about this because it's very specific to the application, but here are a couple of things that bit me: <ul><li>The Office API, unfortunately, is rather uneven, with modern .NET APIs suddenly giving way to crevasses of poorly documented COM interop.&nbsp; There's a lot of HpeHungarianPrefixedEnums.wrepWithRedundantEnumPrefixes; Excel cells are actually Ranges, except when they're Objects; Range has properties called Value and Value2; and Type.Missing is still hanging in there.&nbsp; You can almost feel the years of compatibility cruft.&nbsp; On the plus side, if you're used to the existing Automation model, or want to reuse your existing Office code in VSTO 2008, this is probably exactly what you want. </li><li>Visual Studio doesn't give you a lot of help once it's dropped you into the code.&nbsp; Typically in an Office&nbsp; application you need to get to the Application object, and you can then drill down from there, but the generated event handler doesn't receive an Application object.&nbsp; The trick is that Visual Studio generates a Globals class which contains a reference to the current instance of the add-in, which in turn has a reference to the Application.&nbsp; So you can always get the Application object via Globals.ThisAddIn.Application.&nbsp; (In a template or document, this would instead be Globals.ThisWorkbook or Globals.ThisDocument.)</li></ul><br /><br />Other than that, it's just a matter of writing your custom logic in C# or Visual Basic, and knowing the object model of your target application.<br /><br /><strong>Deploying the Application<br /></strong>Disclaimer: I have to admit that my proof of concept didn't go as far as deployment, so I can't comment on how well all this works.<br /><br />With that caveat in mind, deploying VSTO 2008 solutions looks much easier than previous Office programming models.&nbsp; You can just use ClickOnce.&nbsp; Visual Studio creates a folder including a setup.exe file as well as your application package; all you need to do is copy that folder to your Web server and give users a link to setup.exe.<br /><br />This is particularly sweet for an application like mine that targets external users.&nbsp; Toast couldn't have used group policy or SMS to distribute the application, but they could easily have created a page with a link to setup.exe, and a set of instructions explaining what to do when, for example, ClickOnce started asking for scary permissions.&nbsp; It also addresses the problem of getting users to install updates or bug fixes, as ClickOnce will check back for new versions at a configurable interval.<br /><br />Don't forget that VSTO 2008 depends on .NET 3.5.&nbsp; Users therefore need to have .NET 3.5 installed on their machines; they also need the VSTO runtime.&nbsp; If you use ClickOnce, though, Visual Studio includes these prerequisites in the application manifest and ClickOnce automatically downloads them.<br /><br /><strong>Summary<br /></strong>Admittedly I only scratched the surface of VSTO 2008 in my little proof of concept, but I did feel that it had removed a lot of the complexity and makework of building Office applications.&nbsp; The new Ribbon designer makes it a snap to build your user interface and to integrate it into the standard Ribbon -- or to build a custom Ribbon if that's what your application needs.&nbsp; <br /><br />The code you'll write to drive office remains familiar from Office 2003, but hooking it up to the Office UI is now almost frictionless.&nbsp; And ClickOnce deployment simplifies the rollout process for organisations that don't have mighty mighty group policies to push things out, or for applications that need to be used by external users.&nbsp; <br /><br />For someone like me who's been put off Office as a platform in the past by the high apparent cost of entry, Visual Studio 2008, with VSTO built in for the first time, and Office 2007 have been a bit of an eye-opener.<br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Microsoft Visual Studio webpage</font></a>. <br /><br /><strong>About the Author<br /></strong><em>Ivan Towlson is a <a href="" target="_blank">software developer and architect at Mindscape</a>.&nbsp; Over the years he has worked in a variety of industries from civil engineering and pharmaceuticals to telecoms and e-commerce messaging.&nbsp; He currently works on developer products for Mindscape.</em><img src="" height="1" width="1" alt=""/> Studio 2008 Code Metrics Saves you Money and tricksWed, 26 Mar 2008 00:00:00 PDTOne of many new features available in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> Team Developer and Team Suite editions is Code Metrics (CM). <br /><br />Code Metrics measures industry-standard software characteristics. Covering a range of aspects, it can provide useful and quantifiable feedback for developers. <br /><img src="" border="0" alt="" width="802" height="448" /><br /><br />Displaying code metrics is very easy; simply right click on a project or a solution in the Solution Explorer, and select Calculate Code Metrics. Here's what the results look like:<br /><br /><br />The results window displays each of five different metrics: Cyclomatic Complexity, Depth of Inheritance, Class Coupling, Lines of Code, and an overall Maintainability Index. By expanding the tree on the left, you can drill right down from a whole project to individual methods within a class. But what do all the numbers mean?<br /><br /><br /><strong>Cyclomatic Complexity<br /></strong>Cyclomatic Complexity is the total number of linearly independent paths that can be taken when executing a method, based on the number of 'if', 'switch', 'while' and other similar branching statements in it. If a method has no such statements in it, there is only one path that can be followed, and so the Cyclomatic Complexity is one.<br /><br /><br /><img src="" border="0" alt="" width="486" height="279" /><br /><br />In this example, there are three realisable paths that could be followed when this method is executed, depending on the value of X: <ul><li>The path that is followed when X is 1 </li><li>The path that is followed when X is 2 </li><li>The path that is followed when X isn't 1 or 2 </li></ul><br /><br />Cyclomatic Complexity tells you two important things. First, it indicates the general complexity of a method. Lower is better; if the number is high, the method is probably trying to cover too many different situations (i.e. trying to be too clever) and needs to be broken up into simpler, specialised methods that cater specifically to individual situations (and are much easier to maintain).<br /><br />Secondly, in order to ensure that every scenario has been tested properly, you must create a unique test case for each path. Cyclomatic Complexity tells you the total number of test cases you need to write, to ensure that all possible situations have been covered.<br /><br /><br />If Cyclomatic Complexity is higher than the number of unit tests for a piece of code, you will know that some scenarios are not being accounted for, and may be harbouring bugs.<br /><br /><br /><strong>Depth of Inheritance<br /></strong>Depth of Inheritance is the total number of levels of inheritance in a class hierarchy, starting at one (remember everything inherits from Object). This example has a depth of inheritance of three:<br /><br /><br /><img src="" border="0" alt="" width="461" height="356" /><br /><br />Lower is better; if Depth of Inheritance goes higher than three or four, your code may be over-engineered and prove difficult to maintain. <br /><br />The higher the number, the more subclasses you will have to modify -- costing time and money, and potentially introducing bugs -- if you make a breaking change to a base class. <br /><br />If you consider that every change you make to those subclasses may introduce potential bugs with all of the objects they interact with... well, you get my point.<br /><br /><br /><strong>Class Coupling<br /></strong>Class Coupling counts the total number of distinct types a class interacts with, excluding primitive and built-in types like Int32 and String. Lower is better; the higher the number, the more &quot;tied-down&quot; a class is, with more dependencies on the rest of its immediate environment. <br /><br />As a class's coupling increases, the harder it becomes to 'rip out' and use in another project. In short, the higher a class's coupling, the less reusable it is.<br /><br /><br />We've all seen examples of a class that should be reusable, in theory, but in practice, proves to be highly project-specific and has to be more-or-less completely re-written each time it is &quot;ported&quot; to another project. <br />If this class had been better designed when it was originally created, we could have saved a lot of time later on.<br /><br /><br /><strong>Lines of Code<br /></strong>Lines of Code (LOC) measures the size of a piece of software by counting the total number of executable lines of code in it. As with the other metrics, lower is generally better, simply because you end up with less source code to wrestle with. Bear in mind though, there are a few caveats you should be aware of before using this metric:<br /><br /><ul><li>Not everyline is equal. Some lines are very simple, and others are very complicated and take hours to figure out. </li><li>It doesn't count code that has been deleted and replaced.&nbsp; </li><li>Sometimes splitting things up onto multiple lines makes them easier to comprehend; in this case increasing the LOC improves maintainability. </li><li>Unless well-designed, thoroughly-tested, and production-ready code flows directly from your fingers every time you sit down at your keyboard, LOC doesn't accurately reflect the amount of effort that has been put into a piece of software. </li></ul><br /><br />Use this metric wisely. In the past, LOC has been famously abused to measure daily programming productivity, with disastrous results. Remember there's a lot more to software development than just typing code!<br /><br /><strong>Maintainability Index<br /></strong>Last, but not least, is the Maintainability Index, which goes from 0 to 100 and indicates the overall maintainability of a class, member, namespace or project. It's effectively an aggregate of the other metrics, but it also includes a few extra bits like the Halstead Volume, which measures the total length and vocabulary size of the program. For a change, higher is better here.<br /><br /><br />The Maintainability Index also provides a red/yellow/green traffic light icon which allows you to quickly see problem areas at a glance. The traffic light turns yellow when the number dips below 20, and red below 10, at which point you should be running for the hills.<br /><br /><br /><strong>Summary<br /></strong><a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>'s Code Metrics doesn't measure performance or security, and won't help you resolve any bugs. It will, however, help you to identify potential problem areas in your software, as you are developing it.<br /><br /><br />If you address these issues early, you will save time and money that would have to be spent re-factoring unmaintainable code later on. You will also feel good about yourself knowing that you got it right the first time!<br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Microsoft Visual Studio webpage</font></a>. <br /><br /><strong>About the Author<br /></strong><em><img style="margin: 10px" src="" border="0" alt="" width="100" height="100" align="left" />Richard &quot;Dingo&quot; Dingwall is a rock star .NET developer in <a href="" target="_blank">Provoke's Bespoke Solutions</a> team. Heralding from the South Island of New Zealand, Richard's lateral thought, problem solving strengths and his eye for detail puts him in the elite of Microsoft software engineers in the country.</em><img src="" height="1" width="1" alt=""/> Studio 2008 support for building SilverLight applications and tricksTue, 25 Mar 2008 00:00:00 PDTWhile not baked into the development environment, building SilverLight applications in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> is much easier than in Visual Studio 2005. With Visual Studio 2005 to be able to build a SilverLight application, you need to create a class library and add/remove a few assembly references and a few extra things. You can read more on this in the <a href="" target="_blank">Orcas required</a> post on the SilverLight forums.&nbsp; <br /><br />Instead, you can download the <a href=";displaylang=en" target="_blank">Microsoft SilverLight Tools Beta 1</a> for <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> which will install SilverLight 2 (formerly SilverLight 1.1) beta 1 and the SilverLight project templates for you. The SilverLight 2 release comes with a &ldquo;Go-Live&rdquo; license, more information on the Go-Live license can be found in the post <a href="" target="_blank">Exploring the SilverLight 2.0 &ldquo;go-live&rdquo; license</a>.<br /><br />The main difference between SilverLight 1.0 and SilverLight 2.0 is that do build SilverLight 1.0 applications you have to use JavaScript but for SilverLight 2.0 you can use .NET languages such as C# &amp; VB.NET SilverLight 2.0 also includes additional controls. You can find out more about the differences in the SilverLight Feature Matrix. <br /><br /><strong>Building a simple SilverLight form with Visual Studio 2008<br /></strong>After installing the SilverLight tools for <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> the visual studio project templates become available to you as you can see below. <br /><br /><img src="" border="0" alt="" width="640" height="178" /><br /><br />Using the above templates you can create a SilverLight Application or a SilverLight Class library, a SilverLight application is sufficient in most situations but you might consider a class library when you want to build a SilverLight assembly shared by multiple projects or creating custom controls for SilverLight. See <a href="" target="_blank">Developing a SilverLight Library Assembly</a> for more on that topic.<br /><br /><strong>SilverLight 2.0 Controls<br /></strong>When you create a SilverLight Application using the SilverLight 2.0 tools for <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> you will see the following list of controls available that you can use in your application, including new ones such as the Textbox, Radio and Checkbox controls.<br /><br /><img src="" border="0" alt="" width="258" height="653" /><br /><br />As you can see from the list of controls available, you can use some of those controls to build a web form that has a much richer experience that traditional web forms not built with SilverLight. Below is a simple example demonstrating this.<br /><br /><strong>Adding form elements into the Visual Studio 2008 SilverLight Designer<br /></strong><br /><img src="" border="0" alt="" width="640" height="348" /><br /><br />When the new project is created you see the following layout with your XAML files created including the Page.xaml, which is the file hosting our SilverLight form and the XAML/Design split view. <br /><br />In the current version of the SilverLight tools for Visual Studio 2008 there is no support for dragging items into design view which is why I really like the split view feature of <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> as it lets you drag your controls into the XAML code view and see an instant preview in the design view.<br /><br />For this form let&rsquo;s add a Textbox, Button and set some styling properties as shown below<br /><br /><img src="" border="0" alt="" width="640" height="441" /><br /><br />As can be seen above the items we added are showing on top of each other, the reason for that is that we have not applied any positioning to the items we&rsquo;ve just added. To do so we need to add those items into a canvas so that we can position them on the form as shown below.<br /><br /><img src="" border="0" alt="" width="640" height="111" /><br /><br />We position the elements by specifying values for the Canvas.Left &amp; Canvas.Top values as shown below with the button element. Note how we have access to XAML intellisense as can be seen on the Textbox properties. <br /><br /><strong>Applying some styling<br /></strong><br /><img src="" border="0" alt="" width="1" height="1" /><br /><img src="" border="0" alt="" width="640" height="378" /><br /><br />The screenshot above shows how with just a little bit of XAML code we can apply some styling to our form. <br /><br />Now that the form is styled we need to actually be able to use it. Before we add events to our form elements we need to specify an element name so that we can reference those elements from the server side code. This is done by using the x:Name property as shown below.<br /><br /><img src="" border="0" alt="" width="399" height="107" /><br /><br /><strong>Handling Events<br /></strong>To handle events on your form elements you need to bind some methods to your events as shown below where we bind some code to the Click event. <br /><br /><img src="" border="0" alt="" width="399" height="219" /><br /><br />After selecting the click event, tab over the new event handler shown below. <br /><br /><img src="" border="0" alt="" width="277" height="71" /><br /><br />This creates an event handler method in the server side code and binds that method to the event. We can now go to the code and implement that method as shown below.<br /><br /><img src="" border="0" alt="" width="640" height="241" /><br /><br />So if all goes well our Textbox text should update and display &ldquo;Text has changed...!!!&rdquo;<br /><br /><strong>Executing and debugging SilverLight code<br /></strong>We test if our code will work by adding a break point into the method above and debug.<br /><br /><img src="" border="0" alt="" width="643" height="88" /><br /><br />The screenshot above shows us a breakpoint in the event handler method for the button with a tool tip showing the current text.<br /><br /><strong>Final result<br /></strong><br /><img src="" border="0" alt="" width="400" height="335" /><br /><br />And finally once the code has run we can see that our Textbox text has been updated and our form is displayed with all the style attributes we&rsquo;ve applied including the Opacity and transformations.<br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Microsoft Visual Studio webpage</font></a>. <br /><br /><strong>About the Author<br /></strong><img style="margin: 10px" src="" border="0" alt="" width="100" height="100" align="left" /><a href="" target="_blank"><em>Daniel Wissa</em></a><em> is a Web Developer working in Christchurch. He has a B.Com. from the University of Canterbury where he studied Information Systems and Computer Science and is also a MCAD in .NET. <br /><br />He has been involved with Microsoft and Microsoft communities for many years since being a Student Partner at Canterbury University a few years ago to currently leading the Christchurch .NET user group. He also maintains a blog </em><a href=""><em></em></a><em> where he regularly blogs about Microsoft technologies, local user group events and more.<br /><br /></em><img src="" height="1" width="1" alt=""/> Me: Syndication with Visual Studio 2008 and .NET 3.5 and tricksSun, 23 Mar 2008 23:09:00 PDTWhen you start up <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> for the first time, it&rsquo;s natural to go looking to see what new project templates may have been added. Under &ldquo;WCF&rdquo; (assuming you have the framework version set to 3.5) we now see the following:<br /><br /><img src="" border="0" alt="" width="529" height="186" /><br /><br />The new Syndication Service Library template allows you to create feed services that will generate either RSS 2.0 or Atom 1.0 feeds or both (although not at the same time, because that would be silly...).<br /><br />When you create a new project using this template a default feed is created with an interface definition and a feed service to implement the interface. In this sample (&ldquo;Hello World&rdquo; if you will) feed service the feed is returned in RSS 2.0 format by default, but as Atom 1.0 if the service has been passed the query string &ldquo;format=atom&rdquo;.<br /><br /><img src="" border="0" alt="" width="560" height="454" /><br />The nice feature here is that the delivery format is abstracted away from the code the developer writes: no additional code is required to produce a feed in one or the other format, or as in the sample, both.<br /><br />In practice I don&rsquo;t currently see a lot of point in providing any given feed in multiple formats, since most feed readers are able to deal with the most widely used formats in case, so my personal recommendation would be to pick one format you&rsquo;re happy with and use that - but it&rsquo;s certainly a good thing that you have the freedom to make that choice without having to take care of the implementation details yourself.<br /><br />The new WCF Service Host enables you to test your service directly from the library project, so you can take the generated code and start viewing the resulting feeds immediately, switching seamlessly between RSS and Atom output.<br /><br />At the code level you will mainly be working with the SyndicationFeed class which corresponds with an RSS Channel or Atom Feed, and within each SyndicationFeed a SyndicationItem collection that equates to an Atom Entry or RSS Item. The object model is relatively simple, reflecting the simplicity of the syndication formats themselves (I am of course oversimplifying here so don&rsquo;t get the wrong idea &ndash; all the essential features such as categories are supported).<br /><br />Points to note: Date/Time values in SyndicationFeed and SyndicationItem use the new DateTimeOffset type to represent time values as an offset from UTC (Coordinated Universal Time). <br /><br />It&rsquo;s very easy to derive this value from your local time (if that&rsquo;s how the value is stored in your data source) because DateTimeOffset has a constructor that takes an old-style DateTime structure as its parameter. When you use this method the offset from local time to UTC is derived automatically. <br /><br />A second point worth noting is that properties such as Title which seem familiar enough to people used to working with RSS are not as you might expect simple strings, but are instead of type TextSyndicationContent. So if I have an item called for the sake of argument item, I could set its title by assigning it a new instance of TextSyndicationContent with my string value as its constructor &ndash; attempting to assign a string value directly to item.Title would cause an exception to be raised. Since my title should be a plain text string (no HTML) I actually prefer the static method TextSyndicationContent.CreatePlaintextContent (), with my title string as its parameter.<br /><br /><strong>Extending the syndication formats<br /></strong>RSS 2.0 and Atom 1.0 are designed to be extensible, this extensibility being achieved by the normal XML method of providing additional attributes and elements with an associated namespace.<br /><br />Microsoft&rsquo;s underrated Simple List Extensions for RSS take advantage of this facility, but it&rsquo;s useful as well for your run of the mill everyday garden blog feed.<br /><br />For instance, I personally steer well clear of the RSS author element, since it is intended to be populated with the author&rsquo;s email address, and one thing that is not high on my list of Stunningly Brilliant Things to Do is publishing my email address on the web in machine-readable form. <br /><br />For this reason if I felt it necessary to identify myself as the author of content in a feed I&rsquo;d prefer to use the Dublin Core creator element, which allows me to be simply &ldquo;Daly, Kevin&rdquo; or something similar. <strong><em>System.ServiceModel.Syndication</em></strong> enables this with the AttributeExtensions and ElementExtensions properties. <br /><br />There is however a slight catch in the case of RSS: assuming I don&rsquo;t want to include the full namespace declaration with each occurrence of the element (which would waste space and make me look like a bit of an idiot), I&rsquo;ll need to add an entry to the AttributeExtensions of the feed, defining the prefix (usually by convention &ldquo;dc&rdquo; for Dublin Core) and associating it with the namespace <a href=""></a>. <br /><br />The Feed object as I said earlier corresponds with the RSS channel and Atom feed. Now, while feed is the root element in an Atom feed, the root of an RSS feed is, fittingly enough, rss. This means that while in your Atom feed everything will be as expected, in the RSS feed the namespace declarations will not be on the root element as people have come to expect, but on the channel.<br /><br />This is still perfectly valid XML, and unless they are unforgivably sloppy feed readers should handle it correctly, but it does differ from what we have come to expect. There may be a way to achieve the more traditional behaviour but if there is I haven&rsquo;t been able to find it, so for now I just put it down as One of Those Things.<br /><br /><strong>Supporting Conditional GET<br /></strong>Conditional GET is a feature of HTTP that enables the program requesting a file to provide information about the version of that file (if any) they last received, enabling the server to verify whether it actually has a more recent version of the data before sending bits down the line. This can save a lot of bandwidth (and time) for both parties, since in the case where there are no changes the server simply sends an HTTP status of 304 (Not Modified) and no actual content.<br /><br />When you consider that a popular RSS feed could be retrieved by many feed readers and at regular (and frequent) intervals, the bandwidth wasted sending people information they already have can be huge. Or to put it another way, this is going to cost you (and them) money. And thinking of all that unnecessary traffic flying around, you may find yourself thinking the next time internet performance is getting you down: &ldquo;Bugger, if only I&rsquo;d followed Kevin&rsquo;s advice and implemented Conditional GET&rdquo;.<br />The best explanation I&rsquo;ve seen on this subject was Charles Miller&rsquo;s blog article, <a href="" target="_blank">HTTP Conditional GET for RSS Hackers</a>. Important things to know:<br /><br />1. It&rsquo;s mediated through the magic of HTTP headers (possibly the only time in my life I will ever use the phrase &ldquo;magic of HTTP headers&rdquo;, so treasure it).<br /><br />2. The server enables the process by accompanying the feed with Last-Modified and ETag headers, the former containing the date/time of the last time anything was added to or changed in the feed (converted to GMT. Unless you start out with GMT), while the ETag contains any value you want to put in it, enclosed in quotes.<br /><br />3. The client stores the values of ETag and Last-Modified, and presents them with its next request to the server in the If-Modified-Since and If-None-Match headers respectively.<br /><br />4. The server checks these values against what it would be sending for ETag and Last-Modified this time, and if they both match, it should return a 304 status rather than the feed content.<br /><br />None of this is rocket science, but unfortunately it tends to get left out when people are making the &ldquo;Look Kids How Easy It Is to Create Your Own Feeds!!!&rdquo; case.<br /><br />So, how do we actually go about doing this using System.ServiceModel.Syndication and WCF?<br /><br />The first step is to read the header string values from the client request.<br /><br />The headers (if present) can be found in WebOperationContext.Current.IncomingRequest.Headers, assuming you already have a reference to System.ServiceModel.Web.<br /><br />The HttpRequestHeader enum includes the necessary values, so we can retrieve our header strings using WebOperationContext.Current.IncomingRequest.Headers[HttpRequestHeader.IfModifiedSince] and WebOperationContext.Current.IncomingRequest.Headers[HttpRequestHeader.IfNoneMatch].<br /><br />If you use DateTime.Parse to convert the value of If-Modified-Since to a DateTime structure it will be automatically converted from GMT to the local time zone. Since I&rsquo;m still familiarising myself with all the new bits I haven&rsquo;t tried converting it to a DateTimeOffset yet. To eliminate the potential for cross-system rounding errors you may find it useful to strip the millisecond values from DateTime values before comparing them (I do), otherwise you may find that you never seem to get a match.<br /><br />If you determine that the values have not changed, it takes very little code to notify the requester accordingly:<br /><br />WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotModified; WebOperationContext.Current.OutgoingResponse.SuppressEntityBody = true;<br /> return null;<br /><br />This code sets the HTTP status to 304 and returns just the headers with no content, which is exactly what we want<br /><br /><strong>Taking care of the other end &ndash; using <em>System.ServiceModel.Syndication</em> to retrieve feeds<br /></strong>The short version of this would be &ldquo;Please don&rsquo;t&rdquo;, but that wouldn&rsquo;t be very helpful. The longer version would be that SyndicationFeed has a static Load method which takes an XmlReader as a parameter, but that in my opinion this should not normally be used to retrieve feeds directly because it does not provide access to HTTP headers and therefore does not give you the opportunity to observe the client side of Conditional GET. <br /><br />I suggest that you should instead use a WebClient or HttpWebRequest to obtain the data stream from the server, and create the XmlReader on top of this (this is assuming that you&rsquo;re not using the Common Feed List infrastructure that comes with IE7). <br /><br /><strong>Finishing up...<br /></strong>There is not a lot left to say when it comes to producing your feeds &ndash; the auto-generated feed class file gives you a good hint about what you need to provide. <br /><br />Where you get your content from is of course up to you &ndash; you could read it from a database of items that you have entered via whatever method takes your fancy, or generate it using a Fiendishly Cunning algorithm, the latter option having the additional benefit that it will provide years of happy fun for cranks who want to speculate about its occult significance.<br /><br />But there I&rsquo;m straying slightly off topic, which means it must be time to stop. So I will.<br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Microsoft Visual Studio webpage</font></a>. <br /><br /><strong>About the Author</strong><br /><em><img style="margin: 10px" src="\blog\vs2008\intro/kev.jpg" border="0" alt="" width="100" height="149" align="left" />Kevin Daly is has been programming professionally for almost 22 years. He has been using .NET and C# continuously since the Beta 2 in 2001, which probably explains the bags under the eyes. Other examples of his views, rants and even the odd code sample can be found on his blog at </em><a href=""><em></em></a><em>, the construction of which did in fact involve LINQ to SQL, LINQ to XML, WCF HTTP programming and Other Good Things. He will now stop talking about himself in the third person because it&rsquo;s frankly a bit weird.</em><img src="" height="1" width="1" alt=""/> Studio 2008 JavaScript Debugging Studio 2008Tue, 18 Mar 2008 00:00:00 PDTVisual Studio has always offered an impressive debugging environment. From my first experiences with Visual Basic 3 I was hooked on being able to set break points and step through code. <br /><br />Microsoft continued to improve the debugging experience and in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> they have added JavaScript debugging as a first class citizen. <br /><br />This is great for modern web developers who are expected to roll out AJAX web sites that make heavy use of JavaScript. Previously debugging JavaScript was a case of pumping out alert boxes in code to display variable values &ndash; not an enjoyable way to debug by any stretch of the imagination!<br /><br />So here is an overview of what to expect when debugging JavaScript with <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>.<br /><br /><strong>Setting break points<br /></strong>Setting break points for debugging JavaScript is done in exactly the same manner as setting break points in your code. Clicking the gutter space at the start of the line you wish to break on will place a red dot and highlight the line. When this code is encountered the execution flow will pause at that spot.<br /><br /><img src="" border="0" alt="" width="550" height="277" /><br /><br />Once a break point is hit the usual stepping functionality is available &ndash; step through and step into so you can watch the execution flow closely. <br /><br />The break points that you set will be persistent and exist when you re-open a project where you previously set break points.<br /><br /><strong>Variable evaluation<br /></strong>Resting over a variable while debugging with provide the normal inspection view allowing developers to dig deeper into variables. In this case we can see how long our JavaScript will take to perform a resize function.<br /><br /><img src="" border="0" alt="" width="551" height="125" /><br /><br /><strong>Updating values on the fly<br /></strong>Often when debugging you will want to change a value, just to test how the system handles it. Rather than needing to stop, change and restart you can now update a value on the fly while debugging to test new values. In this case we can update our resize time to 25 seconds.<br /><br /><img src="" border="0" alt="" width="550" height="122" /><br /><br />By clicking the value and typing in the new one we can instantly see this reflected. It couldn&rsquo;t be easier.<br /><br /><strong>Querying with the intermediate window<br /></strong>The intermediate window is a hidden gem in Visual Studio &ndash; it&rsquo;s been there as long as I can recall but I don&rsquo;t often see other developers making use of this powerful tool.<br /><br />While debugging, jump into the intermediate window by clicking on the pane at the bottom of Visual Studio. If you don&rsquo;t see the intermediate window you can bring it into view by pressing CTRL + ALT + I.<br /><br />Within the intermediate window you can write queries and code that should be executed within the scope of the currently hit break point. This is great when needing to inspect values that are hard to navigate to, type cast and carry out other tasks. <br /><br /><img src="" border="0" alt="" width="550" height="402" /><br /><br />A word for those who want to start debugging with <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> right away &ndash; make sure that you enable script debugging in Internet Explorer. Without enabling it you will get an error about no symbols being loaded and the the break point will never be hit. <br /><br /><img src="" border="0" alt="" width="413" height="519" /><br /><br />I will be the first to admit that I have never been the biggest fan of writing JavaScript &ndash; I&rsquo;ve always felt the tooling support available was poor and I just plain hated trying to debug my scripts. It is great to see that <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> adds JavaScript debugging. I&rsquo;m sure there are many other developers like myself who are considerably more happy and comfortable working with JavaScript now.<br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Microsoft Visual Studio webpage</font></a>. <br /><br /><strong>About the Author</strong><br /><br /><img style="margin: 10px" src="" border="0" alt="" width="100" height="110" align="left" /><em>John-Daniel Trask is a co-founder of </em><a href="" target="_blank"><em>Mindscape</em></a><em>, a product development company based in Wellington New Zealand. He also maintains a popular </em><a href="" target="_blank"><em>blog about software development and business</em></a><em>.</em><img src="" height="1" width="1" alt=""/> AJAX and ASP.NET Extensions with .NET 3.5 &#0038; Visual Studio 2008 and tricksMon, 17 Mar 2008 00:00:00 PDTOne of the many new features of <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> is built in Support for ASP.NET AJAX development. Previously with Visual Studio 2005 you would have needed to download separate add-ons and project templates in order to AJAX enable your web applications. <br /><br />This becomes much easier with <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>&rsquo;s built in support for AJAX development and the .NET framework 3.5. <br /><br />By creating an ASP.NET website or web application <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> will automatically add the required configuration settings for AJAX in your web config as well as the AJAX controls.<br /><br /><strong>AJAX Project Templates<br /></strong>When you open <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> to create a new web site/application you will see the following templates<br /><br /><img src="" border="0" alt="" width="740" height="163" /><br /><br />As you can see above those templates include the ASP.NET Web application template which will allow us to setup an AJAX enabled web application project as well as the following two new templates:<br /><br />-&nbsp;ASP.NET AJAX Server Control<br />-&nbsp;ASP.NET AJAX Server Control Extender<br /><br />The above two controls differ from the ASP.NET Server Control in that they are associated with JavaScript files and allow you map server control properties with JavaScript file properties. <br /><br />In addition the difference between the ASP.NET AJAX Server Control and the ASP.NET AJAX Server Control extender is that the AJAX Server Control has its own JavaScript associated with it when you build the control but the AJAX Server Control extender allows you to add AJAX/JavaScript functionality to existing controls.<br /><br /><strong>Project Files for ASP.NET AJAX Server Control &amp; Server Control Extender<br /></strong>The screenshots below show you the project files included for both types of the above projects. <br /><br /><strong><em>ASP.NET AJAX Server Control<br /></em></strong><br /><img src="" border="0" alt="" width="239" height="152" /><br /><br /><strong><em>ASP.NET AJAX Server Control Extender<br /></em></strong><img src="" border="0" alt="" width="223" height="164" /><br /><br />If you closely examine each of the content of the project files below you will notice that they are almost identical despite the name differences. However, they are&nbsp;different. With the AJAX Server Control when the GetScriptDescriptors() method of the behaviour class is called it is passed the client id of the custom control as seen below.<br /><br /><img src="" border="0" alt="" width="723" height="129" /><br /><br />But in the case of the Control Extender we pass the client id of another control <br /><br /><img src="" border="0" alt="" width="818" height="122" /><br /><br />You can find additional information about AJAX Server Controls and Control Extenders in the articles <a href="" target="_blank">ASP.NET AJAX Controls and Extenders Tutorial</a>&nbsp;and <a href="" target="_blank">Adding ASP.NET AJAX Client Behaviours to Web Server Controls</a>.<br /><br /><strong>AJAX Extensions Built In Support<br /></strong>As mentioned earlier, when you create a new web application in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> it will be AJAX ready by default and there is no need to download the AJAX extensions as was the case in Visual Studio 2005. When you open the tool box in Visual Studio 2008 you will automatically have the AJAX extensions as shown below.<br /><br /><img src="" border="0" alt="" width="202" height="337" /><br /><br /><strong>Microsoft AJAX Library<br /></strong>The Microsoft AJAX library which can be found on the AJAX downloads site mentioned earlier is a new library that provides you with JavaScript resources for ASP.NET AJAX client components in ASP.NET 3.5.&nbsp; The library is mainly intended for situations where you want to build AJAX applications on any platform and any server based technology such as ColdFusion and ASP.NET.<br /><br /><strong>ASP.NET Extensions 3.5 Preview<br /></strong>Another area of new features that you can use with Visual Studio 2008 and ASP.NET AJAX is the ASP.NET 3.5 Extensions which you can download from the <a href="" target="_blank">AJAX downloads page</a>. When you install the AJAX extensions you&rsquo;ll see some new project templates such as those for creating ASP.NET MVC applications and Dynamic Data Web applications.<br /><br /><img src="" border="0" alt="" width="556" height="162" /><br /><br />From the list of projects above when you choose the ASP.NET 3.5 Extensions web application template you will see the following extra section of new controls that you can use in you applications including things like SilverLight and the new ListView control.<br /><br /><img src="" border="0" alt="" width="280" height="449" /><br /><br />More information on those controls and how to use them can be found on the <a href="" target="_blank">ASP.NET 3.5 Extensions Quick Start</a> tutorials page. <br /><br />One very interesting control in the list of the new controls above is the new ListView control and the reason for that is that it gives you complete control over the generated HTML mark-up. For more information on how you can use the new ListView control along with some other of the extensions preview controls see Scott Guthrie&rsquo;s post on <a href="" target="_blank">how to build a product listing page with clean CSS</a>.<br /><br /><strong>Calling Web Services from Client Script in ASP.NET AJAX<br /></strong>Another really great feature with .NET 3.5 and ASP.NET AJAX is easily being able to use client side code to execute server side logic and display results on your ASP.NET page. <br /><br />This is a great feature that can be very useful when you are not using server controls and what to add some AJAX functionality to your website while being able to use some server side code. This is somewhat similar to what you can do with the AjaxPro library but is baked into the .NET framework. This can be done in three easy steps!<br /><br />-&nbsp;Create your web service function and declare the web service as a script service<br />-&nbsp;Configure your application in web config to allow calling a web service from a script<br />-&nbsp;On your web page register your web service with the script manager and write two JavaScript methods one to call your web service and one to obtain the web service result and display on the page.<br /><br />The article <a href="" target="_blank">Exposing Web Services to Client Script in ASP.NET AJAX</a> explains how you can do this in detail.<br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Microsoft Visual Studio webpage</font></a>. <br /><br /><strong>About the Author<br /></strong><img style="margin: 10px" src="" border="0" alt="" width="100" height="100" align="left" /><a href="" target="_blank"><em>Daniel Wissa</em></a><em> is a Web Developer working in Christchurch. He has a B.Com. from the University of Canterbury where he studied Information Systems and Computer Science and is also a MCAD in .NET. <br /><br />He has been involved with Microsoft and Microsoft communities for many years since being a Student Partner at Canterbury University a few years ago to currently leading the Christchurch .NET user group. He also maintains a blog </em><a href=""><em></em></a><em> where he regularly blogs about Microsoft technologies, local user group events and more.<br /><br /></em><img src="" height="1" width="1" alt=""/> Workflow Enhancements in Visual Studio 2008 Studio 2008Sun, 16 Mar 2008 00:00:00 PDTOne of the enhancements to <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> and the .Net 3.5 platform that I was really interested in was Workflow Services.&nbsp;Having spent much time developing my own infrastructure for Windows Workflow (WF) to handle external events using External Data Exchange (EDE) and Local Communications services (LCS) I was keen to see what approach Microsoft took to making the problem less painful.&nbsp; <br /><br />The LCS/EDE samples are sparse and the approaches taken by different authors are <a href="" target="_blank">quite divergent</a>. The Microsoft documentation also glosses over some of the key details which makes it difficult to get your first real world application working reliably.&nbsp; <br /><br />In addition, the decision to make Windows Workflow a &ldquo;meta&rdquo; workflow (a reasonable approach for a vendor of Workflow systems) makes what you might expect to be mundane tasks surprisingly complex. <br />With Microsoft&rsquo;s recent software releases, the tooling (<a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>) and infrastructure (.Net 3.5) work together to solve the problems of a visual design environment, hosting the workflow, <a href="" target="_blank">routing responses to the correct workflow instance</a>, and <a href="" target="_blank">routing responses to the correct&nbsp; activity instance in the specified workflow instance</a>.<br /><br /><a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> supports the .Net 3.5 Workflow extensions via two additional project templates in the Windows Communication Framework (WCF) section. The &ldquo;Sequential Workflow Service Library&rdquo; and &ldquo;State Machine Workflow Service Library&rdquo; templates generate a basic Workflow, an interface specification and the configuration files required to host the workflow as a WCF service.<br /><br /><img src="" border="0" alt="" width="683" height="512" /><br />The <a href="" target="_blank">Conversations sample</a> provides an introduction to the use of Workflow Services, the management of context,&nbsp; and the use of netTcpContextBinding , which along with basicHttpContextBinding&nbsp; are the two new context aware bindings. <br /><br />The <a href="" target="_blank">DinnerNow sample</a> and <a href="" target="_blank">associated source</a>&nbsp;illustrate how all of the .Net 3.5 (with additional material covering Windows Mobile 6, IIS7 etc.) technologies can be used together to provide a complete &ldquo;end to end&rdquo; solution for a fictional restaurant meal delivery service.<br /><br />One of my main uses of WF has been the <a href="" target="_blank">management of aggregation</a> using combinations of sequential and state machine workflows. I usually have sequential workflows for processes where the workflow is in control, and state machine workflows for where a human is in control.<br /><br />The <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> support for Workflow Services workflow design is via the SendActivity and the ReceiveActivity the in toolbox. When using the SendActivity and ReceiveActivity features of <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> I start with a pre-baked implementation of the interfaces I wish to call and/or implement rather than building them on the fly. <br /><br />I use both the <a href="" target="_blank">IDesign WCF Coding Standards</a> and the <a href="" target="_blank">WCF Contract Design Guidelines</a> written by Simon Evans from Conchango for guidance. These are just two authors (of many) whose guidance I have found to be well considered and reasonable.<br /><br />The ReceiveActivity listens for specific method invocations and handles the associated logic in a workflow. It can be a container for other activities and hold them as part of its execution flow.<br /><br /><img src="" border="0" alt="" width="760" height="589" /><br /><br />For example in the Dinner Now sample the order process is initiated by the following request:<br /><br />void StartRestaurantOrder(RestaurantOrder order, System.Collections.Generic.Dictionary context);<br /><br />As calling this method starts the process of handling an order the ReceiveActivity CanCreateInstance property should be set to true so a new workflow instance is created. <br /><br />It is also important the correct context information is flowed from one workflow activity to another. In the Conversations sample SupplierWorkflow the context passed to the SubmitOrder activity in the request (A ReceiveActivity) is assigned to the context of the Order Details (A SendActivity) for the response.<br /><br /><img src="" border="0" alt="" width="760" height="589" /><br /><br />The ReceiveActivity also allows you to specify what WCF channel to be used. This is a sample from the Customer console workflow application which is part of the Conversations sample. <br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /><img src="" border="0" alt="" width="487" height="191" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /><br />The Conversations sample has three hardwired Shippers which is most probably not terribly representative of aggregation in the real world. Where the number of service providers is not known in advance a Replicator activity could be used to spawn multiple (optionally &ldquo;concurrently&rdquo; executing) instances of a custom activity. <br /><br /><img src="" border="0" alt="" width="640" height="706" /><br /><br />The management of context is not quite seamless but is largely handled &ldquo;automagically&rdquo; by the runtime. But on the first request the developer does need to implement the initial context exchange.&nbsp; In the Customer workflow of the Conversations sample the context is set in the &ldquo;BeforeSend&rdquo; processing of the SendActivity:<br /><br />private void PrepareOrder(object sender, SendActivityEventArgs e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.order.Amount = 1000;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.order.OrderId = 1234;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.contextToSend = this.ReceiveOrderDetails.Context;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />The management of context in a replicator is critical and associating the SendActivity with the correct OwnerActivity (in the case of the SupplierWorkflow in the Conversations sample the hosting parallel activity) and setting the CustomAddress property to target different service instances is necessary for correct functioning of the workflow.<br /><br />For long running activities in workflows such as database lookups and remote calls (i.e. &gt; 0.1 sec) it is most probably worth implementing the &ldquo;send, save state, listen response&rdquo; pattern as <a href="" target="_blank">described in this article by Paul Andrew</a>.<br /><br />The two available context aware bindings posed a major problem for me as I often use Microsoft Message Queue (MSMQ) as the bearer for WCF. I use MSMQ to increase the resilience and scalability of my applications by providing an elastic buffer between services to ensure they don&rsquo;t choke on traffic spikes. It also makes my applications truly disconnected as they can go in and out of service with no impact on each other. <br /><br />MSMQ and workflow services do not integrate nicely (really not at all) which has caused me much pain, though there are <a href="" target="_blank">some third party options available</a>. I also looked at developing my own custom channel which I found would be a non trivial exercise. As a result of this I tend to &ldquo;mix n match&rdquo; Workflow Services and the LCS/EDE approach in my solutions<br /><br />In my opinion, the logical evolution of the tight integration of WF and WCF via Workflow Service appears to be the <a href="" target="_blank">recently announced Oslo initiative</a> which will provide the tooling and infrastructure for model driven design of distributed applications.<br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Microsoft Visual Studio webpage</font></a>. <br /><br /><strong>About the Author</strong><br /><em>This year will be Bryn&rsquo;s 20th year in the industry. He has been working with Microsoft products since Windows 286 was hot. After a couple of years working for Microsoft Consulting Services in Auckland, he now works for Clarus a Christchurch based IT Consulting and contracting company. Bryn is a Certified Scrum Master and is involved with the Christchurch .Net development community through his work doing the logistics for the local meetings. Current projects range from process improvement, remediation, WindowsMobile development, through to highly scalable .Net 3.5 Windows Workflow and Windows Communication Framework architecture work.<br /></em><img src="" height="1" width="1" alt=""/> Studio 2008 Code Metrics &#8211; build more maintainable software, 13 Mar 2008 00:00:00 PDTCyclometric complexity, depth of inheritance&hellip; these are terms that many developers paid very little attention too once their software engineering paper at university was finished and they were baking in the final summer before heading off into the &ldquo;real world&rdquo;. <br /><br />Now, in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>, these terms are back with the new code metrics engine.<br /><br />There is a reason that Cyclometric complexity and other such metrics are taught in university &ndash; they are often great indicators of just how maintainable a software project is. Before digging in deeper and looking at these metrics one by one, how can you generate these metrics?<br /><br />Open a solution in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a>, and under the &ldquo;Analyze&rdquo; menu, select &ldquo;Run code analysis on &rdquo;. <br /><br /><img src="" border="0" alt="" width="562" height="247" /><br /><br />After a short while you will be presented with a snap in pane much like how everything in Visual Studio is presented. Resizing this pane, you should see something similar to the following:<br /><br /><strong>Maintainability Index<br /></strong>We can see in this solution that the Designer project has a maintainability index of 80. A maintainability value is a figure between 0 and 100 where 100 is fantastic and zero means you should probably change your profession :-) <br /><br />A color indicator gives an instant indication of what this values means &ndash; green is universally accepted as &ldquo;good&rdquo;, red as &ldquo;bad&rdquo;. <br /><br /><img src="" border="0" alt="" width="560" height="104" /><br /><br />So far so good but is there anywhere that is causing concern? Setting the filtering to find anything below a value of 20 we get a single result. Drilling in we can find exactly where that code exists:<br /><br /><img src="" border="0" alt="" width="560" height="105" /><br /><br />By double clicking the row we are taken directly to the code that is at fault and, surprise, it&rsquo;s the automatically generated code that Visual Studio makes for initializing a form! While it&rsquo;s not the best code in the world it&rsquo;s at least reliable and it&rsquo;s not something we actively have to maintain so we can safely ignore that method.<br /><br /><img src="" border="0" alt="" width="559" height="159" /><br /><br />More information on how this value is calculated can be found on the <a href="" target="_blank">Microsoft Code Analysis Team Blog here</a>.<br /><br /><strong>Cyclometric complexity<br /></strong>Cyclometric complexity is a well known way of calculating how complex code is. We won&rsquo;t go into detail here about exactly how to calculate it yourself but I would recommend checking out <a href="" target="_blank">Wikipedia for more information</a>. <br /><br />A lower figure for cyclometric complexity is important and testing this value is now included in FXCop, the built in static analysis tools for visual studio meaning that warnings may be generated if the cyclometric complexity of a method goes beyond a healthy level. <br /><br /><strong>Depth of inheritance<br /></strong>This metric gives a quick indication of how many layers of code there are forming an object. <br /><br />For example, if class A inherits class B then class A has a depth of 2. Understandably, once code inherits back too far it can become quite cumbersome trying to maintain that code &ndash; a change at one layer may have an impact on code elsewhere. <br /><br />One thing to keep in mind with this metric however is that it examines the entire .Net framework. What I mean here is that if you inherit, for example, off System.Windows.Window, you will get a reasonably high figure immediately because of the inheritance depth in the framework. <br /><br />This diagram from the Microsoft Code Analysis Team Blog shows how depth of inheritance is calculated:<br /><br /><img src="" border="0" alt="" width="560" height="385" /><br /><br /><strong>Class coupling<br /></strong>This metric provides a figure of how many classes that a given project, class or method relies upon. It only takes account of the class itself and not the sub classes in the inheritance hierarchy. As with the depth of inheritance, less is best.<br /><br />Another diagram from the Microsoft Code Analysis Team Blog helps explain class coupling:<br /><br /><img src="" border="0" alt="" width="1" height="1" /><br /><img src="" border="0" alt="" width="560" height="428" /><br /><br /><br /><strong>Lines of code<br /></strong>Possibly one of the less useful metrics, lines of code was once looked upon as a key metric of how large a software development project was. <br /><br />The truth is that the lines of code is often a misleading figure as you can have a lot of lines that do very little or very few that do a lot (and a mix of the two). <br /><br />How lines of code are counted is also up for debate &ndash; should you include whitespace? What about lines that do not equate to direct code like &ldquo;{&ldquo;? The engine for calculating lines of code in Visual Studio is reluctant to count anything that isn&rsquo;t a line of code that will evolve into executable code. This means the figure may be lower than the figure presented by other tools.<br /><br />Having said all this, generally speaking, a lower figure is always better if possible &ndash; just don&rsquo;t sacrifice readability to push it lower in every case.<br /><br /><strong>Team based development<br /></strong>There is plenty of extra usefulness in the code metrics additions in <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> when it comes to working with your team. The ability to export to Microsoft Excel is useful when needing to send the stats to other team members who might not be developers &ndash; project managers for example. If you use Team System you&rsquo;re also in luck as you can create work items based on the metrics.<br /><br /><a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> is a solid step forward in aiding developers in taking a more holistic approach to software development &ndash; rather than just for writing code, Visual Studio now can be used to better understand the interactions of our code and how that impacts the maintainability and robustness of our solutions. <br /><br />I hope this post has helped illustrate what the metrics provided by Visual Studio mean and what value they provide to your development process. If you would like to learn more about code metrics and code analysis in Visual Studio I&rsquo;d highly recommend reading the <a href="" target="_blank">Visual Studio Code Analysis Team Blog here</a>.<br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Microsoft Visual Studio webpage</font></a>. <br /><br /><strong>About the Author</strong><br /><br /><img style="margin: 10px" src="" border="0" alt="" width="100" height="110" align="left" /><em>John-Daniel Trask is a co-founder of </em><a href="" target="_blank"><em>Mindscape</em></a><em>, a product development company based in Wellington New Zealand. He also maintains a popular </em><a href="" target="_blank"><em>blog about software development and business</em></a><em>.</em><img src="" height="1" width="1" alt=""/> CSS &#0038; HTML Support in Visual Studio 2008 and tricksWed, 12 Mar 2008 00:00:00 PDT<a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> is equipped with better HTML and CSS support than Visual Studio 2005 and the new features should make anyone who spends a lot of time in design/HTML view a lot happier.<br /><br />The software now shares the same web designer that comes with the Expression Web product so it gives developers all the goodies that designers have in that package. <br /><br />Among those new features is the introduction of the split view between design and source, CSS style manager, CSS Properties Grid as well as CSS and JavaScript intellisense in source view. <br /><br />More on JavaScript intellisense can be found in this article: <a href="">A happy JavaScript-er with the new features of Visual Studio 2008</a><br /><br /><strong>HTML Editing Split View</strong><br />This is one of the features I really like about <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Visual Studio 2008</font></a>. In the past I used to find it quite annoying to have to switch between source and design view and even more so when the switching used to break your HTML code.<br /><br />With the split view introduced this now becomes less of a problem. A great thing about split view is the synchronisation between both views as can be seen in the image below.<br /><br /><img src="" border="0" alt="" width="640" height="234" /><br /><br />Any changes you do in either view is immediately reflected on the other view. In the image above you can see there are some selected text in source view and that same text is shown selected in design view. <br /><br /><strong>Improved CSS Support</strong><br />Another big change the <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> Web designer is support for CSS. As mentioned earlier <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> comes with a CSS Styles Manager and CSS Properties Grid which can be seen below.<br /><br /><strong>CSS Properties Grid<br /></strong>You can think of the CSS properties Grid as the traditional properties window that you use to specify the properties of an ASP.NET web control, so this is basically where you can define the CSS style settings such as font, background and so on.&nbsp; <br /><br /><img src="" border="0" alt="" width="201" height="519" /><br /><br />If you select a section in design/source view that has a CSS style applied on it the properties window will show you the applied attributes of that style to the selected section as shown below. This is a nice easy way to know which styles are affecting a particular section. <br /><br /><img src="" border="0" alt="" width="198" height="503" /><br /><br />In addition, the properties grid also supports identifying overridden style sheets, so if say you have a div tag with a style applied to it, and inside it there is paragraph tag with another style applied to it, you will be able to identify which style is being applied to a set property and the overridden property will be crossed as shown below.<br /><br /><img src="" border="0" alt="" width="207" height="43" /><br /><br /><strong>CSS Style Manager<br /></strong>Another new enhancement with CSS support is the CSS Style Manager; this is the second CSS tab next to the Toolbox tab that can be seen in the first screenshot earlier in the post. <br /><br /><img src="" border="0" alt="" width="201" height="719" /><br /><br />The CSS Style Manager allows you to add existing styles by pointing to an existing CSS file, create new styles or modify existing ones. You can also find all instances where a style is being used as shown in the options below. You can also see a preview of the code of any particular style by hovering over the style name.<br /><br /><img src="" border="0" alt="" width="231" height="260" /><br /><br />If the icon name next to the style has a circle around it this indicates that the style is being used in the current document. The list of visible styles can be modified re-sorted using the options dialog next to the New Style link button as shown in the image below.<br /><br /><img src="" border="0" alt="" width="369" height="252" /><br /><br /><strong>CSS Intellisense in Source View<br /></strong>Not only does <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> have improved style management options but also when you&rsquo;re editing HTML in source view you&rsquo;ve got CSS style intellisense that gives you direct access to your CSS classes, etc when editing your HTML as shown below. This feature also works with ASP.NET controls and not just standard HTML.<br /><br /><img src="" border="0" alt="" width="425" height="106" /><br /><br />Another new feature with <a href=";clk=1&amp;creativeID=90250" target="_blank">Visual Studio 2008</a> is the introduction of nested master pages while this can be an entire post in itself basically the idea is that now you can assign created two master pages and assign one master page as the master page template for the second master page. <br /><br /><br /><strong>Download Visual Studio 2008 90 day trial<br /></strong>For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the <a href=";clk=1&amp;creativeID=90250" target="_blank"><font color="#4e6064">Microsoft Visual Studio webpage</font></a>. <br /><br /><strong>About the Author<br /></strong><img style="margin: 10px" src="" border="0" alt="" width="100" height="100" align="left" /><a href="" target="_blank"><em>Daniel Wissa</em></a><em> is a Web Developer working in Christchurch. He has a B.Com. from the University of Canterbury where he studied Information Systems and Computer Science and is also a MCAD in .NET. <br /><br />He has been involved with Microsoft and Microsoft communities for many years since being a Student Partner at Canterbury University a few years ago to currently leading the Christchurch .NET user group. He also maintains a blog </em><a href=""><em></em></a><em> where he regularly blogs about Microsoft technologies, local user group events and more.<br /><br /></em><img src="" height="1" width="1" alt=""/>