With all the out-of-band technology releases we've had (ASP.NET AJAX, .NET 3.0), it's nice to reach a point where we can bring them all together.
As an example...
Create a new web site in Visual Studio 2008. This will have to be a website under IIS, unfortunately, for reasons I'll point out later. Once the web site is up, add a new item – a WCF service. The service contract can look like the following:
The data contract can look like so:
Finally, the LINQish implementation:
We can entirely remove any WCF <system.serviceModel> configuration from web.config. Instead of all the XML configuration goo, we just need a Factory attribute in our .svc file:
What magic does this factory give us? Well, we can add a ServiceReference via a ScriptManager (it's nice that AJAX extensions are in the toolbox by default), and write some script:
Voila! Zero configuration and we have JSON on the wire!
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.0
X-Powered-By: ASP.NET
Date: Tue, 31 Jul 2007 03:08:10 GMT
Content-Length: 662
{"d":[{"__type":"ProcessInfo:#","Name":"devenv","WorkingSet":51011584},
{"__type":"ProcessInfo:#","Name":"w3wp","WorkingSet":44748800},
{"__type":"ProcessInfo:#","Name":"Fiddler","WorkingSet":34213888},
...
}
Note: there is a problem in Beta 2 that prevents this magic from working with WebDev.exe. The error you'll see with WebDev (aka Cassini) is:
"IIS specified authentication schemes 'Ntlm, Anonymous', but the binding only supports specification of exactly one authentication scheme. Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. Change the IIS settings so that only a single authentication scheme is used."
Unfortunately, twiddling with the NTLM checkbox for WebDev doesn't help. Thus, the current need for IIS.
Sahil's post on "Things
I can't live without" got me thinking about some software I use that might
not be so well known.
XaMp Studio plays XM Radio from a desktop application. Looks like Winamp and offers more features than the XM web interface. There is a toast notification to tell you when your favorite artist or tune is streaming. Note: don't download the "desktop" edition, as it seems incompatible with Vista and Windows Media Player 11.
DynDNS Updater coupled with the DynDNS service can give any computer a name – even if your ISP hands out dynamic IP addresses. The Updater can run as a Windows service to keep addresses in synch.
FoxIt Reader is a small, fast PDF reader. Scott Hanselman first mentioned Foxit a couple years ago, and the feature list has grown since that time. The only downside is that Foxit does not seem to decrypt password protected PDF files, so no e-book reading with Foxit.
Robocopy now comes standard in Windows Vista. It's the tool I use for large file operations, particularly when moving bits over the network. Robocopy easily beats copying files using Windows Explorer, after all, the "robo" is short for robust.
There is only one weakness with robocopy. Try copying an Outlook PST file when Outlook is running:
Which brings me to my "last but not least" entry: Hobocopy.
Hobocopy is Craig Andera's tool that uses the Volume Shadow Service to copy locked files. Pure goodness.
Ayende had a recent post with the following quote from Nicholas Piasecki:
To me, this discussion all boils down to one thing: the foreach loop. Let's say you want to display a table of sales reports, but after every tenth row, you want to print out an extra row that displays a running total of sales to that point. And you want negative numbers to appear in red, positive numbers to appear in green, and zeros to appear in black. In MonoRail, this is easy; with WebForm's declarative syntax, just shoot yourself in the face right now. Most solutions I've seen end up doing lots of manipulation in the code-behind and then slamming it into a Literal or something, which to me defeats the purpose of the code separation.
Ayende says this is the essence of why he dislikes WebForms. In the comments, someone proposed a rails solution ...
... which received praise for elegance. I'm thinking if you really want to intermingle code and markup, than open up an .aspx page and have at it:
Why throw out the baby with the bathwater?
RockNUG is the newest .NET user group in the vast suburbia of Washington D.C. Their next meeting is on August 8 at Montgomery College, and I'll be there to talk about ASP.NET AJAX. I have one WF book and one Pluralsight T-shirt to give away, too.
Come for the free pizza, and stay for the asynchronous fun!
Unit testing features will now be available in the Professional version of Visual Studio 2008.
Unit testing has been to Visual Studio what Barry Bonds has been baseball – a center of controversy. First there was the Peter Provost petition to include unit testing features in all version of VS. Then there was the highly criticized TDD guidance accompanying the feature. Next came some performance issues and pain while using the shipping version, and most recently, the TestDriven.NET hullaballoo added an emotional charge to the air.
Putting all this behind us - what's new in 2008? I've been working with the latest bits, and I can say:
Moving the unit-testing features into the Pro edition is a great move by Microsoft. I hope the feature gains traction and brings awareness of unit testing into the mainstream (although I think we are already close, aren't we?).
Related Links
Guidelines for Test-Driven Development by Jeff Palermo
Rules to Better Unit Tests by Adam Cogan.
I wrote my first class with automatic properties in Orcas today...
... then I found myself staring at the screen.
It's an interface!
No,it's a class!
Wait, it is a class!
I'd say the syntax is still growing on me.
I'm sure some people will say – why use properties at all? If you don't need special code in the get and set methods – why not just use a public field?
The quick answer is: reflection. There are many forms of magic that will only occur if you expose state using public properties.
Come join Fritz Onion and myself at a Pluralsight double feature in southern California. Starting October on 22nd, we'll cover everything from JSON spitting web services to the Sharepointy magic of ASP.NET 2.0 web parts.
It's more than a class … it's an experience (and fun, too)!