Using the Application Block Software Factory with VS 2008/Entlib 4.1

Topics: Building and extending application blocks, General discussion
Apr 16, 2009 at 8:56 AM

I was wondering if anyone in the community could help.  I have not been able to find any references, documentation or blogs on how to use the ABSF with the latest bits of VS (2008), ENTLIB (4.1), GAX (1.4), Vista.  This has been quite frustrating.  In fact, it took me a long time to even find the source code for the ABSF in the Entlib contrib.


I have no desire to dismantle my machine with all the latest software and factories in order to install EntLib 3.1.  I built my own application block and provider mechanism a couple of years ago from scratch and it works well, however, I would like to replace the architecture and automate the system by using the ABSF so that I can more easily create providers, or have other developers create providers.  As it stands, it is a complex task to do this by hand and would be nearly impossible to document the process to hand this off to other developers.


Am I just out of luck to use the ABSF with the latest technologies, or has anyone here successfully done this?  Your help and guidance is greatly appreciated.


Apr 22, 2009 at 9:56 AM
Hi rayidukes, we're finding a way how to do this.  In the meantime, if you could find a way how to update the source code to use the current gat/gax versions, I think that would solve the problem.  We'll get back to you once we've managed to do this.

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
Nov 30, 2010 at 12:46 AM


It's been some time since this was raised? Any updates on this?

Nov 30, 2010 at 8:17 AM

Have you tried rebuilding the ABSF source code using the gat/gax version for VS 2008?


Dec 1, 2010 at 6:30 PM

I have rebuilt the ABSF source code against the GAT/GAX version 1.4 binaries

However, my goal is to have the ABSF at runtime generate solutions and projects that reference the Enterprise Library 4.1 binaries.

I have taken a stab at this, fumbling around the ABSF code and seem to be making progress. I'll post a summary of what I've done in a bit.

Dec 10, 2010 at 3:18 AM

I've been able to modify the application block software factory source code so that it emits code that works with enterprise library 4.1.

Now in the Lib folder, there are only enterprise library 4.1 dlls when you create a new application block.

References to these DLLs are now added with the appropriate names to the projects in the generated solution.

Imports and Using namespaces referencing  Microsoft.Practices.Objectbuilder now refer to Microsoft.Practices.Objectbuilder2. I even modified the BlockFactory/Documentation/ABSFOverview.htm file to show in the Guidance Navigator Toolwindow that it's now based on entlib 4.1.

How? search and replace. I am not an expert in GAT/GAX. Not sure I even have a good picture, but I guessed it was just code being generated based on some templates - in this case, the T4 template files. Saw this on a scott hanselman post a while back. and in shanselmann's blog).

I hope someone can help make more sense of it. The changes I made were only in the BlockFactory project

First point of call was Recipes/Common/CommonAddReferences.xml. I changed line 5 to <ValueProvider Type="RegistrySearch" Key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Enterprise Library v4.1" Name="Bin" />.

I wanted the Unity DLL included in the solution so I added these lines to Recipes/Common/CommonSolution.xml

    <Action        Name="CopyUnityAssembly" Type="CopyFile"
                     ErrorMessage="The source file {0} can't be copied to the destination file {1}">
            <Input  Name="SourcePath" RecipeArgument="EnterpriseLibraryBinariesDirectory" />
            <Input  Name="DestinationPath" ActionOutput="CreateLibDirectory.NewDirectory" />

Observe the Actions/EnterpriseLibrary/AddReferences.cs. Apparently, the entire folder contains configurable actions (they derive from the aptly named ConfigurableAction class. I figured the Recipes which are a whole bunch of xml files just call the actions. It's in the Recipes that actual arguments are passed to the actions at runtime to copy files, add references, run a T4 template etc.

Next, updated the recipe files wherever there was a

<Argument Name="EnterpriseLibraryReferences">
            <ValueProvider Type="Evaluator" Expression="Microsoft.Practices.EnterpriseLibrary.Common.dll,Microsoft.Practices.ObjectBuilder.dll,Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll" />

The ObjectBuilder.dll in the Expression attribute was changed to Objectbuilder2.dll.

In the Templates/Solutions/Projects folder, there are project files containing references to ObjectBuilder.dll changed to ObjectBuilder2.dll

In Templates/T4 folder, there are T4 files containing code templates that point to the Objectbuilder.dll - changed them to, you guessed right - objectbuilder2.dll.

In summary,

  • Get most recent Entlib Contrib Codeset - ABSF is part of that and it should build in VS2008 /GAX 1.4
  • Change source of enterprise library files in Recipes/Common/CommonAddReferences.xml
  • Modify Recipes/Common/CommonSolution.xml to cause ABSF to copy unity dll to the lib folder if desired.
  • Update all Recipe files, T4 files and Project templates to reference Objectbuilder2.dll

Hope it makes sense.