gpt4 book ai didi

c# - 当 "Application Name=application"在连接字符串中时,为什么此数据库连接失败?

转载 作者:太空狗 更新时间:2023-10-29 17:59:39 26 4
gpt4 key购买 nike

我们正在编写一个 Multi-Tenancy Silverlight 应用程序。用户使用 Windows 窗体身份验证登录,我们从表中提取该用户的连接字符串。该字符串的形式为:

Data Source=1.2.3.4; Initial Catalog=database; Persist Security Info=True; User ID=######; Password=##########

这工作正常。然后我们决定设置应用程序名称,原因 outlined here会是个好主意:

Data Source=1.2.3.4; Initial Catalog=database; Application Name=application; Persist Security Info=True; User ID=######; Password=##########

但是,现在没有建立连接,所以我们收到错误。这仅在部署的站点上失败。通过 Visual Studio 运行显然不受影响。建立连接的代码没有任何变化。我愿意相信应该有变化,但我一直无法弄清楚它们应该是什么。

连接是这样创建的:

public class OurDataContext : DataContext
{
public OurDataContext()
: base(SessionCache.OurConnectionString)
{
....
}
}

SessionCache.OurConnectionString 是从数据库读取的字符串。

更新

对连接字符串的更改可能是一个转移注意力的问题。我们只在一台 Web 服务器(我无法直接访问的服务器)上遇到此故障。将属性添加到另一个 Web 服务器引用的数据库(我确实可以访问)不会重现问题。这使我得出错误在其他地方的结论。但是,我离解决这个问题还差得很远。

实际错误是异常:

An exception of type 'System.ServiceModel.DomainServices.Client.DomainOperationException' occurred and was caught.
------------------------------------------------------------------------------------------------------------------
01/31/2012 14:18:53
Type : System.ServiceModel.DomainServices.Client.DomainOperationException, System.ServiceModel.DomainServices.Client, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Message : Load operation failed for query 'GetUserSecurityConfig'. The remote server returned an error: NotFound.
Status : ServerError
ErrorCode : 0
Data : System.Collections.ListDictionaryInternal
Stack Trace : The stack trace is unavailable.

我今天对此所做的所有研究都返回了一些不应该改变的相当基本的东西:

  • System.ComponentModel.DataAnnotations、System.ServiceModel.DomainServices.EntityFramework、System.ServiceModel.DomainServices.Hosting 和 System.ServiceModel.DomainServices.Server 未复制到\bin 目录。我查过了,他们是。
  • 连接到数据库服务器时出错。我认为不是这种情况,因为表单例份验证有效。它是服务器上的不同数据库,但凭据是相同的。

最佳答案

问题原来是由于服务器上安装的 RIA 服务版本引起的。

我们最近更改了项目以通过 NuGet 包管理器包含 RIA 服务,并且此服务器已经安装了用于 VS2010 的 RIA 服务。当我们解决这个问题时,一切都恢复了生机。

虽然还不清楚为什么这个问题花了这么长时间才显现出来。

关于c# - 当 "Application Name=application"在连接字符串中时,为什么此数据库连接失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9065193/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com