WCF 服务尝试读取 mdf 文件

发布于 2024-12-06 11:04:04 字数 7427 浏览 1 评论 0原文

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

该应用程序调用项目内的 WCF 服务来读取 mdf 文件,同样是在应用程序内。

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

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

removed, see comments and below

有人对如何解决此问题有任何建议吗?我对 WCF 服务已经束手无策了!

预先感谢

Cap


编辑:

我现在已经激活了 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 中的新文件夹中。有什么想法吗?

再次感谢

I have a Silverlight application, developed in VS2010 and deployed on Server 2008.

The application calls a WCF service within the project to read an mdf file, again within the application.

After getting through a number of what can only be called bugs within the VS deployement system (missing out the svc.cs file, placing the references in a folder the service can't see) I have managed to get it running.

The problem I'm having is that the service fails after a few seconds. Using WCF Storm I was able to run the service and get the following error information:

removed, see comments and below

has anyone any suggestions as to how to fix this? I'm getting to the end of my tether with WCF services!

Thanks in advance

Cap


Edit:

I have now activated errors in the web.config (thanks Upendra Chaudhari) and it has given the following error:

<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& 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& 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<T>.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[]& outputs)   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& 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& 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& msgData, Int32 type)   at NewSiteService.GetDataTypes()   at NewSiteServiceClient.GetDataTypes()</StackTrace>
  <HelpLink isNull="true" />
  <Source>mscorlib</Source>
</FaultException1>

It looks like the service cannot see the database. I'm not particularly experienced with this sort of thing so I may be missing something important.

Within VS2010 I have the mdf file inside App_Data within the webpage. The service is within the services folder. I have published the site and moved the files and folders to a new folder within wwwroot. Any ideas?

Thanks again

Cap

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

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

发布评论

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

评论(1

长不大的小祸害 2024-12-13 11:04:05

您的问题是以下之一:

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

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

    <块引用>

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

Your problem is one of these:

  • your connection string is wrong:you must open web.config file in your web part of your project and right that.

  • database system is inaccessible because:

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