Tuesday, February 28, 2012

KB2656351 does not apply, or is blocked by another condition on your computer.

 

If you have .Net Framework 4.5, uninstall it along with VS.Net 2011 Developer Preview.  This prevents this update from being delivered (possibly fools Microsoft Update to think no .Net Framework 4.0 installed).

After I did the above,  KB2656351 started showing up on Windows Update as an “important update”.

Thursday, September 29, 2011

Design Driven Development

I’ve tried to capture what I feel are the important traits to put “Design” First, to have a design driven development.

image

Technorati Tags: ,

Tuesday, April 26, 2011

Deploying an ASP.Net application on Windows Azure

 

  1. Setup & Pre-requisites

    1. Signup for Windows Azure Pass using code ‘DPWE01’ (Don’t blame me if this doesn’t work)
    2. Use Management portal to add your public IP to the firewall
    3. Install VS.Net 2010 Ultimate/Prof/Express, Azure SDK 1.4
  2. Migrate Database to SQL Azure 

    1. Upload the database to SQL Azure using SQL Azure Migration Wizard
    2. Change your connection strings in web.config to point to SQL Azure.
  3. Would it work on Azure?

    1. Add Azure Project to the your Solution (that you’re migrating)
    2. Compile & Run locally by choosing the azure project (*.ccproj) as the startup
  4. Configure Azure

    1. Use management portal and create hosted service (select ‘No Deployment’ option) clip_image002
    2. Create a Storage Account
    3. clip_image004
  5. Publish to Azure

    1. Rebuild your Solution in VS.Net 2010 and click ‘Publish’ clip_image006
    2. Create a new certificate clip_image008
    3. Click on View and Save the certificate to a file (*.cer file)
      • One of the best practices is to create a ‘Solution Folder’ in your Solution and place these files there. This ensures your certificates are source controlled. Note there’s no way to download a certificate back (as of this writing) from Azure Management Portal clip_image010
    4. Upload the certificate to Management Certificate section in the management portal

      clip_image012
    5. From management portal get your subscription ID (available in the properties of the root node called Subscription)  clip_image014
    6. It should authenticate and the Storage account dropdown should list the accounts you’ve created before. Select the account shown.
    7. Click on remote configure linkclip_image016
    8. Create another certificate for remote access
    9. Click on View and save the certificate with Private key (the password you provide here will be needed when you upload the certificate to Azure portal) (*.pfx) clip_image017
    10. Upload the certificate under Certificate Folder under your Hosted Service clip_image019
    11. Click ‘OK’

 

Wednesday, November 24, 2010

My 1st Windows Phone Application

Well, this why you shouldn’t be buying a book relying on title alone.  Winking smile

I figured if you navigate to a URL from Windows Phone browser, I should be able to see the SL app right away.  Silly me!

It brought me to the Silverlight download page!  Isn’t SL supposed to be the ‘Default’ for Windows phone app development?

Should I be “installing” my app as opposed to running directly from the browser?  More on this once I figure this out.

Thursday, July 01, 2010

DynamicMvvM – An Overview

 

Goals
  1. How do you adapt a pre-existing Object Model (that doesn’t support notifications)?
  2. How do I extend my ViewModel with a commanding infrastructure?
  3. How do I make my standard .Net resource available as part of ViewModel Metamodel?
  4. How do I make my model support a State Machine?
    • This is could be really useful when to trigger actions based on object state
    • Essentially, we’re moving all action(s)/behaviors into commands making the models passive
  5. How do I extend the existing Model with new properties?
  6. How do I create a brand new model from scratch (fully dynamic)?
  7. How do I make related information part of Model MetaModel?
    • For example, EmployeeKind can be an enum of ‘Skilled, Unskilled, Others’.
  8. How do I emulate standard static C# property on a Dynamic model?
  9. How do I add support for Radio / Linked Properties
  10. How do I translate an existing object into a dynamic Model?
  11. How do I translate the same back?

DynamicMvvM

Initial Design

ModelProviders

Models-2

 

Assigning AutomationIds Dynamically in Silverlight

I came across an interesting problem recently:  How do you assign AutomationIds automatically for Items in an ItemsControl?

<UserControl 
    x:Class="ThinkFarAhead.AutoAutomationId.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:ThinkFarAhead.AutoAutomationId" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400">
 
  <Grid x:Name="LayoutRoot" Background="White">
    <StackPanel>
      <ItemsControl x:Name="ItemsControl">
        <ItemsControl.ItemTemplate>
          <DataTemplate>
            <TextBlock 
                local:AutomationHelper.Parent=
                    "{Binding ElementName=ItemsControl}"
                local:AutomationHelper.CurrentItem=
                    "{Binding Path=DataContext,
                    RelativeSource={RelativeSource TemplatedParent}}"
                local:AutomationHelper.IndexedId="Message{0}"
                    AutomationProperties.AutomationId=
                        "{Binding (local:AutomationHelper.IndexedId),
                        RelativeSource={RelativeSource Self}}"
                Text="{Binding (AutomationProperties.AutomationId), 
                    RelativeSource={RelativeSource Self}}" />
          </DataTemplate>
        </ItemsControl.ItemTemplate>
      </ItemsControl>
    </StackPanel>
  </Grid>
</UserControl>

 

namespace ThinkFarAhead.AutoAutomationId
{
    using System.Windows;
    using System.Windows.Controls;
 
    public static class AutomationHelper
    {
        #region Constants and Fields
 
        public static DependencyProperty CurrentItemProperty =
            DependencyProperty.RegisterAttached(
                "CurrentItem",
                typeof(object),
                typeof(AutomationHelper),
                new PropertyMetadata(null)
            );
 
        public static DependencyProperty IndexedIdProperty =
            DependencyProperty.RegisterAttached(
                "IndexedId",
                typeof(string),
                typeof(AutomationHelper),
                new PropertyMetadata(null)
            );
 
        public static DependencyProperty ParentProperty =
            DependencyProperty.RegisterAttached(
                "Parent",
                typeof(ItemsControl),
                typeof(AutomationHelper),
                new PropertyMetadata(null)
            );
 
        #endregion
 
        #region Public Methods
 
        public static object GetCurrentItem(DependencyObject element)
        {
            return element.GetValue(CurrentItemProperty);
        }
 
        public static string GetIndexedId(DependencyObject element)
        {
            return element.GetValue(IndexedIdProperty) as string;
        }
 
        public static ItemsControl GetParent(DependencyObject element)
        {
            return element.GetValue(ParentProperty) as ItemsControl;
        }
 
        public static void SetCurrentItem
        (
            DependencyObject element, object value
        )
        {
            element.SetValue(CurrentItemProperty, value);
        }
 
        public static void SetIndexedId
        (
            DependencyObject element, string value
        )
        {
            value = string.Format(value, 
                GetParent(element)
                .Items
                .IndexOf(GetCurrentItem(element)));
 
            element.SetValue(IndexedIdProperty, value);
        }
 
        public static void SetParent
        (
            DependencyObject element, ItemsControl value
        )
        {
            element.SetValue(ParentProperty, value);
        }
 
        #endregion
    }
}

 

namespace ThinkFarAhead.AutoAutomationId
{
    using System.Collections.Generic;
    using System.Windows.Controls;
 
    public partial class MainPage : UserControl
    {
        #region Constructors and Destructors
 
        public MainPage()
        {
            this.InitializeComponent();
 
            var list = new List<string>();
 
            list.Add("Zero");
            list.Add("One");
            list.Add("Two");
            list.Add("Three");
            list.Add("Four");
            list.Add("Five");
            list.Add("Six");
            list.Add("Seven");
            list.Add("Eight");
            list.Add("Nine");
            list.Add("Ten");
 
            this.ItemsControl.ItemsSource = list;
        }
 
        #endregion
    }
}

 

image

Hope it helps somebody!

 

Tuesday, May 18, 2010

Silverlight 4.0, Dynamic Types & Extension Methods

I’ve been very busy lately earning my living.  Not able to get time to blog!  But hey, I wanted to hack together something - the DynamicMvvM framework which I had hinted about earlier - over this weekend.  This got me working with the beauty that is DynamicObject (and ExpandoObject) in C# 4.0.

The first error I had hit was probably the one every one working with DynamicObject for the first time encounters:

Error    2    Predefined type 'Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported    TestApp
Error    3    One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?   

True enough when I did add Microsoft.CSharp.dll and System.Core.dll, the errors went away.

Using a keyword in C# requires me to add some assemblies?  Oops…  Adding these two assemblies to Visual Studio project templates for Silverlight, by default, would be high on my wish list!  Thankfully, these are added by default to WPF projects (the only one I checked) and hopefully other project types.

Another interesting thing about DynamicObject is that when it’s assigned to a dynamic, it’s not able to find ExtensionMethods.  This is reasonable considering all the calls to the methods and properties are resolved at runtime and the ExtensionMethods are not part of the object’s interface per se.

Just one one more piece of info you need to file away for future use.

Thursday, March 11, 2010

Update: The Need for ViewModels

Well, I left out something that was very close to my heart having been developing UI based applications for such a long time.  That’s testability:  How do you Unit Test your UI with standard / Open Source tools (Project White – now rechristened White -  is one I experimented with couple of years ago).  Though, Microsoft has made it easier than ever before to automate UI for testing with Automation APIs,  if your UI is clearly separated, you could just use MSTest/XUnit frameworks to Unit test.