"尝试获取数据库类型,键与QUOT的实例激活出错; < - 空白 [英] Activation error occured while trying to get instance of type Database, key "" <-- blank

查看:136
本文介绍了"尝试获取数据库类型,键与QUOT的实例激活出错; < - 空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想出来的企业库5.0,并做我的BL一些单元测试,我需要对DL或测试项目?


$一个的app.config b $ b

请注意:我已经在我在我的Web项目的web.config配置设置



我如何使用DAAB:

 私有静态数据库DB = DatabaseFactory.CreateDatabase(); 

db.ExecuteNonQuery(spInsertSalesman,salesman.Fullname);

我的app.config上DL:



 <结构> 
< configSections>
<节名称=dataConfigurationTYPE =Microsoft.P​​ractices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,Microsoft.P​​ractices.EnterpriseLibrary.Data,版本= 5.0.414.0,文化=中性公钥= 31bf3856ad364e35requirePermission =FALSE/>
< / configSections>
< dataConfiguration defaultDatabase =DBTEST/>
<&是connectionStrings GT;
<添加名称=DBTEST的connectionString =数据源= [dbsource];初始目录= [DBNAME];用户ID = SA;密码=密码;
的providerName =System.Data.SqlClient的/>
< /&是connectionStrings GT;
< /结构>


解决方案

我是引用错误的.dll副本。现在的工作。


I'm trying out the Enterprise Library 5.0 and was doing some unit-tests on my BL, do I need to have a app.config on the DL or on the Test project?

note: I already have the configuration settings on my web.config on my web project.

how I use the DAAB:

private static Database db = DatabaseFactory.CreateDatabase();

db.ExecuteNonQuery("spInsertSalesman", salesman.Fullname);

my app.config on DL:

<configuration>
    <configSections>
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
    </configSections>
    <dataConfiguration defaultDatabase="DBTEST" />
    <connectionStrings>
        <add name="DBTEST" connectionString="Data Source=[dbsource];Initial Catalog=[dbname];User Id=sa;Password=password;"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>

解决方案

i was referencing the wrong .dll copy. it works now.

这篇关于&QUOT;尝试获取数据库类型,键与QUOT的实例激活出错; &LT; - 空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆