【问题标题】:WCF service attempting to read mdf fileWCF 服务尝试读取 mdf 文件
【发布时间】:2011-09-27 10:13:40
【问题描述】:

我有一个 Silverlight 应用程序,在 VS2010 中开发并部署在 Server 2008 上。

应用程序调用项目内的 WCF 服务来读取 mdf 文件,再次在应用程序内。

在解决了 VS 部署系统中的一些只能称为错误的问题(错过了 svc.cs 文件,将引用放在服务看不到的文件夹中)之后,我设法让它运行起来。

我遇到的问题是服务在几秒钟后失败。使用 WCF Storm 我能够运行该服务并获得以下错误信息:

removed, see comments and below

有没有人对如何解决这个问题有任何建议?我的 WCF 服务即将结束!

提前致谢

上限


编辑:

我现在在 web.config 中激活了错误(感谢 Upendra Chaudhari),它给出了以下错误:

<GetDataTypes>
<MethodParameters>
<FaultException1>
  <Detail>
    <HelpLink isNull="true" />
    <InnerException>
      <HelpLink isNull="true" />
      <InnerException isNull="true" />
      <Message>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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)</Message>
      <StackTrace>at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)   at System.Data.SqlClient.SqlConnection.Open()   at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean&amp; closeStoreConnectionOnFailure)</StackTrace>
      <Type>System.Data.SqlClient.SqlException</Type>
    </InnerException>
    <Message>The underlying provider failed on Open.</Message>
    <StackTrace>at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean&amp; closeStoreConnectionOnFailure)   at System.Data.EntityClient.EntityConnection.Open()   at System.Data.Objects.ObjectContext.EnsureConnection()   at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)   at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator()   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)   at e_on_silverlight_bing.Web.Services.NewSiteService.GetDataTypes() in C:\Documents and Settings\richardsonl\My Documents\Visual Studio 2010\Projects\E-on Site Map\SilverlightApplication3\e-on silverlight bing.Web\Services\NewSiteService.svc.cs:line 65   at SyncInvokeGetDataTypes(Object , Object[] , Object[] )   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
    <Type>System.Data.EntityException</Type>
  </Detail>
  <Action>http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault</Action>
  <Code>System.ServiceModel.FaultCode</Code>
  <Message>The underlying provider failed on Open.</Message>
  <Reason>The underlying provider failed on Open.</Reason>
  <Data>
    <KeysAndValues attr0="KeyValuePairArray" isNull="false" />
  </Data>
  <InnerException isNull="true" />
  <TargetSite>Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)</TargetSite>
  <StackTrace>Server stack trace:    at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc&amp; rpc)   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)Exception rethrown at [0]:    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)   at NewSiteService.GetDataTypes()   at NewSiteServiceClient.GetDataTypes()</StackTrace>
  <HelpLink isNull="true" />
  <Source>mscorlib</Source>
</FaultException1>

服务似乎看不到数据库。我对这类事情不是特别有经验,所以我可能会遗漏一些重要的东西。

在 VS2010 中,我在网页的 App_Data 中有 mdf 文件。该服务位于服务文件夹中。我已发布该站点并将文件和文件夹移动到 wwwroot 中的新文件夹。有什么想法吗?

再次感谢

上限

【问题讨论】:

  • 根据错误描述,这不是您收到的实际错误。要得到实际的错误,您需要在 WCF 服务中打开 IncludeExceptionDetailInFaults 以便我们有更多的想法。
  • 哇,我怎么错过了。这是漫长的一天。谢谢:)
  • 现在错误表明与 SQL 的连接问题。

标签: visual-studio silverlight wcf visual-studio-2010 silverlight-4.0


【解决方案1】:

您的问题是其中之一:

  • 您的连接字符串错误:您必须在项目的 Web 部分中打开 web.config 文件并进行正确处理。

  • 数据库系统无法访问,因为:

    • 数据库计算机已关闭
    • 数据库系统的防火墙或防病毒软件处于活动状态

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多