简单的企业库控制台应用程序拒绝编译

发布于 2024-08-31 04:23:02 字数 1266 浏览 0 评论 0原文

我刚刚下载并安装了 Microsoft企业库5.0。我启动了 VS 2010 来使用 EL 5,并创建了一个非常简单的控制台应用程序。但是,它无法编译。我收到以下错误:

命名空间中不存在类型或命名空间名称“Data” 'Microsoft.Practices.EnterpriseLibrary' (你是否缺少一个程序集 参考?)

我添加了 Microsoft.Practices.EnterpriseLibrary.Common、Microsoft.Practices.EnterpriseLibrary.DataMicrosoft.Practices.Unity 参考我的项目。

这是拒绝编译的简单代码。

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 行:

using Microsoft.Practices.EnterpriseLibrary.Data;

有人可能会指出我的一个愚蠢的错误,但目前我看不到它。

我尝试删除 Microsoft.Practices.EnterpriseLibrary.Data 并再次添加到引用中,但没有帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乖乖兔^ω^ 2024-09-07 04:23:02

我在这个问题中找到了答案。我将项目中的目标框架从 .NET Framework Client Profile 更改为 .NET Framework 4。

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

作妖 2024-09-07 04:23:02

我怀疑您的目标是 .NET 客户端配置文件。使用 EntLib 5.0 的 Microsoft.Practices.EnterpriseLibrary.Data 程序集时,您需要面向完整的 .NET 框架。右键单击您的项目,选择“属性”,然后在“应用程序”选项卡中,选择“.NET Framework 3.5”或“.NET Framework 4.0”作为“目标框架”属性的值。这是 EntLib 5.0 中的一个已知问题

im suspecting that you are targeting a .NET client profile. When using the Microsoft.Practices.EnterpriseLibrary.Data assembly of EntLib 5.0, you are required to target the full .NET framework. Right click on your project, select Properties, and in the Applciation tab, select either .NET Framework 3.5 or .NET Framework 4.0 as value of the Target Framework property. This is a known issue in EntLib 5.0

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文