WCF服务尝试读取mdf文件

时间:2011-09-27 10:13:40

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

我有一个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文件。该服务位于services文件夹中。我已发布该站点并将文件和文件夹移动到wwwroot中的新文件夹。有什么想法吗?

再次感谢

1 个答案:

答案 0 :(得分:0)

你的问题是其中之一:

  
      
  • 您的连接字符串错误:您必须在项目的Web部分中打开web.config文件,然后就可以了。

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

         
        
          
    • 数据库计算机已关闭
    •     
    • 数据库系统的防火墙或防病毒软件
    •     
      
  •