【发布时间】:2014-07-04 10:18:17
【问题描述】:
我正在使用 Visual Studio 2013。我正在尝试创建 WCF 服务。在这项服务中,我有一个数据库。当我运行此服务时,它会返回数据。但是当我从客户端应用程序尝试时,我得到了一个例外。我正在使用默认的 Visual Studio 2013 SQL Server。谁能帮帮我吗?有什么问题,我该如何解决?
错误:
发生网络相关或特定于实例的错误,同时 建立与 SQL Server 的连接。找不到服务器或 无法访问。验证实例名称是否正确,并且 SQL Server 配置为允许远程连接。 (提供者:SQL 网络接口,错误:50 - 发生本地数据库运行时错误。 无法创建自动实例。查看 Windows 应用程序事件 记录错误详情。 )
服务器堆栈跟踪:
在 System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(消息 回复、MessageFault 故障、字符串操作、MessageVersion 版本、 FaultConverter faultConverter)
在 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime 操作,ProxyRpc&rpc)
在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, Object[] 出局,TimeSpan 超时)
在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall、ProxyOperationRuntime 操作)
在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 留言)在 [0] 处重新抛出异常:
在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(消息数据& msgData, Int32 类型)
在 WindowsApplication1.ServiceReference1.IService1.login(字符串 id, 字符串密码)
在 WindowsApplication1.ServiceReference1.Service1Client.login(字符串 id, 字符串密码)在 e:\study\7thsemister\Paint app\Paint app\Service References\ServiceReference1\Reference.cs:第 77 行
在 WindowsApplication1.login.login_btn_Click(对象发送者,EventArgs e) 在 e:\study\7thsemister\Paint app\Paint app\login.cs:line 26
【问题讨论】:
-
您能否提供尽可能多的有关连接字符串的信息以及它工作或不工作的每个上下文?
-
LocalDB 中似乎出现了错误。您是否遵循堆栈跟踪
50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.中的此建议(即您是否查看了事件日志)? -
我正在尝试验证用户名和密码。当我从服务器端手动输入时,它给了我很好的结果。但是当我从客户端应用程序尝试时,它给了我这个巨大的异常
-
亲爱的 martin_costello 我不知道。你能简单介绍一下吗。实际上我是 wcf 的新手
-
鉴于您是 WCF 新手,我可以建议您先获得一些简单的 WCF 服务,无需任何数据库访问权限吗?并且还要学习编写 SQL Server 数据库客户端代码,而不涉及 WCF 之类的任何花哨的东西?现在你正试图同时做两件事,这两件事都非常复杂,而且对你来说都是新的。首先选择问题的一部分来解决。
标签: c# sql-server wcf