使用 DAAB 4.1 部署的项目出现运行时错误
我在尝试使用 Microsoft Enterprise Library 的数据访问应用程序块 4.1 时遇到了一个奇怪的部署问题。 当尝试使用利用 DAAB 的 Web 应用程序的元素时,我收到以下未处理的异常:
Exception information:
Exception type: BuildFailedException
Exception message: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, DBNAME]) failed: The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Data.Database' threw an exception. (Strategy type ConfiguredObjectStrategy, index 2)
我的 web.config 具有以下用于连接字符串的部分:
<connectionStrings configSource="data.config" />
并且 data.config 包含异常中引用的 DBNAME 的条目:
<?xml version="1.0"?>
<connectionStrings>`
<add name="dbname"
providerName="System.Data.SqlClient"
connectionString="[valid information here]" />
</connectionStrings>
我知道连接字符串有效,因为应用程序中不使用 DAAB 进行数据访问的部分正在使用相同的连接字符串,没有任何问题。 此外,在我的开发机器以及其他开发人员的机器上一切都运行良好。 这仅在部署到生产服务器时发生,甚至不特定于“发布”版本,因为该版本在我的本地计算机上也运行良好。
我怀疑这可能是生产服务器的配置问题,但我无法弄清楚它可能是什么。 关于部署企业库的 MSDN 文章提到,程序集的 xcopy 部署应该可以工作,并且我将它们包含在 /bin 文件夹中,因此我不确定从哪里开始。 有任何想法吗?
I'm having a weird problem on deployment while trying to use Microsoft Enterprise Library's Data Access Application Block 4.1. I get the following Unhandled Exception when trying to use the element of the web application that utilizes the DAAB:
Exception information:
Exception type: BuildFailedException
Exception message: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, DBNAME]) failed: The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Data.Database' threw an exception. (Strategy type ConfiguredObjectStrategy, index 2)
My web.config has the following section for connectionStrings:
<connectionStrings configSource="data.config" />
And the data.config contains an entry for the DBNAME referenced in the exception:
<?xml version="1.0"?>
<connectionStrings>`
<add name="dbname"
providerName="System.Data.SqlClient"
connectionString="[valid information here]" />
</connectionStrings>
I know the connection string is valid because the portions of the app that aren't using DAAB for data access are using the same connection string with no problems. Additionally, things are working fine on my development machine, as well as the machines of the other developers. This is only happening on deployment to the production servers and isn't even specific to the "release" build since that version runs fine on my local machine as well.
I suspect that it is probably a configuration issue with the production servers, but I haven't been able to figure out what it might be. The MSDN article on deploying Enterprise Library mentions that an xcopy deployment of the assemblies should work and I'm including them in the /bin folder, so I'm not sure where to go from there. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,当您添加参考文献时,它确实会给您一个警告。 至少这就是它在我的机器上的表现。 所以你的投诉没有充分的依据。 :)
但是,异常消息完全不明确,所以感谢您提供的信息。
Well, it does give you a warning when you add the references. That's at least how it behaved on my machine. So you don't have a solid ground for your complaint. :)
However, the exception message is totally ambiguous, so thanks for the info.
终于明白了这一点。 Enterprise Library 4.1 需要 Framework 3.5,尽管我们的应用程序仍以 Framework 2.0 为目标,但通过使用 Visual Studio 2008 在我们的开发计算机上安装了 3.5。但是,我们没有在生产服务器上安装 Framework 3.5,并且这样做后问题就消失了。
令人费解的是,我在解决方案中的所有项目中明确以 2.0 为编译目标,包括依赖企业库的项目,因此您可能会认为引用需要 3.5 的程序集至少会产生编译警告。 那好吧。
Finally figured this out. Enterprise Library 4.1 requires Framework 3.5 and even though we are still targeting Framework 2.0 for our application, 3.5 is installed on our development machines by virtue of using Visual Studio 2008. We did not, however, have Framework 3.5 installed on our production servers and the problem disappeared after doing so.
The puzzling thing is that I am explicitly targeting 2.0 for compilation in all projects in my solution including the one that relies on the Enterprise Library, so you'd think referencing an assembly that requires 3.5 would at least produce a warning on compilation. Oh well.