EF4 EntityException - 底层提供程序在打开时失败

发布于 2024-11-03 06:13:12 字数 632 浏览 2 评论 0原文

好的,这是新的。我正在尝试调试我的项目,我过去已经做过很多次了,现在我在我的一个存储库中遇到了这个异常。我以前没见过。我已经好几天没有碰过我的存储库了,我的连接字符串和以前一样。内部异常指出:

{“建立与 SQL Server 的连接时发生网络相关或特定于实例的错误。找不到服务器或无法访问服务器。请验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接.(提供程序:命名管道提供程序,错误:40 - 无法打开与 SQL Server 的连接)"}

它令人窒息的代码是:

public class HGArticleRepository : IArticleRepository
{
    private HGEntities _siteDB = new HGEntities();

    public List<Article> Articles
    {
        get { return _siteDB.Articles.ToList(); } // <-- this is the line
    }

    // more repo code
}

再次,就像我说的,我以前从未遇到过此异常,而且我也没有碰过我的几天内的域名代码。

Okay, this is a new one. I'm trying to debug my project, which I've done many times in the past, and I'm now getting this exception in one of my repositories. I haven't seen it before now. I haven't touched my repos in days, and my connection string is the same as its always been. The inner exception states:

{"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}

And the code it's choking on is:

public class HGArticleRepository : IArticleRepository
{
    private HGEntities _siteDB = new HGEntities();

    public List<Article> Articles
    {
        get { return _siteDB.Articles.ToList(); } // <-- this is the line
    }

    // more repo code
}

Again, like I said, I've never encountered this exception before, and I haven't touched my domain code in days.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

○愚か者の日 2024-11-10 06:13:12

此错误通常意味着:

  1. 连接字符串指向不存在的 SQL Server。
  2. 连接字符串指向已关闭的 SQL Server。或者没有开始。
  3. SQL Server 设置中禁用了命名管道传输。

一一仔细检查。在你的情况下我猜它是2。

This error usually means:

  1. Connection String points to nonexistent SQL Server.
  2. Connection String points to SQL Server that was shut down. Or not started.
  3. Named pipes transport was disabled in SQL Server settings.

Check them carefully one by one. In your case I guess it is 2.

紫瑟鸿黎 2024-11-10 06:13:12

解决方案的第二种选择:
检查 IIS 是否正在运行。
就我而言,它被停止了,所以我得到了同样的错误。

A second option of solution:
Review that IIS is running.
In my case it was stopped, so I got the same error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文