April 2007 - Posts
Running with Set-ExecutionPolicy as AllSigned or Restricted with a roaming profile? Here's a cmdlet pair that will sign all the scripts in your profile directory. Makes life easier on me as I include a number of scripts into my main profile for readability:
function sign-profile()
{
dir $Profiledir\*.ps1 | foreach-object { sign-script $_.FullName }
}
function sign-script( $scriptsource )
{
get-item $scriptsource
Set-AuthenticodeSignature $scriptsource @(Get-ChildItem cert:\CurrentUser\My -codesigning)[0]
}
And if you aren't already using Powershell, stop wasting your time with the Command Prompt and go get it. Don't forget the Powershell Community Extensions
The last few weeks I've felt like a little intern again. With the WPF Bootcamp and the early stages WCF integration into the Speedy Rewards messaging infrastructure (I'll be posting on this soon), I've had lots of time to play with .Net 3.0 stuff.
For those that have had a chance to fiddle, there are two feasible options at this point: 1) VS.Net Extensions for WCF & WPF and 2) Orcas CTP's. The Extensions, in my opinion, were a valiant stop-gap effort to get people started. This is especially true for WCF, because there isn't a whole lot of design time experience necessary for web services with the exception of those monstrous config sections. The WPF extensions were OK, but it was basically like having XAMLPad embedded in VS. Orcas CTPS, on the other hand, have been virtually useless. The WPF designer crashed regularly and was slower than waiting for me do math in my head. This may be due to the Virtual PC requirements, since they hadn't yet worked out the issue of Visual Studio 2005 and Orcas living happily side-by-side.
Anyway's, as of today, there is a better #2. Orcas has hit Beta 2. Go get it. There are Express SKU's too, so don't worry if you aren't an MSDN Subscriber, you can join the party too.
Happy coding - go make something cool.
In the Speedy Rewards team here we use custom PerformanceCounters quite extensively to monitor and trend our host systems. You may not know, but our rewards program implements real-time host integration for transactions that are Id'ed as a SpeedyRewards member such that systems like the in-store kiosk, www.SpeedyRewards.com, and any other store you may soon visit can accurately reflect balance updates immediately. With 1600+ stores doing this and a sub-1 second response time, we need to keep a close eye on things.
Today I was trying to do some preliminary performance profiling on our new WCF based messaging infrastructure. To make my life a little easier, I put together a PerformanceHelper class that I actually modeling off the Tracer class found in the Enterprise Library 1.1. To use it, you wrap a section of code you wish to monitor performance for with the following:
using(new PerformanceHelper(CATEGORY, "<BlockInstanceName>") )
{
//...
}
This will provide you with a RateOfCountsPerSecond32 counter and an AverageTimer32 counter called "Operations/sec\<BlockInstanceName>" and "Average Time/Operation\<BlockInstanceName>" respectively. You can download the PerformanceHelper class here and a sample project here.
Feel free to use and abuse it, but be aware that this has not fully tested and may well contain bugs. I provide NO warranty or guarantees, so don't come to me when your server blue-screens from a corrupt registry (not that I've ever done that). Use at your own peril.
A co-worker of mine recently went on vacation for a week. Here's what he returned to:
We went with a "Little Tikes" theme.

Rickie is quite the artist.
We wanted Rick to feel special, so we gave him his very own POS!
Meetings are going to be so much more productive now!
This one should be in the Louvre! 
I'm pretty sure I have run across this in the past, but apparently I've avoided complex XSL transforms successfully for long enough that my mind was purged of how namespaces impact your transforms. Today I was working on our .Net 2.0 build process and was attempting to apply a transform to the *.xxproj file that Visual Studio generates, but I was getting anything but what I would have expected.
My goal was simply to copy everything into a new msbuild file, but swap out the <ProjectReference /> elements with <Reference /> elements that pointed to a static version. Our reasoning's are a topic for another day, but suffice it to say we are control freaks and MSBuild's apparent omniscience is not something we wish to rely on.
Most people tend to avoid namespace in their custom structures, because they are time consuming to get correct and, in many cases, people don't understand XSD well enough (understandable). We use them in many cases, but we rarely apply XSLT's to these documents so the issue doesn't commonly present itself. Visual Studio on the other hand, does specify the MSBuild namespace declaration at the <Project /> root. This means I have to account for it in my XSLT. Take the following snippet:
<Books xmlns="http://schemas.cromwellhaus.com/samples/books">
<Book title="Applications = Code + Markup" author="Charles Petzold" />
<Book title="SQL Server 2000 DTS" author="Mark Chaffin" />
</Books>
In this case, one would have to specify the <Books /> default namespace in their XSLT in order to reference the elements in their transform. The corresponding XSLT:
<xsl:template match="bks:Books" >
<xsl:apply-templates select="./Book" >
</xsl:template>
</xsl:stylesheet>
One of the cool tools we had a chance to use while up at the WPF Bootcamp in Redmond was Expression Blend. While there I became pretty engrossed in the ease with which you could create fairly cool animations without an intimate knowledge of Xaml. This made it all that harder to leave seeing as we had the latest bits at the time (the Release Candidate is available as a 30 trial). Fortunately, or gratefully?, Microsoft has decided to make it available on MSDN. That means me!
I will say though, while reading Charles Petzold's book
Application = Code + Markup which starts with Code and then moves to Xaml, I believe developers and designers alike will be fooled into trying to generate a number of more complex animations with paths, triggers/timelines, etc. rather than implement new animations via code. Karsten Januszewski, who we were lucky enough to meet last week, pointed this exact scenario out while I was attempting to mimic the North Face kiosk carousel via a path. He referenced a previous post of his which shows how to create a custom animation. Until I grasp the animation framework in WPF, I'll not risk embarrassing myself by attempting to better explain what Karsten already does much better than I.
[Update: These are being posted due to the ftp access restrictions at the Microsoft Campus]
Today has been pretty intense which has kept me away from blogging "live". Today started with Kevin Moore, Program Manager for WPF/Blend(?), and a lightning round with Expression Blend. As I mentioned yesterday, I'm not a designer, so Kevin had my mind spinning before breakfast had even settled.
For those dev-signers (developers who design out of necessity) Blend is initially a very overwhelming experience. Don't expect to create the North Face demo your first time out. That said, I was able grasp the benefit of a few concepts including DataTemplates and Styles. This stuff is like OO for UI. Pretty cool.
As soon as Kevin had lost me (quickly), I decided to start playing with Blend Styles and Templates. At the same time, I decided I'd design my own button. It turns out my reasoning for wanting to do this, super-rounded ends, were already possible in the standard button, but it was a good learning experience.
Styles
Styles are pretty straight forward and many references to CSS have been made. Styles seem to be a way to share design properties between elements, especially similar elements. It seems pretty intuitive, but every time you change the visual appearance of a control, even via Visual Studio or XamlPad, you are styling your control/element. It becomes really powerful as you share these styles across your project by including these styles in your App Resources section. From within Blend this is pretty easy after you've gone through and stylized one of your controls by selecting that element and going to the Object -> Edit Style -> Edit Copy.
You can then Right Click your other elements, go to Edit Control Parts (Template) -> Apply Resource and Select the Style you just created. You now have a sharable style across your WPF application. I'm still curious about the ability of sharing these styles across multiple projects and applications if you have a suite of tools. Are these considered Assets for Expression Media? That would be cool.
Templates
The way I feel Templating is best described in relationship to Styling is to say that Styling helps describe the visual appearance of one or more elements, while templating describes the Element tree that makes up a visual entity. For instance, my button above used a template to combine two Ellipses and a Rectangle. But an ellipse on each end of the Rectangle and you've got a rounded edge button.
To get started with templating, I right click on the standard button and drilled down to Edit Control Parts (Template) -> Create Empty. If you've done cool stuff with your element already, you can Edit Copy and apply that to other elements rather than start over. I'll go over a demo to create a pretty cool button that uses lots of composite elements to have rollover effects (glow), transition effects, etc.
