尝试配置企业库 5.0(数据访问应用程序块)时出现问题

发布于 2024-09-02 00:42:48 字数 1097 浏览 9 评论 0原文

我在尝试从 Enterprise Library 5.0 运行 DAAB 时遇到了一些问题。我已按照教程执行步骤,但出现错误...

1) 下载/安装企业库

2) 添加对我需要的块的引用(公共/数据)

3) 导入

Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data

4) 通过企业库配置软件。我从我的网站打开 web.config。然后我单击“块”,然后单击“添加数据设置...”填写我的详细信息并保存/关闭

5) 然后我(认为设置已完成)尝试通过 6) 获取数据库的实例

 Dim db As Database = DatabaseFactory.CreateDatabase() 

6) 我编译并收到以下错误:

可以不加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Data,Version=5.0.414.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)(C:\site\web.config 第 4 行)

我的 web.config 中的第 4 行是由配置工具生成的,是:

<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />

我是否缺少必需的步骤?我是否按照错误的顺序完成了这些步骤?我犯了一个错误吗?

非常感谢您的帮助。

I am running into some problems while trying to get DAAB from Enterprise library 5.0 running. I have followed the steps as per the tutorial, but am getting errors...

1) Download / install enterprise library

2) Add references to the blocks I need (common / data)

3) Imports

Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data

4) Through the enterprise library config software. I open up the web.config from my site. I then click Blocks, then Add data settings... fill in my details and save / close

5) I then (thinking setup is complete) try to get an instance of the database via

 Dim db As Database = DatabaseFactory.CreateDatabase() 

6) I compile and receive the following error:

Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\site\web.config line 4)

Line 4 off my web.config was generated by the config tool and is:

<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />

Am I missing a required step? Have I done the steps in the wrong order? Have I made a mistake?

Thanks a lot for the assistance.

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

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

发布评论

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

评论(6

旧瑾黎汐 2024-09-09 00:42:48

答案:

我不小心引用了 src 代码文件夹中的程序集。这意味着公共代币将 = null。我重新引用了 C:\Program Files\Microsoft Enterprise Library 5.0\Bin 中的程序集,问题现已解决。

The answer:

I had accidentaly referenced the assemblies from the src code folder. Which means the public tokens would have = null. I re-referenced to the assemblies in C:\Program Files\Microsoft Enterprise Library 5.0\Bin and the problem is now solved.

欢你一世 2024-09-09 00:42:48

我已经看到你得到了答案;但是,我想指出,当您从 VS 打开配置工具时,您可以选择告诉配置工具您想要引用哪些程序集:

  1. 在 VS2010 中:打开属性编辑器窗口,然后从解决方案资源管理器中选择解决方案文件。
  2. 您将看到“Enterprise Library 5 Assembly Set”选项,其中包含使用签名版本(Microsoft Signed)或未签名版本(EntLibV5Src)的选项

当您启动配置工具时, ;它将相应地引用配置文件中的程序集你的选择。

I already saw you got the answer; however, I wanted to point out that when you open the Config tool from VS, you have the option to tell the config tool what assemblies you want to have referenced:

  1. In VS2010: open the properties editor window, and select from the solution explorer the Solution file.
  2. You'll see the option "Enterprise Library 5 Assembly Set, with the options to use the signed versions (Microsoft Signed) or the unsigned (EntLibV5Src)

When you fire up the config tool; it will reference the assemblies in the config file accordingly to your choice.

倾其所爱 2024-09-09 00:42:48

除了@Nicolas 的回答之外,您还可以通过删除 app.config 中与 Enterprise Library 5.0 dll 一起使用的公共令牌来解决此问题

In addition to what @Nicolas answered you can over come this problem by removing public token in app.config where ever it being used with Enterprise Library 5.0 dll

昨迟人 2024-09-09 00:42:48

企业库有 2 个下载...

  • Enterprise Library 5.0 - Source Code.msi
  • Enterprise Library 5.0.msi

只有第二个具有签名的二进制文件...这是解决“清单定义与程序集引用不匹配”错误所必需的

(仅供参考,如果您选择安装,第二个还包括源代码)

Enterprise library has 2 downloads ...

  • Enterprise Library 5.0 - Source Code.msi
  • Enterprise Library 5.0.msi

Only the second one has the signed binaries ... which is what's necessary to resolve the "manifest definition does not match the assembly reference" error

(and FYI, the second one also includes the source code if you elect to install it)

ペ泪落弦音 2024-09-09 00:42:48

您可能需要做的是将项目属性中的目标框架从“.NET Framework 4 Client Profile”更改为“.NET Framework 4”。

当您首次创建控制台项目时,VS 2010 默认情况下会创建 ."NET Framework 4 Client Profile"。使用“.NET Framework 4”编译的 EL 5 并且您的项目很难解析 EL dll。

What probably you need to do is change Target framework in property of your project from ".NET Framework 4 Client Profile" to ".NET Framework 4".

When you first create a console project, VS 2010 by default creates ."NET Framework 4 Client Profile". EL 5 compiled with ".NET Framework 4" and your project has hard time to resolve EL dll(s).

尬尬 2024-09-09 00:42:48

产生

<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />                      
        <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />   
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />      

generate

<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />                      
        <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />   
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />      
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文