C# – Simple Enterprise Library console application refuses to compile

centerprise-libraryenterprise-library-5net

I just downloaded and installed Microsoft Enterprise Library 5.0. I fired up VS 2010 to play with EL 5 and created a very simple console application. However, it would not compile. I got the following error:

The type or namespace name 'Data' does not exist in the namespace
'Microsoft.Practices.EnterpriseLibrary'
(are you missing an assembly
reference?)

I added Microsoft.Practices.EnterpriseLibrary.Common, Microsoft.Practices.EnterpriseLibrary.Data, and Microsoft.Practices.Unity
references to my project.

Here's the simple code that refuses to compile.

using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Unity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.Unity;

namespace EntLib
{
    class Program
    {
        static void Main(string[] args)
        {
            IUnityContainer container = new UnityContainer();
            container.AddNewExtension<EnterpriseLibraryCoreExtension>();
            var defaultDatabase = container.Resolve<Database>();
        }
    }
}

The error above complains about line #2 :

using Microsoft.Practices.EnterpriseLibrary.Data;

Someone probably will point out to a stupid mistake by me, but at the moment I fail to see it.

I tried to remove and add again Microsoft.Practices.EnterpriseLibrary.Data to refences but it didn't help.

Best Answer

I found my answer at this question. I changed target framework in my project to .NET Framework 4 from .NET Framework Client Profile.

Related Topic