WPF 不尊重 App.config 中的 SQL 连接和成员资格提供程序
我有一个 WPF 表单,尝试将其与我们设置的 SQL 成员资格提供程序一起使用。我的 App.Config 看起来像这样:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<clear/>
<add name="IodConnString" connectionString="server=SQLSERVER;UID=USER;PWD=PASSWORD;DATABASE=DATABASE;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<!-- membership provider -->
<membership defaultProvider="IODMembershipProvider">
<providers>
<clear/>
<add name="IODMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="IodConnString"
enablePasswordRetrieval="true"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Clear"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="3"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""/>
</providers>
</membership>
</system.web>
</configuration>
当我调试时,这里有一个断点:
string thisrsgjha = Membership.Provider.ApplicationName;
当我深入到 Provider(使用监视窗口)时,我看到它在本地使用 SQL 连接字符串,而不是我在 App.Config 中定义的连接字符串。我错过了什么吗?这在我们也有的 Web 应用程序中完美运行,但在这里不行。
I have a WPF form that I am trying to use with a SQL Membership Provider we have setup. My App.Config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<clear/>
<add name="IodConnString" connectionString="server=SQLSERVER;UID=USER;PWD=PASSWORD;DATABASE=DATABASE;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<!-- membership provider -->
<membership defaultProvider="IODMembershipProvider">
<providers>
<clear/>
<add name="IODMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="IodConnString"
enablePasswordRetrieval="true"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Clear"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="3"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""/>
</providers>
</membership>
</system.web>
</configuration>
When I debug I have a break point here:
string thisrsgjha = Membership.Provider.ApplicationName;
When I drill into Provider (using watch window) I see it is using a connection string for SQL locally instead of the one I defined in App.Config. Am I missing something? This work perfectly in a Web App that we also have, but not here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保配置文件正确部署在输出目录中。
Make sure that the config file is properly deployed in the output directory.