我正在学习如何使用.Net的内置配置文件提供程序,并遇到了以下问题:
我了解到,.Net应用程序的web.config设置可以覆盖machine.config设置。对我来说,machine.config文件中的以下设置是相关的:
<connectionStrings>
<add name="LocalSqlServer" connectionString="Data Source=(local);Initial Catalog=aspnetdb;
Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<profile><providers><add name="AspNetSqlProfileProvider"connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/></providers></profile>
这些设置用于设置本地配置文件。但是,当我将这些设置复制到我的应用程序的web.config中并更改machine.config中的设置时,它们就不能正常工作了,我得到了一个配置错误。例如,我将machine.config中提供程序的名称更改为“Local”。这应该不是问题,因为这些设置会被覆盖。然而,在运行应用程序时,我遇到了以下错误:
"条目“AspNetSQLProvider已经添加”(我的翻译)