[英]The underlying provider failed on Open exception in wcf in iis7
我創建了一個ASP.NET MVC 3應用程序,在DAL中也有一個ADO.NET實體數據模型,該模型也具有用於訪問數據的類。
我也有一個WCF Restful服務,它是我為與Android應用程序通信而創建的。 因此,當我嘗試在IIS7上托管服務時,出現此錯誤:
基礎提供程序在Open和此處失敗:
服務器在處理請求時遇到錯誤。 異常消息為“基礎提供程序在打開時失敗”。 有關更多詳細信息,請參見服務器日志。 異常堆棧跟蹤位於
System.Data.EntityClient.EntityConnection.Open()處System.Data.EntityClient.EntityConnection.Open()處的System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition,DbConnection storeConnectionToOpen,DbConnection originalConnection,String exceptionCode,String tryedOperation,Boolean&closeStoreConnectionOnFailure) ()在System.Data.Objects.ObjectQuery
1.GetResults(Nullable
1 forMergeOption)在System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
System.Linq.Queryable.FirstOrDefault的1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1源)在c:\\ Users \\ ines \\ Documents \\ Visual Studio 2012中的SecurityLayer.Authentification.Auth.VerifAuth(User u)處的[TSource](IQueryable`1源) \\ Projects \\ GestionDeComptabilite \\ ControleLayer \\ Authentification \\ Auth.cs:c:\\ Users \\ ines \\ Documents \\ Visual Studio 2012 \\ Projects \\ GestionDeComptab中ManagementServices.AllServices.Authentification(String pseudo,String password)的第16行 ilite \\ ManagementServices \\ AllServices.svc.cs:System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke上SyncInvokeAuthentification(Object,Object [],Object [])的第28行(對象實例,Object []輸入,Object []&輸出)在System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc.patcher。 .Process(布爾值isOperationContextSet)
附帶說明一下,當我從Visual Studio啟動它時,我的WCF服務沒有問題,問題僅在於IIS。 當我搜索此問題時,我嘗試了以下建議作為解決方案的方法:
我還嘗試了那些鏈接中提出的所有解決方案,但仍然沒有一個起作用:
這也是:
如果有人可以提供幫助,我將不勝感激。
有關更多信息,這是我的代碼:
using SecurityLayer.Authentification;
using DataRepository.DAL;
using DataRepository.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;
namespace ManagementServices
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class AllServices : IAllServices
{
public bool Authentification(string pseudo, string password)
{
User u = new User
{
UserName = pseudo,
Password = password
};
Auth a = new Auth() ;
if (a.VerifAuth(u)) return true;
return false;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace ManagementServices
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IAllServices" in both code and config file together.
[ServiceContract(Namespace="http://Services.Compta.com")]
public interface IAllServices
{
[OperationContract(Name="Authentification" )]
[WebInvoke(UriTemplate = "/Auth/{pseudo}/{password}", Method = "GET", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
bool Authentification(string pseudo, string password);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" /> <modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
<connectionStrings>
<add name="GestionComptabiliteEntities" connectionString="metadata=res://*/Data.GestionComptabiliteModel.csdl|res://*/Data.GestionComptabiliteModel.ssdl|res://*/Data.GestionComptabiliteModel.msl;provider=System.Data.SqlClient;provider connection string="data source=(localDB)\v11.0;attachdbfilename=C:\Users\ines\Documents\Visual Studio 2012\Projects\GestionDeComptabilite\DataRepository\App_Data\GestionComptabilite.mdf;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" /> <identity impersonate="true" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding> <binding name="NewBinding0" /> </basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
<services>
<service name="ManagementServices.AllServices" behaviorConfiguration="restBehavior">
<endpoint address="" behaviorConfiguration="a" binding="webHttpBinding" name="xml" contract="ManagementServices.IAllServices" />
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="" contract="ManagementServices.IAllServices" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="restBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors> <behavior name="a"> <webHttp /> </behavior> </endpointBehaviors> </behaviors> </system.serviceModel>
</configuration>
請注意,這是WCF寧靜的應用程序,而不是庫,我也在VirtualBox中的Windows 7 Ultimate 64位下運行。
需要確認....,您在連接字符串中使用mdf文件,您的IIS服務器在哪里,它是在與Visual Studio運行應用程序的同一台計算機上嗎?
如果您在其他物理設備上托管,則.mdf文件存在完整路徑.....以下是共享web.config中連接字符串的一部分,您應首先驗證文件的退出狀態。....數據源=( localDB)\\ v11.0; attachdbfilename = C:\\ Users \\ ines \\ Documents \\ Visual Studio 2012 \\ Projects \\ GestionDeComptabilite \\ DataRepository \\ App_Data \\ GestionComptabilite.mdf; MultipleActiveResultSets = True; App = EntityFramework“
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.