我刚刚下载并安装微软企业库5.0 。我启动了VS 2010与EL 5玩,创造了一个非常简单的控制台应用程序。但是,它不会编译。我得到了以下错误:
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:
的类型或命名空间名称数据不会在命名空间存在 Microsoft.Practices.EnterpriseLibrary (是否缺少程序集 参考?)的
The type or namespace name 'Data' does not exist in the namespace 'Microsoft.Practices.EnterpriseLibrary' (are you missing an assembly reference?)
我加的 Microsoft.Practices.EnterpriseLibrary.Common,Microsoft.Practices.EnterpriseLibrary.Data 和 Microsoft.Practices.Unity 的 引用我的项目。
I added Microsoft.Practices.EnterpriseLibrary.Common, Microsoft.Practices.EnterpriseLibrary.Data, and Microsoft.Practices.Unity references to my project.
下面是简单的code表示拒绝编译。
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>();
}
}
}
上述错误抱怨行#2:
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.
我试图删除并重新Microsoft.Practices.EnterpriseLibrary.Data添加到refences,但它并没有帮助。
I tried to remove and add again Microsoft.Practices.EnterpriseLibrary.Data to refences but it didn't help.
我发现我在答案这个问题。我在我的项目变化的目标框架.NET Framework 4的从.NET框架的客户端配置文件。
I found my answer at this question. I changed target framework in my project to .NET Framework 4 from .NET Framework Client Profile.