Announcing Alexandria RTW

Release to the World that is. Today at 4:33 PM my wife delivered our newest family member, Khara Alexandria Brown. She weighs in at a healthy 6 pounds 3 ounces and has a modelesque height of 19 and 1/4 inches. Happy Birthday my little princess and many more!

Khara's Birthday 013

Khara's birthday 020

Posted by Mike Brown | with no comments

Blend Behaviors FTW

Update: As promised, here’s the code read below for usage.
AgilityCore.zip

Beyond SketchFlow (THE official coolest thing since sliced bread), Blend 3 has some other great features for improving the designer-developer workflow. Something I like a lot  (and most of my fellow WPF Disciples) are Behaviors.

If you recall, I spent a couple of posts a few years back talking about using attached properties to enable adding functionality to controls without code. Blend Behaviors take the pattern and wrap it in a simple API making it much easier to get down to the business of hacking WPF.

Even more interesting than the standard attached behaviors is the new Trigger system implemented using the pattern. Including the capability of creating custom Trigger Actions. In the initial release of WPF, Trigger Actions were effectively sealed because they are abstract and the function that inheritors need to override is marked internal. This effectively stood in the way of providing a solution to this problem in the MSDN forums.

The new Behavior-based trigger system (which works in Silverlight and WPF) opens the door for custom Trigger Actions. Now that we have custom Trigger Actions, I’m able to create an ExecuteCommandAction that allows you to invoke a Command from any trigger. The code is simple as is its usage.

First we define the trigger action

   1:  using System.Windows;
   2:  using System.Windows.Input;
   3:  using Microsoft.Expression.Interactivity;
   4:  using System.ComponentModel;
   5:   
   6:  namespace AzureCoding.Agility.Core.Behaviors
   7:  {
   8:      public class ExecuteCommandAction : TriggerAction<FrameworkElement>
   9:      {
  10:   
  11:          [Category("ExecuteCommandAction Properties"),
  12:          Description("The name of the Command that will be executed by this Trigger Action")]
  13:          public string TargetCommand
  14:          {
  15:              get { return (string)GetValue(TargetCommandProperty); }
  16:              set { SetValue(TargetCommandProperty, value); }
  17:          }
  18:   
  19:          public static readonly DependencyProperty TargetCommandProperty =
  20:              DependencyProperty.Register("Target Command",
  21:                                          typeof(string),
  22:                                          typeof(ExecuteCommandAction),
  23:                                          new PropertyMetadata
  24:                                              (TargetCommandChanged));
  25:   
  26:          private static void TargetCommandChanged(DependencyObject d,
  27:              DependencyPropertyChangedEventArgs e)
  28:          {
  29:   
  30:          }
  31:   
  32:          protected override void Invoke(object parameter)
  33:          {
  34:              var path = TargetCommand;
  35:              var dc = AssociatedObject.DataContext;
  36:              var targetCommand = 
  37:                  dc.GetType().GetProperty(path).GetValue(dc, null) as ICommand;
  38:   
  39:              if (targetCommand != null && targetCommand.CanExecute(parameter))
  40:              {
  41:                  targetCommand.Execute(parameter);
  42:              }
  43:          }
  44:      }
  45:  }

 

The new Behaviors framework is defined in the Microsoft.Expression.Interactivity namespace (in the assembly by the same name). We inherit from TriggerAction, a descendant of the base behavior class and declare a dependency property for the name of the command we want invoked (lines 11 – 30). Finally, we override the Invoke method from the TriggerAction class. Unfortunately, it appears that Binding does not work for TriggerActions and I haven’t heard if this will be addressed in the final version of the behaviors framework. At least for now we have to get a handle to the target command manually. Once that’s done, we just check that it can execute and then ask it to do so. The code uses the convention that the command resides on the Data Context of the object to which your trigger is attached. I also didn’t bother putting in robust error checking (so if the property doesn’t exist, you’ll get an exception).

image 
Once we’ve built the library and referenced it in a Blend 3 project, we can see our new behavior in the asset library

custombehaviors
Adding it to a target is as simple as dragging it to the objects and timeline panel. From there we’re able to edit the properties using the property editor.

So how do we use it? Well The convention of looking for the Command on the attached control’s data context works very well with the MVVM pattern. So let’s make a simple login control and matching View Model to drive it. Here’s the XAML for the Control

<UserControl
<!-- A bunch of xmlns definitions—> 
> <UserControl.DataContext> <AgVM:LoginViewModel/> </UserControl.DataContext> <Grid x:Name="LayoutRoot" Background="White"> <!-- A bunch of layout definitions--> <Button Margin="0,0,5,0" VerticalAlignment="Bottom" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" Content="Login"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <Ag:ExecuteCommandAction TargetCommand="LoginCommand"/> </i:EventTrigger> </i:Interaction.Triggers> </Button>
<!—More UI code--> </Grid> </UserControl>

There is no custom code-behind for the control. The ViewModel is instantiated in the XAML and all the elements are bound to properties on the ViewModel using data binding. Here is our ViewModel (or the significant parts thereof):

    public class LoginViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        public LoginViewModel()
        {
            PropertyChanged += (blank, blank1) => { };
            LoginCommand = new DelegatingCommand
                               {
                                   CanExecuteRequested = param => true,
                                   ExecuteRequested = param => ShowLogin()
                               };
        }

        private void ShowLogin()
        {
            MessageBox.Show(String.Format("Login by {0} successful", _UserName));
        }

Here I’m using the DelegatingCommand to expose an ICommand as a property on my ViewModel. I’ve also exposed a UserName and Password field. Running the application gives us this.

runningthecode

So now we have trigger driven command execution with zero code behind. I’ll upload the code later.

Posted by Mike Brown | 2 comment(s)

Mozilla Lab Concept Series, Aurora, and Flow

Shortly after I started playing around with Flow and put my ideas on paper (or at least digitally), someone pointed me to Adaptive Path’s Aurora Project. The brainstorm that lead to me writing about Flow preceded the publishing of the first Aurora video. I believe that I had created the first prototype before the video was published as well. It was really inspiring to me because I envisioned in Flow many of the concepts demonstrated in that video. What’s very interesting to me is this quote from their site:

This is not a demonstration of a real product. What you see in the video is a visualization of our ideas created by animators. Technologically, much of Aurora would be difficult or impossible to implement today. However, we expect everything you see to be possible in some form in the future.

Their desktop browser concept is definitely feasible, I think the Flow prototype shows this. It wouldn’t be difficult to replace the graphs with  The concept of synchronization across devices is enabled through Live Fx. WPF has a very rich visualization story and almost any data that can be pulled from a web page (for example a table of precipitation data) can be bound and transformed through different visualizations.

I don’t think that “Flow” would ever serve as a primary browser. Or I should say it’s not one of my goals to make Flow a new web browser but rather an Information Browser. In order to make a good browser, Flow would need the capacity of rendering HTML to WPF natively. Hopefully, Microsoft will one day release a native WPF browser control. Or I will attract the attention of an HTML rendering wizard. Until then, web browsing in Flow will be limited by the capabilities of the BrowserControl.

Posted by Mike Brown | with no comments
Filed under:

Static Reflection: Say What?

There’s a new oxymoron going around call Static Reflection. The basic gist is that by using expression trees you can do things that appear to be dynamic but in reality are checked at compile time. Like for instance, getting the name of a property for firing an INotifyPropertyChanged.PropertyChanged event. My colleague, Jon Fuller, showed me his code for Method Guards and my first comment was that this would be a great tool for implementing INotifyPropertyChanged. He informed me that he already went there and showed me that code as well.

I wasn’t too happy with the idea of wasting your sole base class on NotifyPropertyChanged so I suggested that we use extension methods instead. After a bit of finagling with the framework (Events don’t like to be fired from outside their declaring class), here is the result:

        public static void SetProperty<T>(
		this INotifyPropertyChanged source, 
		Expression<Func<T>> propExpr,
		Expression<Func<T>> fieldExpr,
		T value)
        {
            source.SetProperty(
		propExpr, 
		fieldExpr, 
		value, 
		() => { });
        }

        public static void SetProperty<T>(
		this INotifyPropertyChanged source,
		Expression<Func<T>> propExpr,
		Expression<Func<T>> fieldExpr,
		T value,
		Action doIfChanged)
        {
            var prop = 
		(PropertyInfo)
		((MemberExpression)propExpr.Body).Member;
            var field =
		(FieldInfo)
		((MemberExpression)fieldExpr.Body).Member;
            var currVal = (T)prop.GetValue(source, null);
            if (currVal==null && value==null)
                return;
            if (currVal==null || !currVal.Equals(value))
            {
                field.SetValue(source, value);
                var eventDelegate =
			(MulticastDelegate) 
			source.GetType().GetField(
				"PropertyChanged",
				BindingFlags.Instance | 
				BindingFlags.NonPublic).
				GetValue(source);
                Delegate[] delegates = 
			eventDelegate.GetInvocationList();
                var args = new PropertyChangedEventArgs(prop.Name);
                foreach (Delegate dlg in delegates)
                {
                    dlg.Method.Invoke(
			dlg.Target, 
			new object[] 
			{ 
			  source,
			  args 
			});
                }
                doIfChanged();
            }
        }

Now you can use a strongly typed NotifyPropertyChanged declaration without using your base class

    public class PersonStaticReflection : INotifyPropertyChanged
    {
        private string _firstName;
        private string _lastName;
        public string FirstName
        {
            get { return _firstName; }
            set { this.SetProperty(
			() => FirstName, 
			() => _firstName, 
			value); 
		}
        }
        public string LastName
        {
            get { return _lastName; }
            set
            {
                this.SetProperty(() => LastName,
                                 () => _lastName,
                                 value,
                                 () =>
                                     {
		// do something useful here
                                     });
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }

For those concerned, you can statically cache the PropertyChanged field in a dictionary mapped to the object type so that you only have to reflect on it one time.

Posted by Mike Brown | 2 comment(s)

Get Your Hands on Flow

Quite a while ago, I first started hinting about “Flow”. I’ve given friends and colleagues information about the project, and have been teasing everyone with screenshots and videos. Monday, I started a series that I call “Refactoring to Patterns: WPF Edition” in which I started the task of building Flow from the ground up. A few moments ago I wrote a post discussing the background of Flow and finally made the prototype available for download. There is going to be some crossover between my other blog and this one here. But I’m getting ahead of myself.

I’d love to get your feedback. I will be publishing a Codeplex project where you can submit bugs, join the discussion, and even download the code. Until then, you can leave a message for me at either of my blogs. Happy coding!

Posted by Mike Brown | with no comments

Entity Framework Has Layers Like an Onion

If you’ve been following my tweets, you’ll know that I’ve been experimenting with Entity Framework lately. I’ve been digging around, looking at the generated code for EF and realized something very interesting.

    [EdmEntityType(NamespaceName="DBO", Name="Project")]
    [Attribute(IsReference=true)]
    [Serializable()]
    public partial class Project : EntityObject
    {

You see that? My entity has Attributes on it…very similar to NHibernate attributes. Here’s another interesting tidbit from a property that exposes a relationship between two entities (a so-called Navigation Property)

[EdmRelationshipNavigationProperty(
  "DBO", "FK_tblTasks_tblProjects", "tblTasks")]
public EntityCollection<Task> Tasks{
   get{
     return RelationshipManager.GetRelatedCollection<Task>(
                 "DBO.FK_tblTasks_tblProjects", "tblTasks");
   }
   set{
     if ((value != null)){
       RelationshipManager.InitializeRelatedCollection<Task>(
         "DBO.FK_tblTasks_tblProjects", "tblTasks", value);
   }
}

Notice that the navigation property has an attribute giving the name of the relationship (here the same name as the foreign key) and the related entity name (again given the same name as the foreign table). Behind the scenes it uses a relationship manager (property of EntityObject) to get/set the values.

So What’s Your Point?

The point is that the generated code is nothing more than a strongly typed convenience layer over the EF API. The point is that it is possible to provide your own engine that lays over this API and removes the coupling to EntityObject from your Domain Objects. The core of Entity Framework…the database abstraction layer…is very solid. It’s begging to have a proper O/RM engine placed on top of it.

Posted by Mike Brown | 1 comment(s)

Starting the New Year With a Bang!

Yes I know it’s February already, but this should show even more how big the start of this year has been for me. First and foremost is the big announcement that the new year brought.

MVP_FullColor_ForScreen

First and foremost, I’ve been named an MVP in Client App Development (for my community contributions with WPF). This is an incredible honor for me. In addition to the title, being an MVP provides me an opportunity to have better interaction and feedback with Microsoft especially with regards to my specialization. According to the program guidelines, the award is for my past activities and I am not required to do anything else.

However, I want to leverage this opportunity to the fullest and will continue my community contributions going forward, both with regard to WPF and Silverlight as well as with Windows Azure.

USAltNET

Second, as an organizer for our local Alt.NET User Group, Indy Alt.NET, I’m excited about a few recent developments with the group. Chief among those being named an official INETA group – something that surprised me seeing that there was already an INETA group in the Indianapolis area. We are coming on our first anniversary and have seen our attendance stabilize at around 25 per meeting. With almost a year under our belt we have sat down and started a few initiatives.

One major decision will be to incorporate as a non-profit organization (an idea we had thrown about for a while but were too busy with day to day operations to act upon). This action will allow us to apply for grants and begin some community outreach initiatives that we are all excited about. It will also make us more attractive to potential sponsors as certain donations to us will be tax deductible.

Another initiative has been a marketing and sponsorship drive. We are trying to grow organically, but we have noticed that we have a chicken or egg scenario. Therefore, we are pushing our growth on multiple fronts. So far we are getting good feedback from our efforts.

Our biggest initiative about which we are all very excited is planning for a local conference. More on that later ;)

SEP-logo

But wait there’s more! I just finished my first year with my current employer, Software Engineering Professionals. Management announced a number of initiatives here that are pretty exciting for me. I can’t necessarily talk about them right now, but it reaffirmed my decision to come here. I can honestly say that I have grown dramatically since I’ve been here. It is an amazing place to work, and I’m excited to see what the future has in store.

SEP-logo

Finally, my family is counting the days until our latest addition is expected to arrive.

Like I said, this year is starting off with a bang…and there’s more to come. I’ll keep you posted with new developments.

Posted by Mike Brown | 1 comment(s)
Filed under:

Buzz In the Cloud December 4, 2008

Sorry for the extended absence. I've been working on a crossover article series on refactoring between my WPF half and my Azure half. It's shaping up pretty nicely. But in the meanwhile, I've neglected my buzz duties. So without further ado, here are your buzz-worthy items for today.

Getting Webby With It

Next week (December 8th to be precise), the Live Framework team will be hosting a webcast. I think the topic will be about the future of the MacOS or something like that. I'm pretty stoked about the 1 and 15 minutes scheduled for Q&A on the agenda!

Steve Marx Says

"PDC Attendees Should Have Windows Azure Tokens" (that is if you registered for them). Also if you follow his blog, he has more Azure code samples (including the blog itself) than you can shake a stick at.

The Gift That Keeps on Giving

The PDC ended a month ago and I am still finding great sessions like this one that gives an in depth view of how the B2B sample Azure application shown during the opening keynote was built. It's funny, I went into PDC without a shred of interest in Microsoft's cloud platform (outside of Mesh/Live Framework). And now I'm so enthralled by it, I haven't spent more than 3 hours with VS 2010 (and that's just for the "Oslo" stuff). Anyway, I'm told there are good sessions on WPF 4.0, WF 4.0, TFS 2010, and other new stuff, and I'm going to get to them...eventually.

The Real Reason to Get Excited About Live Mesh

I've seen a lot of chatter about how cool Live Mesh is because you can synchronize your files. What if I told you that the file synchronization is really just a proof-of-concept. The Live Mesh client that you see today, is little more than an example of what the Live Framework enables. Don't believe me? Look at this video by Jamie Thomson where he shows the masses what the lucky few with Live Framework CTP tokens get to play with. BTW, I managed to win a few invite cards from the Live Framework team in an arm wrestling match. Leave a comment on this post for a chance to win one.

Today's Episode Guest Stars David Burela

Long Zheng decided to let someone else take the reins for a day over at his blog. David Burela took the opportunity to post a review of Azure. Don't go looking at the sidebar or anything. There's nothing to see there. Nope, nothing at all about a HP Magic Giveaway including a Touchsmart that is Windows 7 multi-touch capable.

Farewell "Blue Badge" Hack But We Don't Need You Anymore

Well soon we won't that is. Windows 7 Beta 1 (feature complete) will be given to attendees of the MSDN Developer Conferences. Basically, it's the PDC distilled and distributed at a more reasonable price point. I will be attending the Chicago event and promptly installing my Beta 1 copy on site!

Windows 7 Gives You Wings

Over at Redmond Developer News, you can read the new issue's cover story online. It is a review of Windows 7 Build 6801 that pretty much reaffirms my experience with 7.

The Signs Were Always There

Way back on October 1st Computer World posted a teaser article for "Windows Cloud".

You've Got to Love Fanboys

Windows 7 hasn't even released yet and the self proclaimed "Cyber Cynic" has written three different posts proclaiming that Windows 7 sucks and that Microsoft had to resort to bribery to get a good review. Like I said in my review, the only "bribe" I received from Microsoft was a copy of Windows 7 on a WD Passport drive. And my employer paid 2400 for me to get that.

The Live Framework Afternoon Special

In a new white paper by Nishant Gupta and Dharma Shukla, the two answer the question we've all been dying to know "What is it and Why Should I Care?". Next week it will be "Coping with Peer Pressure: Should I Use Live Framework?".

 

Well that's it for today fellow cloud dwellers. There's more news to tell, but not enough time to type it all out.

Getting Started With Azure Development

I have posted an overview of getting started with Windows Azure development, our first article in the Azure Development Series. I will update the series weekly with walkthroughs and tutorials on Azure Development.

Posted by Mike Brown | with no comments

Buzz In the Cloud November 25, 2008

Whoa...today is a doozy for buzzing, so let's get right to it.

I For One Welcome Our New Cloud Overlords

The latest Deep Fried Bytes episode (entitled "Windows Azure: the Overlord in the Cloud") includes an interview with Steve Marx, Program Manager for Windows Azure.

7's a Lucky Number

Oak Leaf Blog rounds out their Azure Storage Services Test Harness with a post on paging the LINQ query result sets and another on testing for table existence...hmm, maybe a management utility is in order to get rid of that pesky requirement. By the way, they also placed the harness up for your viewing pleasure.

If CTP Isn't Cutting Edge Enough

What's that you say? Living on the edge isn't enough for you? You want to jump off the edge with your bedroom sheets as your parachute? Okay, daredevil, I've got the fix for your thrill-seeking craving! Check out the SQL Services Labs where you'll find 7 projects in "incubation" status. Included in these projects are:

Overall, I see the utility of all these projects (outside of "Anchorage" it really has me confused). I think it would be good to have them all graduate from incubation. But if I had to pick one, it would be the ADO.NET data services over SDS.

Saving Lives One Cloud at a Time

Over at the Joy of Code, Josh Twist tells us about his adventures in the clouds while coding a proof of concept for the RNLI (Royal National Lifeboat Institute). Basically, the software receives beacon data from fishing boats (relayed from satellites to the RNLI data center to the Cloud App). Should a fisherman go overboard, an alert signal is raised and the Coast Guard will have tracking data in order to send the proper assets to the right place. That is incredible if I must say so myself.

Two Pages We Have More Content in a Single Post

DevX finally decided that Windows Azure was worth space on their gargantuan site. So they wrote a two page introduction to Windows Azure. Oh wait, the introduction is on the entire Azure Services platform. Honestly, you'd be better served reading David Chappell's white paper. Heck the AzureWiki has more content than that introduction (with more on the way).

Chappell Show

I wonder how many people have hacked the pronunciation of poor David Chappell's name. To be honest, until I saw this interview, I was one of them. Now I know it's CHAPpell (like the Church) not ChapPELL (like the show). And knowing is half the battle.

Googling Azure

Dion Almaer, Googler and founder of Ajaxian, gives us a refreshingly honest view of PDC from a competitor's perspective. Our overlord in the cloud is pleased.

Must Have a Long Digestive Track

Kirk Evans writes a pretty insightful post on the PDC announcements in "The PDC That Took Weeks to Digest" He talks about letting it stew, simmer, and brew, but never eating. Maybe it would digest quicker if he hurry up and cook it.

Yet Another Blog Post About Silverlight and Azure

Although to give the author credit, it does discuss the limitations of Silverlight on the current release of Azure. Hey guys, can we get to working on that whole SSL certificate thing?

Okay that's enough for today's buzz. There's still a lot more that I could throw at you, but I'm getting fatigued. I'll be back tomorrow with more buzz.

The Synchronization Morass

Microsoft loves them some synchronization like a fat kid loves cake.

Yet another synchronization platform from Microsoft has emerged. This one appears to be an evolution of the Synctoy which was a desktop application that seemed oddly similar to Live Mesh. Codename "Anchorage", or as Redmond Pie calls it, "A SyncToy for the Cloud" If you're totally lost at this point, it's with good reason:

Codename "Anchorage" represents our current thinking of where to take SyncToy in the future that not only provides value as a generic sync hub but also - an easy to use application capable of keeping content synchronized across PCs, services, and devices through a rich plug-in mechanism based on the Microsoft Sync Framework.

Come again? Isn't that what Live Mesh does?

With Live Mesh, you can synchronize files with all of your devices, so you always have the latest versions handy. Access your files from any device or from the web, easily share them with others, and get notified whenever someone changes a file.

Here's where it gets really loopy:

With this project, providers will be able to register and be discovered in a variety of sync groups including contacts, files, favorites, videos, as well as synchronization across services such as the Live Mesh, PhotoBucket.com, Smugmug.com, and more. Powered by the Microsoft Sync Framework - this E2E and hub for sync providers has value for both consumers AND developers.

So wait a minute..."Anchorage" is an extensible synchronization platform that integrates with Live Mesh which itself is an extensible synchronization platform. (And from all indicators is ALSO built on top of the Sync Framework). Well at least Live Sync is a purely end user synchronization platform...at least we hope.

Another Use for Live Mesh

So here's the problem, you have about a bajillion sites that make you create your own account. Raise your hand if you use the same 2 or 3 passwords across those sites. If you're good, you might have a more "secure" password for your email account, and another one for online banking (that way if your password to that micro-gaming site is compromised, they won't get your important account).

Well I can say honestly that I don't suffer from that problem. I have a different password for every site I visit regularly. Heck I even have a different password for every site I visit irregularly. Even better, I don't even know these passwords. Okay I lie, I know my Windows Live account password...but I have to know that one. My secret is simple: Password Safe + Live Mesh. Password Safe stores your passwords in a Blowfish Encrypted master file protected by a master key password. Live Mesh allows you to synchronize that master file across machines. The result, other than your Master Key Password and your Live ID password, you can remain blissfully ignorant of your passwords while still keeping them unique and safe.

Posted by Mike Brown | 4 comment(s)
Filed under: ,

Buzz In the Cloud November 21, 2008

Well, my fellow cloud dwellers, there's only one thing standing between me and a weekend of what I like to call heaven on 7. So let's get this party started!

New Bits for Your Meshification Pleasure

The first post on the Live Framework Team's fresh new blog (other than "Hello") is an announcement of fresh bits for the LiveFX CTP. Get your mesh on!

Would You Blog Inside a Box? Would You Blog Next to a Fox?

There are a lot of tips coming out for using Live Mesh to synchronize everything from your homework to your Tweetdeck settings. I was going to write a tip for people who want to synchronize their Live Writer posts/drafts. But Sarah Perez beat me to it. Actually I sync my entire Documents folder like Sarah does. So I got Live Writer posts for free.

More On Table Services Programming

Oak Leaf continues their series on creating a test harness for the Azure Table Services API. I think LIMOG would be useful even if you weren't using table services

Azure Storage Services Test Harness: Table Services 5 – Generating Classes/Collection Initializers with LIMOG v2

Azure Storage Services Test Harness- Table Services 4 – Programming the Table Services API

Azure Storage Services Test Harness- Table Services 3 –Starting the Test Harness Project

The series is definitely turning into a good read for getting a grasp on programming for Table Services.

Is It Sync Or Is It Mesh?

There is a lot of confusion regarding foldershare's transition to Live Sync. I got it straight from the source. Says Angus Logan "Live Sync and Live Mesh clients are different for now." I'm not sure how much we should read into the for now. But they're two separate apps...for now.

 

Live Sync?

Using an Existing SQL Instance With Azure SDK

David Justice provided this tip on his blog. But if you already have access to a SQL Server Installation, you're not limited to using SQL Express. You don't even have to use a local SQL installation.  Just open developmentstorage.exe.config in your Azure SDK Bin directory and change the two lines that refer to sqlexpress to point to the instance you want.

Also there is a command line parameter for devtablegen that you have to pass in order to get it to generate the tables on an instance other than the default SQLExpress. Passing /server:<myserver[\myinstancename]> to devtablegen will cause it to generate your table storage on a SQL instance with the same name. In fact, if you're going to be using the Samples with a predetermined SQL Instance, you might as well change it so that rundevstore.cmd will generate the tables for you. I did the digging so you don't have to. First we want to change the Microsoft.Samples.ServiceHosting.Targets file. This file is ultimately responsible for calling devtablegen.

  1. Insert a line after the opening for the property group at the top of the file (line 3)
  2. Paste these lines into the file
  3. <!-- Allow user to pass the server parameter to devtablegen -->
    <DevStoreParam Condition="'$(InstanceName)'!=''">/server:$(InstanceName)</DevStoreParam>
    <DevStoreParam Condition="'$(InstanceName)'==''"></DevStoreParam>

  4. Replace the UpdateSamplesTableDB (do a search but should be near line 130) with the following
  5. <Target Name="UpdateSamplesTableDB" DependsOnTargets="BuildSubProjects">
        <Message Text="$(DevTableGenCommand) $(DevStoreParam) /database:$(SamplesDBName) $(DevtableGenForceCreateFlag) @(DevTableGenAssemblies)"/>
        <Exec Condition="'$(SamplesDBName)'!=''"
                Command="$(DevTableGenCommand) $(DevStoreParam)  /database:$(SamplesDBName) $(DevtableGenForceCreateFlag) @(DevTableGenAssemblies)"
        WorkingDirectory="$(MSBuildProjectDirectory)"/>
      </Target>

What we did here was allow a parameter called InstanceName to be passed into MSBuild that will be passed to devtablegen. All we have to do now is update rundevstore.cmd to pass in the parameter. Replace line 21 in rundevstore.cmd with the following:

%msbuild% MSBuild\BuildAll.proj   /t:RunDevStoreOnSamplesTableDB /p:SamplesDBName=ServiceHostingSDKSamples;ForceTableCreate=true;InstanceName=.

Replace . at the end with your instance name (unless it's the default instance on local, in that case . is the shortcut for that). Open your Windows Azure SDK Prompt, navigate to your samples directory, execute rundevstore and voila, you've broken the chains to SQL Express.

What's that you say, too lazy to do all that file opening, cutting and pasting? Have no fear! Here are the sample files for your convenience.

Microsoft.Samples.ServiceHosting.targets

rundevstore.cmd

No Buzz Tonight

Between speaking about Azure at a local user group and working on a useful Azure sample, I haven't had time to collect the interesting news for today. Again, if you have something that you feel will be pertinent to the site, send a message to me. Also, in case anyone is wondering, I do read and/or watch everything before I write about it here. Hopefully, I'll have a note about what I'm writing tonight in tomorrow's buzz. If you really must have something to read tonight, check out Angus Logan's blog. He has a TON of posts about the Live Framework.

Posted by Mike Brown | with no comments
More Posts Next page »