June 2010 Entries
AppFabric Workflow Persistence Not Fully Functional Because Net.Pipe Protocol is Missing

When setting up my AppFabric environment yesterday, I was running into (what I thought) was a strange error:

Workflow persistence is not fully functional because the net.pipe protocol is missing from the application’s list of enabled protocols.



At first, I was quite confused by this. I had double-checked to make sure that net.pipe *was* enabled.  First I checked the Site Bindings for the web site itself:


Next, I check the Enabled protocols by going to “Advanced Settings” at the application level. Sure enough, I had previously added “net.pipe” in the comma separated list:



After a few minutes of beating my head against the wall, it occurred to me that IIS might be picky with *how* the Enabled Protocols is formatted.  Sure enough, the problem is that I did not realize I had a {space} after the comma.  I had “http, net.pipe” when I should have had “http,net.pipe”. Once I removed the space, everything was resolved:

Posted On Wednesday, June 23, 2010 10:33 AM | Comments (4)
A Closer Look at the HiddenInput Attribute in MVC 2

MVC 2 includes an attribute for model metadata called the HiddenInput attribute. The typical usage of the attribute looks like this (line #3 below):

   1:  public class PersonViewModel
   2:  {
   3:      [HiddenInput(DisplayValue = false)]
   4:      public int? Id { get; set; }
   5:      public string FirstName { get; set; }
   6:      public string LastName { get; set; }
   7:  }

So if you displayed your PersonViewModel with Html.EditorForModel() or Html.EditorFor(m => m.Id), the framework would detect the [HiddenInput] attribute metadata and produce HTML like this:

   1:  <input id="Id" name="Id" type="hidden" value="21" />

This is pretty straight forward and allows an elegant way to keep the technical key for your model (e.g., a Primary Key from the database) in the HTML so that everything will be wired up correctly when the form is posted to the server and of course not displaying this value visually to the end user. However, when I was giving a recent presentation, a member of the audience asked me (quite reasonably), “When would you ever set DisplayValue equal to true when using a HiddenInput?” To which I responded, “Well, it’s an edge case. There are sometimes when…er…um…people might want to…um…display this value to the user.” It was quickly apparent to me (and I’m sure everyone else in the room) what a terrible answer this was. I realized I needed to have a much better answer here.

First off, let’s look at what is produced if we change our view model to use “true” (which is equivalent to use specifying [HiddenInput] since “true” is the default) on line #3:

   1:  public class PersonViewModel
   2:  {
   3:      [HiddenInput(DisplayValue = true)]
   4:      public int? Id { get; set; }
   5:      public string FirstName { get; set; }
   6:      public string LastName { get; set; }
   7:  }

Will produce the following HTML if rendered from Htm.EditorForModel() in your view:

   1:  <div class="editor-label">
   2:      <label for="Id">Id</label>
   3:  </div>
   4:  <div class="editor-field">
   5:      21<input id="Id" name="Id" type="hidden" value="21" /> 
   6:      <span class="field-validation-valid" id="Id_validationMessage"></span>
   7:  </div>

The key is line #5. We get the text of “21” (which happened to be my DB Id in this instance) and also a hidden input element (again with “21”).

So the question is, why would one want to use this? The best answer I’ve found is contained in this MVC 2 whitepaper:

When a view lets users edit the ID of an object and it is necessary to display the value as well as to provide a hidden input element that contains the old ID so that it can be passed back to the controller.

Well, that actually makes sense. Yes, it seems like something that would happen *rarely* but, for those instances, it would enable them easily. It’s effectively equivalent to doing this in your view:

   1:  <%: Html.LabelFor(m => m.Id) %>
   2:  <%: Model.Id %>
   3:  <%: Html.HiddenFor(m => m.Id) %>

But it’s allowing you to specify it in metadata on your view model (and thereby take advantage of templated helpers like Html.EditorForModel() and Html.EditorFor()) rather than having to explicitly specifying everything in your view.

Posted On Monday, June 14, 2010 2:09 PM | Comments (6)
MVC 2 Presentation – Final Demo

In my presentation this past weekend at NoVa Code Camp, a member of the audience caught my final demo on video. In this demo, I combine multiple new features from MVC 2 to show how to build apps quickly with MVC 2. These features include:

  • Template Helpers / Editor Templates
  • Server-side/Client-side Validation
  • Model Metadata for View Model
  • HTML Encoding Syntax
  • Dependency Injection
  • Abstract Controllers
  • Custom T4 Templates
  • Custom MVC Visual Studio 2010 Code Snippets

The projector screen is a little difficult to see during parts of the video – a video of the direct screencast can be seen here: MVC 2 in 2 Minutes.


Direct link to YouTube video here.

Posted On Sunday, June 13, 2010 8:23 PM | Comments (2)
NOVA Code Camp – Code Samples

Thanks to everyone who attended my MVC 2 presentation at NOVA Code Camp. The code samples and PowerPoint can be downloaded here: Top 10 Ways MVC 2 Will Boost Your Productivity.

Posted On Sunday, June 13, 2010 9:11 AM | Comments (0)
Visual Studio 2010 Pro Power Tools Screencast

Microsoft just released the Visual Studio 2010 Pro Power Tools extension and it is awesome. A summary of all the features can be found here and it is available in the Visual Studio Gallery here. There are a bunch of great features but, in my opinion, the best one is the replacement for the Add Reference dialog. This gives sub-string search capabilities as well as the ability to add multiple references without having to continually re-open the dialog. For this feature alone, you should install the Pro Power Tools right now. There are a few blogs posts that do a good job describing all the features but what I wanted to do here was to post a quick screencast (7 minutes) that shows the features that I think are really cool. I show most (but not all) of the features focusing on the ones I think are the best. The features I cover are:

  • Installation with the Extension Manager
  • Add Reference Dialog replacement
  • Tab Well including pinned tabs, pinned tabs in second row, fixed close button, colorized tabs, dirty indicator
  • Highlight current line
  • Triple Click for full-line selection
  • Ctrl + Click for Go To Definition
  • Colorized Parameter Help


(Right-click and Zoom to view in full screen)

Posted On Thursday, June 10, 2010 12:18 AM | Comments (6)
ILMerge - Unresolved assembly reference not allowed: System.Core

ILMerge is a utility which allows you the merge multiple .NET assemblies into a single binary assembly more for convenient distribution. Recently we ran into problems when attempting to use ILMerge on a .NET 4 project. We received the error message:

An exception occurred during merging:
Unresolved assembly reference not allowed: System.Core.
    at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly)
    at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type)
    at System.Compiler.Ir2md.VisitReferencedType(TypeNode type)
    at System.Compiler.Ir2md.GetMemberRefIndex(Member m)
    at System.Compiler.Ir2md.PopulateCustomAttributeTable()
    at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
    at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
    at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
    at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
    at ILMerging.ILMerge.Merge()
    at ILMerging.ILMerge.Main(String[] args)

It turns out that this issue is caused by ILMerge.exe not being able to find the .NET 4 framework by default. The answer was ultimately found here. You either have to use the /lib option to point to your .NET 4 framework directory (e.g., “C:\Windows\Microsoft.NET\Framework\v4.0.30319” or “C:\Windows\Microsoft.NET\Framework64\v4.0.30319”) or just use an ILMerge.exe.config file that looks like this:

   1:  <configuration>
   2:      <startup useLegacyV2RuntimeActivationPolicy="true">
   3:          <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
   4:      </startup>
   5:  </configuration>

This was able to successfully resolve my issue.

Posted On Wednesday, June 2, 2010 6:51 AM | Comments (13)

View Steve Michelotti's profile on LinkedIn

profile for Steve Michelotti at Stack Overflow, Q&A for professional and enthusiast programmers

Google My Blog

Tag Cloud