Blog

  • Microsoft PDC09 Keynote Address

    Microsoft announced the new bits at PDC keynote today. The theme? Cloud, cloud, and more cloud. The Azure platform goes into production on Jan 1. In beta through the next several months are new cloud platform tools: AppFabric (previously code named "Dublin") and Endpoint. From what I understand AppFabric provides a unified hosting environment for WCF and Workflow, SQL Azure database caching, and can be configured right in IIS. Endpoint seems to be a discovery service for web services all over the world. You can search it and get all the information you need to consume that data in your application. It probably uses the REST protocol. Microsoft showed a pretty cool demo with the NASA web service that involved showing 3D landscapes of pictures taken by the Mars Rover. You could do a serious mashup in a .NET app with Endpoint. Continue reading...

  • IIS 7 Non-HTTP Protocol Support

    More fun with WCF. Out of the box IIS 7 supports the HTTP protocol only. To configure named pipes, TCP, or MSMQ you must use the IIS configuration tool appcmd.exe located in %windir%\system32\inetsrv. (The command-line tool updates the %windir%\system32\inetsrv\config\applicationHost.config file.) For example, if tcp runs over port 808 and my web server's windir is c:\windows then the command to enable tcp is: Continue reading...

  • Visual Studio 2008: Unable to create the Web site

    After a brief foray into Windows 7 Beta just to check it out I took my laptop back to Vista 64-bit, wiping everything out in the process to get a clean slate. Many moons ago, when first installing Vista, it took me about 3 minutes before I disabled the UAC. This time I'm trying hard not to disable it. (You know, best practices about not developing as a sysadmin and all of that.) Now I'm running into security issues that I'm forced to address rather than bypass. In the end this is a good thing. Here's the latest: In VS2008 I right-clicked on the solution and chose Add > New Web Site. Then I picked the WCF Service template and changed the location to HTTP. This tells VS to create a new virtual application beneath the Default Web Site (in my case c:\inetpub\wwwroot) but I got the error: "Unable to creat the Web site 'http://localhost/Foo' because I was not running Visual Studio in an administrator context. The solution is to run VS as an administrator (you can create a shortcut of devenv.exe and under the Advanced tab toggle "Run as administrator") in order to add the web site. Then save and close and go back in under your logged in credentials. Continue reading...

  • Windows Vista Port 8000

    Port 8000 is not open in Windows Vista except when running as a system administrator. And so with User Account Control (UAC) enabled, you cannot navigate to http://localhost:8000 or run self-hosted WCF Services without opening the port. To open for your user account, open a command prompt (running as Administrator) and invoke the netsh utility: Continue reading...

  • Cursorless Iteration in SQL

    Knowing when to use cursors and when to avoid them is key to being a successful developer. Here's a very useful snippet to use when you want to use a cursorless iteration over a resultset. In the example I create a temp table of widgets and then enumerate each row to print them out: Continue reading...

  • STORM! ORM Mapper Beta Launch

    I'm happy to announce that SquareWidget in partnership with the good folks at FlishHorse have launched the Strongly-Typed Object Relational Mapper (STORM) Beta. Download it now and take it for a spin. What is STORM? It's an add-in into Visual Studio 2005. What does it do? It's an OR mapper. It's a code generator. And there are no third-party black box assemblies or other wackiness. We've used Subsonic, NHibernate, and many other ORM tools and we came to the conclusion that it's no fun writing and maintaining a bunch of XML scripts. And we also didn't like creating custom templates like in CodeSmith. We're lazy. So we made a tool that's trivial to use. Continue reading...

  • IComparer and Sorting Widgets

    Back in the turn of the last century, the golden days of .NET 1.1, if you wanted to implement a type-safe custom collection your best bet was to derive from CollectionBase in the System.Collections namespace. CollectionBase was more than just an abstract base class. It was also a wrapper around an internal ArrayList. If you wanted to sort strongly-typed objects in the collection you would implement an IComparer class: Continue reading...

  • Fetching Connection Strings

    Let's assume you wish to store your database connection string in the <connectionStrings> configuration section of Web.config. This is the best practice in my opinion because you can (and should) encrypt the section in production. Now you have two basic options: Continue reading...

  • Enumerate Application Settings

    Here's my own solution to a problem that seems to plague a lot of .NET developers out there. The problem is how best to enumerate application settings stored in a section of an ASP.NET 2.0 app.config file at runtime. Let's suppose you have a settings file called Color.settings with the following key-value pairs: Continue reading...

  • Custom SiteMapProvider

    Usually custom SiteMap providers are written because we're pulling our nodes from a source other than xml. Jeff Prosise's provider written for SQL Server is a classic example. But I had a case recently in which the out of the box XmlSiteMapProvider was just fine; my problem was that I needed to do some peculiar security trimming on the nodes. No problem, just add roles to the nodes and enable security trimming in Web.config for the provider right? Not exactly. The requirements were that the system had to ship with the ability to turn a major piece of functionality on or off in production. Let's call the functionality "ViewWidgets" and let's say there's an app setting in Web.config called "ViewWidgets" with value="false". That means, the web site should suppress the Widgets unless and until it is flipped to true. Then Widgets should be available to the end user. One way of implementing this would have been to set a generic role or override Web.config in a subfolder. But I wanted the webmaster to be able to flip the flag to true or false in Web.config where he was more comfortable working. The solution turns out to be pretty easy. Just derive a custom provider from XmlSiteMapProvider and override the Initialize method to trim the node based on the app setting: Continue reading...

  • Generics and Nullable Types

    It is often useful in OR mapping to analyze a value type that might be null prior to setting it in a business entity. For instance, SqlDateTime type (in System.Data.SqlTypes namespace) is a value type that is nullable. You can call IsNull to check and Value to retrieve the underlying DateTime type: Continue reading...