in

MSMVPS.COM

The Ultimate Destination for Blogs by Current and Former Microsoft Most Valuable Professionals.

Kevin McNeish [C# and .NET]

The Blog
  • DevTeach Toronto, 2008 - A Great Conference!

    DevTeach (www.devteach.com) is one of the best deals in .NET conferences...it's a great small conference that gives you access to many of the regular .NET speakers but in a much smaller venue. Personally, I'm giving a pre-con called "WPF Meets the iPhone" which elaborates on my article in CoDe Magazine (http://www.devx.com/codemag/Article/37589). In this pre-con you learn a lot about WPF in general as we do something fun--recreate the iPhone user interface in WPF.

    Kevin McNeish
    INETA Speaker

    Microsoft .NET MVP
    President, Oak Leaf Enterprises, Inc.
    Chief Architect, MM .NET Application Framework
    http://www.oakleafsd.com/

     

  • How to select a different WPF TabItem in Visual Studio 2008

    Sadly, Microsoft did not provide a TabControl designer for Visual Studio 2008. If you want to edit a TabItem, you can get around this limitation and select a TabItem other than the default by temporarily changing the TabControl's <<b>>SelectedIndex<</b>> property to the index of the TabItem you want to edit.

    Kevin McNeish
    INETA Speaker

    Microsoft .NET MVP
    President, Oak Leaf Enterprises, Inc.
    Chief Architect, MM .NET Application Framework
    http://www.oakleafsd.com/

  • How to apply a WPF style to all elements of a particular type?

    Often, you need to apply the same style to elements of a particular type, such as Button, TextBox, MenuItem, and so on. To do this, specify a style that uses the TargetType attribute. The following example demonstrates specifying Font settings and a Background color for all Buttons on a form:

    <Window.Resources> <Style TargetType="{x:Type Button}"> <Setter Property="FontFamily" Value="Times New Roman" /> <Setter Property="FontSize" Value="30" /> <Setter Property="FontWeight" Value="Bold" /> <Setter Property="Background" Value="#FFCA5132" /> </Style> </Window.Resources>

    Note: For this to work properly, you must omit the Style's Key attribute!

    Kevin McNeish
    INETA Speaker

    Microsoft .NET MVP
    President, Oak Leaf Enterprises, Inc.
    Chief Architect, MM .NET Application Framework
    http://www.oakleafsd.com/

  • Fixing the Vista backup error "the system cannot find the specified file"

    I've been getting an error "when using the Vista Backup tools the last few days "the backup did not complete...the system cannot find the specified file". As it turns out this seems to be a Vista "issue". Apparently this is because a shadow copy created by Vista is conflicting with the backup process. Here's what I did to fix the problem:

    1. From Control Panel, select "System"
    2. In the System Protection tab, uncheck all drives listed under "Automatic Restore Points"
    3. Click OK to save the settings--this deletes all existing shadow copies
    4. Go back into the System settings and reselect the drives that you unselected

    Next time you run a backup, you shouldn't experience this problem again!

    Kevin McNeish
    INETA Speaker

    Microsoft .NET MVP
    President, Oak Leaf Enterprises, Inc.
    Chief Architect, MM .NET Application Framework
    http://www.oakleafsd.com/

  • Downloading the VS 2005 Class Designer PowerToys

    I just heard that you can download the VS 2005 Class Designer PowerToys at this link:

    http://www.codeplex.com/modeling

    With the deminse of the GotDotNet web site, it's been difficult to find a place where it can be downloaded!

    Kevin McNeish
    Microsoft .NET MVP
    President, Oak Leaf Enterprises, Inc.
    Chief Architect, MM .NET Application Framework: http://www.oakleafsd.com

     

  • DevTeach 2007, Vancouver - .NET 3.0/3.5 Training PreCon

    Just wanted to let everyone know about the .NET 3.0 pre-con I'll be giving at DevTeach 2007, Vancouver on November 26.

    I'll be giving an introductory session on all four .NET 3.0 technologies:

    • Windows Workflow
    • Windows Presentation Foundation
    • Windows Communication Foundation
    • Windows CardSpace

    If you want to get up the learning curve quickly and get a great all-day immersion in these new technologies I recommend heading to Vancouver for this pre-con (www.devteach.com)! DevTeach conference is normally held annually in Montreal (usually in the spring) but is branching out to Vancouver this year. It's a great conference--lots of great topics and speakers in a smaller venue providing easier access to speakers.

    Kevin McNeish
    Microsoft .NET MVP
    President, Oak Leaf Enterprises, Inc.
    Chief Architect, MM .NET Application Framework: http://www.oakleafsd.com

     

  • Converting a String to a GUID

    To convert a string to a GUID, do the following:

    In C#:

    Guid MyGuid = new Guid(stringValue);

    And in VB .NET:

    Dim MyGuid As Guid = New Guid(stringValue)
     

    Best Regards,

    Kevin McNeish
    Microsoft .NET MVP
    President, Oak Leaf Enterprises, Inc.
    Chief Architect of the MM .NET Application Framework

  • Fixing the Creation of Setup/Deployment Packages on Windows Vista (Fixing the dreaded "error code 2869")

    There are a few Visual Studio 2005 bugs that surface when building installation packages on a Windows Vista machine.

    1. If your installation package performs a custom action you will get the dreaded "error code 2869" error during installation
    2. Exceptions thrown during the install process are obscured

    I found answers to these problems in Aaron Stebner's Web Log and at Omar Shahine's Web Log -- thanks to these folks for posting their solutions!

    Some of the instructions were not as clear as they could be, so I have repeated them here with a few modifications:

    To fix both of these problems:

    1. Download this sample script and extract the contents to the root directory of your Visual Studio Setup/Deployment project
    2. If you haven't already done so, download and install the Windows Software Development Kit for Windows Vista and .NET Framework 3.0 Runtime Components
    3. In Windows Explorer, go to this folder:

      C:\Program Files\Microsoft SDKs\Windows\v6.0\Samples\SysMgmt\MSI

      Locate the file WiRunSQL.vbs and copy it to your Setup/Deployment project's root folder
    4. Open the Setup/Deployment project in Visual Studio 2005
    5. Press F4 to display the Properties window
    6. Click on the Setup/Deployment project in the Solution Explorer
    7. Click on the PostBuildEvent property in the Properties window to display the ellipses button
    8. Click on the ellipses button to display the Post-build Event Command Line dialog
    9. Add the following command lines to the Post-build event command line text box:

      cscript.exe "$(ProjectDir)CustomAction_NoImpersonate.js" "$(BuiltOuputPath)"
      cscript.exe "$(ProjectDir)WiRunSQL.vbs" "$(BuiltOuputPath)" "INSERT INTO `Error` (`Error`, `Message`) VALUES (1001, 'Error [1]: [2]')"
    10. Build your project in Visual Studio 2005

    Best Regards,

    Kevin McNeish
    Microsoft .NET MVP
    President, Oak Leaf Enterprises, Inc.
    Chief Architect of the MM .NET Application Framework

  • Property Code Snippet for Visual Studio 2005

    In contrast to the default Visual Studio format, I prefer to format my properties like this with the associated variable beneath the property declaration and a comment above it <s>:

    /// <summary>
    /// OrderID Property
    /// </summary>
    public int OrderID
    {
        get { return _orderID; }
        set { _orderID = value; }
    }
    private int _orderID;

    My partner in crime Rick Strahl (www.west-wind.com) wrote a blog post about a snippet he created do something similar which gave me the idea to do it to suit my own needs. Here's what I've come up with:

    <?xml version="1.0" encoding="utf-8" ?>
    <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
        <
    CodeSnippet Format="1.0.0">
           
    <Header>
                <
    Title>prop</Title>
                <
    Shortcut>prp</Shortcut>
                <
    Description>Code snippet for property and backing field</Description>
                <
    Author>Kevin McNeish</Author>
                <
    SnippetTypes>
                    <
    SnippetType>Expansion</SnippetType>
                </
    SnippetTypes>
            </
    Header>
            
    <Snippet>
                <
    Declarations>
                   
    <Literal>
                       
    <ID>type</ID>
                        <ToolTip>Property type</ToolTip>
                        <
    Default>int</Default>
                    </
    Literal>
                    <
    Literal>
                        <
    ID>property</ID>
                        <
    ToolTip>Property name</ToolTip>
                        <
    Default>MyProperty</Default>
                    </
    Literal>
                    
    <Literal>
                        <
    ID>field</ID>
                        <
    ToolTip>The variable backing this property</ToolTip>
                        <
    Default>_var</Default>
                    </
    Literal>
                </
    Declarations>
                <
    Code Language="csharp">
                    <![CDATA[
    /// <summary>
       
    /// $property$ Property
        /// </summary>
        public $type$ $property$
        {
            get { return $field$;}
            set { $field$ = value;}
        }
        private $type$ $field$;
    $end$
    ]]>
                </
    Code>
            </
    Snippet>
        </
    CodeSnippet>
    </
    CodeSnippets>

    To use this snippet, create a file named prp.snippet and place it in this folder on your computer:

    My Documents\Visual Studio 2005\Code Snippets\Visual C#\My Code Snippets

    The keyword to fire this snippet is "prp" (rather than "prop"). Obviously this snippet can also be adapted for VB .NET.

    Note that in order to get camel case to work properly for the private variable (since you can't call a function from a snippet) after typing _myVariable in the Get() accessor you need to press ENTER rather than TAB!

    Best Regards,

    Kevin McNeish
    Microsoft .NET MVP
    President, Oak Leaf Enterprises, Inc.
    Chief Architect of the MM .NET Application Framework

  • Fixing "Rebuild" error when using the Object Test Bench

    Lots of folks don't know that Visual Studio 2005 has design-time expression evaluation that allows you to instantiate objects and execute their methods at design time--a very cool feature. You can do this by right-clicking an object in a class diagram and selecting Create Instance from the shortcut menu (you can also do the same from the Class View window).

    If you get an error telling you to rebuild the project when trying to instantiate an object in the Object Test Bench (and the error won't go away), rebuild your project, then select Tools | Options from the Visual Studio menu and in the Options dialog, select Projects and Solutions in the left pane then mark the Show advanced build configurations check box.

    Best Regards,

    Kevin McNeish
    Microsoft .NET MVP
    President, Oak Leaf Enterprises, Inc.
    Chief Architect of the MM .NET Application Framework


     

  • Visual Studio SDK 4.0 Updates the Microsoft DSL Tools Version 1.0

    If you were previously using the Microsoft DSL Tools version 1.0 released back in September 2006 in the Visual Studio 2005 SDK 3.0, then you should definitely install the Visual Studio SDK 4.0 that includes bug fixes for Domain Specific Language Tools Version 1.0. To see what's been changed, after installing the 4.0 SDK, check out the following Readme.htm file located in this directory by default:

    C:\Program Files\Visual Studio 2005 SDK\2007.02\VisualStudioIntegration\Tools\DSLTools\readme.htm

    Kevin McNeish
    President, Oak Leaf Enterprises, Inc.
    http://www.oakleafsd.com

  • New Microsoft Empower Program Link - Get MSDN Universal on the cheap--just $375!

    This is an update my previous blog post about the Microsoft Empower program. Here is the new link to the program:

    https://empower-isv.one.microsoft.com/isv/programguide/Default.aspx

    If you keep clicking the Next button, you'll get to the Benefits page which, among other things, lists the following benefit that you get for just $375:

    Development and Testing Licenses
    MSDN® Universal Subscription
    (Licenses included in MSDN are for development and testing only)

    One (1) MSDN Universal license and four (4) user licenses. Up to five (5) partner staff members can use MSDN licenses for development and testing concurrently.

    Basically, they require that you build an application that supports one of the following platforms:

    -->
    *Microsoft Software **Software Tests
    Microsoft® Windows® .NET Server 2003 Certified for Windows® .NET Server 2003
    Designed for Windows® Server 2003
    Microsoft® Windows® XP Designed for Windows® XP Testing
    Microsoft® Windows® 2000 Verified Compatible for Microsoft® Windows® 2000
    Certified for Microsoft® Windows® 2000
    Microsoft® SQL Server™ 2000 Certified for SQL Server™ 2000
    Microsoft® mobility platform (Microsoft® Windows® for Pocket PC, Microsoft® Windows® for Smartphone) Designed for Windows® for PocketPC
    Designed for Windows® for Smartphone
    Microsoft® Office Microsoft® Platform Test for ISV Solutions - OS component, Office Component
    OR
    Designed for Windows® and Office Component
    Microsoft® .NET Web services Microsoft® Platform Test for ISV Solutions – OS component , Web service component
    OR
    Designed for Windows® and Web service component
    Microsoft® .NET Framework Microsoft® Platform Test for ISV Solutions – OS component, Managed Code component
    OR
    Designed for Windows® and Managed Code component
    Microsoft® Business Solutions Microsoft® Business Solutions Test for ISV Solutions-Great Plains;
    Microsoft® Business Solutions Test for ISV Solutions-Navision;
    Microsoft® Business Solutions Test for ISV Solutions-Axapta;
    Microsoft® Business Solutions Test for ISV Solutions-Solomon
    Microsoft® Small Business Accounting Microsoft® Small Business Accounting

More Posts Next page »
Copyright © is the original authors. Blog site is an independent site not sponsored by Microsoft. The Yoda blog server and the Brianna SQL server would like to thank www.ownwebnow.com and www.exchangedefender.com. They wouldn't be here and broadcasting without the generosity of Vlad Mazek and his companies.
Powered by Community Server (Commercial Edition), by Telligent Systems