when I run my project from my local computer I can connect to the database just fine. when I publish it I receive an error (below). I believe the issue is with the app pool, but cant' figure out what it is.
当我从本地计算机运行我的项目时,我可以很好地连接到数据库。当我发布它时,我收到一个错误(如下)。我认为问题在于应用程序池,但无法弄清楚它是什么。
this is a fresh install of everything, down to the OS
这是一切全新的安装,直到操作系统
Identity - applicationpoolidentity
身份 - 应用程序身份
connection string
<add name="SPA_Impact_Reporting_TestEntities" connectionString="metadata=res://*/newRack.csdl|res://*/newRack.ssdl|res://*/newRack.msl;provider=System.Data.SqlClient;provider connection string="data source=serverip;initial catalog=dbname;persist security info=True;user id=user;password=pass;MultipleActiveResultSets=T rue;App=EntityFramework"" providerName="System.Data.EntityClient" /></connectionStrings>
ERROR
Process information: Process ID: 5872 Process name: w3wp.exe Account name: IIS APPPOOL\DefaultAppPool
进程信息:进程ID:5872进程名称:w3wp.exe帐户名:IIS APPPOOL \ DefaultAppPool
Exception information: Exception type: SqlException Exception 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1 retry) at System.Data.SqlClient.SqlConnection.Open() at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
异常信息:异常类型:SqlException异常消息:建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供者:命名管道提供程序,错误:40 - 无法打开到SQL Server的连接)在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning的System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,Boolean breakConnection,Action1 wrapCloseInAction)中(TdsParserStateObject stateObj,Boolean callerHasConnectionLock,Boolean asyncClose)System.Data上的System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,SqlInternalConnectionTds connHandler,Boolean ignoreSniOpenTimeout,Int64 timerExpire,Boolean encrypt,Boolean trustServerCert,Boolean integratedSecurity,Boolean withFailover)。 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover中的SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,String newPassword,SecureString newSecurePassword,Boolean ignoreSniOpenTimeout,TimeoutTimer timeout,Boolean withFailover)(ServerInfo serverInfo,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance,SqlC System.Data.SqlClient.SqlInternalConnectionTds..ctor上的System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer超时,SqlConnectionString connectionOptions,SqlCredential凭证,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance)中的onnectionString connectionOptions,SqlCredential凭证,TimeoutTimer超时)( System.Data.SqlClient.SqlConnectionFactory.CreateConnection中的DbConnectionPoolIdentity标识,SqlConnectionString connectionOptions,SqlCredential凭证,Object providerInfo,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData)(DbConnectionOptions选项,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,DbConnectionPool池, System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool池,DbConnecti)上的DbConnection owningConnection,DbConnectionOptions userOptions)在System.Data.ProviderBase.DbConnectionPool.UserCreateRequest上的System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection)上的owningObject,DbConnectionOptions选项,DbConnectionPoolKey poolKey,DbConnectionOptions(userOptions)上(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal) System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean allowCreate,Boolean onlyOneCheckConnection,DbConnectionOptions userOptions,DbConnectionInternal&connection)at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,TaskCompletionSource1 retry,DbConnectionOptions userOptions) System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource1 retry,DbConnectionOptions us),DbConnectionInternal&connection)在System.Data的System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry)处的System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource1 retry,DbConnectionOptions userOptions)处的erOptions,DbConnectionInternal oldConnection,DbConnectionInternal&connection。 System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf上的System.Data.SqlClient.SqlConnection.Open()中的SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry)(布尔值openCondition,DbConnection storeConnectionToOpen,DbConnection originalConnection,String exceptionCode,String attemptsOperation,Boolean&closeStoreConnectionOnFailure)
The network path was not found
找不到网络路径
Server Error in '/spadashboard' Application.
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
超时已过期。从池中获取连接之前经过的超时时间。这可能是因为所有池连接都在使用中并且达到了最大池大小。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
Exception Details: System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
异常详细信息:System.InvalidOperationException:超时已过期。从池中获取连接之前经过的超时时间。这可能是因为所有池连接都在使用中并且达到了最大池大小。
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。
Stack Trace:
[InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.] System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +6600161 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 retry, DbConnectionOptions userOptions) +6600667 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) +233 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1 retry) +278 System.Data.SqlClient.SqlConnection.Open() +239 System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +99
[InvalidOperationException:超时已过期。从池中获取连接之前经过的超时时间。这可能是因为所有池连接都在使用并且达到了最大池大小。] System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource1 retry,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal&connection)+6600161 System.Data。 ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource1 retry,DbConnectionOptions userOptions)+6600667 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry)+233 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry)+278 System.Data.SqlClient.SqlConnection.Open()+239 System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition,DbConnection storeConnectionToOpen,DbConnection originalConnection,String exceptionCode,String attemptsOperation,Boolean&closeStoreConnectionOnFailure)+9 9
[EntityException: The underlying provider failed on Open.] System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +10948975 System.Data.EntityClient.EntityConnection.Open() +136 System.Data.Objects.ObjectContext.EnsureConnection() +91 System.Data.Objects.ObjectContext.ExecuteStoreQueryInternal(String commandText, String entitySetName, MergeOption mergeOption, Object[] parameters) +109 System.Data.Objects.ObjectContext.ExecuteStoreQuery(String commandText, Object[] parameters) +87 System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery(String sql, Object[] parameters) +118 System.Data.Entity.Internal.InternalContext.ExecuteSqlQueryAsIEnumerable(String sql, Object[] parameters) +85 System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery(Type elementType, String sql, Object[] parameters) +260 System.Data.Entity.Internal.InternalSqlNonSetQuery.GetEnumerator() +34 System.Data.Entity.Internal.InternalSqlQuery1.GetEnumerator() +28 System.Linq.Enumerable.FirstOrDefault(IEnumerable
1 source) +220 SPADash.Controllers.AccountsController.checkLogin(usrlogin cred) +151 lambda_method(Closure , ControllerBase , Object[] ) +127 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +242 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +39 System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +12 System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +139 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +112 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +452 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +15 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +37 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +241 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29 System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) +111 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +74 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +19 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51 System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) +111 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
[EntityException:底层提供程序在Open上失败。] System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition,DbConnection storeConnectionToOpen,DbConnection originalConnection,String exceptionCode,String attemptsOperation,Boolean&closeStoreConnectionOnFailure)+10948975 System.Data.EntityClient.EntityConnection.Open ()+136 System.Data.Objects.ObjectContext.EnsureConnection()+91 System.Data.Objects.ObjectContext.ExecuteStoreQueryInternal(String commandText,String entitySetName,MergeOption mergeOption,Object [] parameters)+109 System.Data.Objects.ObjectContext .ExecuteStoreQuery(String commandText,Object [] parameters)+87 System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery(String sql,Object [] parameters)+118 System.Data.Entity.Internal.InternalContext.ExecuteSqlQueryAsIEnumerable(String sql, Object [] parameters)+85 System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery(Type elementType,String sql,Object [] parameters)+260 S ystem.Data.Entity.Internal.InternalSqlNonSetQuery.GetEnumerator()+34 System.Data.Entity.Internal.InternalSqlQuery1.GetEnumerator()+28 System.Linq.Enumerable.FirstOrDefault(IEnumerable1 source)+220 SPADash.Controllers.AccountsController.checkLogin (usrlogin cred)+151 lambda_method(Closure,ControllerBase,Object [])+127 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary2 parameters)+242 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext,ActionDescriptor actionDescriptor,IDictionary2参数)+39 System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult,ActionInvocation innerInvokeState)+12 System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult)+139 System.Web.Mvc。 Async.AsyncInvocationWithFilters。
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34212
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.34212
1 个解决方案
#1
1
Ok, let's try, change the applicaton pool identity from "AppPoolIdentity" to either "LocalSystem" or "NetworkService". See if this makes the issue go away
好的,让我们尝试将应用程序池标识从“AppPoolIdentity”更改为“LocalSystem”或“NetworkService”。看看这是否会使问题消失
to change it go to run >> inetmgr and press enter
更改它去运行>> inetmgr并按Enter键
you should see your iis console .
你应该看到你的iis控制台。
on your left hand you can see application pool click on it by mouse and on your right hand on screen you can see set application pool default click on it it will pop up anew window with many properties go for identity and choose localsystem or network service and if you chose local service user account on machine make sure you give the local service permission on your published folder
在你的左手边你可以看到应用程序池通过鼠标点击它,在屏幕右边你可以看到设置应用程序池默认点击它会弹出一个新窗口,其中有许多属性用于标识并选择本地系统或网络服务如果您在计算机上选择本地服务用户帐户,请确保您在已发布的文件夹上授予本地服务权限
#1
1
Ok, let's try, change the applicaton pool identity from "AppPoolIdentity" to either "LocalSystem" or "NetworkService". See if this makes the issue go away
好的,让我们尝试将应用程序池标识从“AppPoolIdentity”更改为“LocalSystem”或“NetworkService”。看看这是否会使问题消失
to change it go to run >> inetmgr and press enter
更改它去运行>> inetmgr并按Enter键
you should see your iis console .
你应该看到你的iis控制台。
on your left hand you can see application pool click on it by mouse and on your right hand on screen you can see set application pool default click on it it will pop up anew window with many properties go for identity and choose localsystem or network service and if you chose local service user account on machine make sure you give the local service permission on your published folder
在你的左手边你可以看到应用程序池通过鼠标点击它,在屏幕右边你可以看到设置应用程序池默认点击它会弹出一个新窗口,其中有许多属性用于标识并选择本地系统或网络服务如果您在计算机上选择本地服务用户帐户,请确保您在已发布的文件夹上授予本地服务权限