简体   繁体   English

IIS 7.5下的SQL Express

[英]SQL Express under IIS 7.5

I´m developing a web service that access a SQL Express database, it works very well in the Visual Studio host but when i deploy it to IIS 7.5 i get this exception. 我正在开发一种访问SQL Express数据库的Web服务,它在Visual Studio主机中可以很好地工作,但是当我将其部署到IIS 7.5时会遇到此异常。

Please help me. 请帮我。

Stack Trace: 堆栈跟踪:

System.Data.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, 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)
   --- End of inner exception stack trace ---
   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.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at WSCinema.CinemaService.Movie() in D:\Documents\My Dropbox\Projects\sd.v0910\trab3\code\WSCinema\CinemaService.asmx.cs:line 46

The account that your app's application pool in IIS is running as needs write access to the App_Data folder where your database file (mdf) is stored. IIS中应用程序的应用程序池正在运行的帐户需要对存储数据库文件(mdf)的App_Data文件夹具有写权限。 Eg if the app pool is configured to run as Network Service, give permissions to that account on App_Data folder. 例如,如果将应用程序池配置为作为网络服务运行,请在App_Data文件夹中为该帐户授予权限。

When you run in the VS host your app is running as your user account which has access to App_Data. 当您在VS主机中运行时,您的应用程序将以您具有访问App_Data权限的用户帐户运行。

You are using RANU, SQL Express user instances. 您正在使用RANU,SQL Express用户实例。 See more details about them at SQL Server 2005 Express Edition User Instances . SQL Server 2005 Express Edition用户实例中查看有关它们的更多详细信息。 RANU creates a new instance for each user connecting to the original SQL Express instance, and the new user instance runs under the user credentials. RANU为连接到原始SQL Express实例的每个用户创建一个新实例,新用户实例在用户凭据下运行。 In this case, it will create an user instance under the ASP AppPool identity, and trying to create this user instance hits the error: 在这种情况下,它将在ASP AppPool标识下创建一个用户实例,并且尝试创建此用户实例会遇到错误:

Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. 由于检索用户的本地应用程序数据路径失败,因此无法生成SQL Server用户实例。 Please make sure the user has a local user profile on the computer. 请确保用户在计算机上具有本地用户配置文件。

So, if you insist on using user instances, make sure the app pool identity has a profile on the IIS host. 因此,如果您坚持使用用户实例,请确保应用程序池标识在IIS主机上具有配置文件。 But it would be way more beneficial and easier if you abandon user instances, just use the SQL Express instance directly. 但是,如果您放弃用户实例,而直接使用SQL Express实例,则将更加有益和轻松。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CropZoom无法使用IIS 7.5,但可以使用IIS 7.5 Express - CropZoom not working with IIS 7.5 but works with IIS 7.5 Express IIS Express 7.5 wwwroot 目录在哪里 - Where is IIS Express 7.5 wwwroot Directory 设置应用程序池iis express 7.5用于应用程序 - Set application pool iis express 7.5 for application 在IIS 7.5下进行调试时,构建的程序集与源不匹配的问题 - Problem with built assembly not matching source when debugging under IIS 7.5 DirectoryServicesCOMException 80072020来自IIS 7.5在ApplicationPoolIdentity下运行的站点 - DirectoryServicesCOMException 80072020 From IIS 7.5 Site Running Under ApplicationPoolIdentity IIS 7.5下的SignalR Move Shape演示中未定义客户端属性? - client property undefined in SignalR Move Shape demo under IIS 7.5? 如何正确授予IIS 7.5 Express上的文件夹的权限 - How to grant rights properly to a folder on IIS 7.5 Express 在IIS 7.5 Express中使用ASP.Net Preloader - Using ASP.Net Preloader in IIS 7.5 Express 在 IIS 7.5 下工作的 web.config 在 IIS 10 下不起作用 - web.config that worked under IIS 7.5 doesn't work under IIS 10 使用表达式语法(&lt;%$%&gt;)时,ASP.NET本地化在IIS Express中工作,但在IIS7.5中不工作 - ASP.NET Localization working in IIS Express but not in IIS7.5 when using expression syntax (<%$ %>)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM