The type String cannot be constructed. You must configure the container to supply this value.

利用 Enterprise Library 5.0

Microsoft.Practices.EnterpriseLibrary.Common

Microsoft.Practices.EnterpriseLibrary.Data

Microsoft.Practices.ServiceLocation

引用都添加了

EnterpriseLibraryContainer.Current.GetInstance<SqlDatabase>("SQLConnString"); 运行到此处一直报错

The type String cannot be constructed. You must configure the container to supply this value.

后发现问题 出现在此:

<add name="SQLConnString" connectionString="server=127.0.0.1;database=ddbb;uid=dd;pwd=11;"  />

再加上   providerName="System.Data.SqlClient"

    <add name="SQLConnString" connectionString="server=172.20.20.13;database=ProjectDB;uid=sa;pwd=11;" providerName="System.Data.SqlClient" />

都正常了

原文地址:https://www.cnblogs.com/net-saiya/p/5999364.html