How do I replace refs to ObjectBuilder in my VS 2010/EntLib5 project?

Topics: Building and extending application blocks, General discussion
Feb 17, 2012 at 7:54 PM
Edited Feb 17, 2012 at 8:46 PM

I am converting a Visual Studio 2008/SCSF 2008/EntLib4.1 soluction to Visual Studio 2010/SCSF 2010/EntLib5.0.

I understand that "ObjectBuilder2 is no longer a separate assembly. The code is now completely contained in the Unity assembly and there is no need to reference ObjectBuilder2.dll in your projects" in EntLib5.0.

I have a reference to "ObjectBuilder" in some of my projects and I believe that I should get rid of this reference, but I am unable to compile my project after I have removed the reference to "ObjectBuilder". I was thinking that adding a reference to Microsoft.Practices.Unity.dll in my project would fix the issue, but it does not. I have also added a reference to Microsoft.Practices.ServiceLocation.dll, but this has not resolved my issue.

I cannot seem to find any clear direction on how to properly remove a reference to "ObjectBuilder" in a project.

The[CreateNew] attribute is causing an error in the example below. I have commented out .ObjectBuilder, removed the .ObjectBuilder reference from this project, and have added references (and the using statements) to Microsoft.Practices.Unity.dll and Microsoft.Practices.ServiceLocation.dll.

using System;
using Microsoft.Practices.CompositeUI.SmartParts;
//using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Unity;
using Boeing.CMES.Infrastructure.Interface;

namespace Boeing.CMES.ArchiveMEP
    public partial class ArchiveMEPGridView
        /// Sets the presenter. The dependency injection system will automatically
        /// create a new presenter for you.
        public ArchiveMEPGridViewPresenter Presenter
                _presenter = value;
                _presenter.View = this;


Would somebody be able to help me understand what needs to be done?




Feb 22, 2012 at 4:32 AM

It looks like you are referencing ObjectBuilder and not ObjectBuilder2.  Enterprise Library does not use ObjectBuilder for dependency injection any longer.  Unity is used for DI (and internally ObjectBuilder2).

I'm not that familiar with SCSF but it looks like ObjectBuilder gets installed with it.  On Windows 7 it should be located at:

C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\Microsoft\Smart Client Software Factory 2010\3.0\Microsoft.Practices.ObjectBuilder.dll

If you add a reference to that assembly your code should be able to compile and run.

Randy Levy
Enterprise Library support engineer