当前位置:Gxlcms > 数据库问题 > 使用LocalDB部署Asp.Net MVC网站时遇到的问题

使用LocalDB部署Asp.Net MVC网站时遇到的问题

时间:2021-07-01 10:21:17 帮助过:21人阅读


Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local
Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.

经过搜索,在StackOverflow以及MSDN上都有相关的描述。主要是LocalDB与Full IIS应用不兼容,需要按照某一个补丁,进行额外设置。我不确定最新的IIS是否已经兼容,至少在Windows 2008 Serve R2上的IIS版本不兼容。在Using LocalDB with Full IIS, Part 1: User Profile[1]一问中有更加详细的描述。按照其Part1的设置,网站依然没有跑起来。在Windows 7 SP1 causes IntelliTrace Collection to fail on IIS[2]提到了不兼容的补丁信息,以及如何解决。

 

着急之下,直接在服务器上安装SQLServer Express。如果LocalDB不建议部署,准备直接迁移到Express。在一些参考上,又提到SQL Server Runtime,可能是没有安装Express的原因。安装完SQLServer Express,网站依然无法正常工作。在下载Express时,看到还有一个下载选项为CHS\x64\SqlLocalDB.msi 。可能此程序才是LocalDB的Runtime。遂卸载 SQLServer Express,安装SQlLocalDB。再次运行网站,错误信息变为如下:

//大概是这个意思
找不到SQLServer进程
无法启动实例

看来LocalDB还需要与SqlServer Express协同工作。安装好之后,再次启动网站,错误依旧。

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: 50 - Local Database Runtime error occurred. 在 LocalDB
实例启动期间出错: 无法启动 SQL Server 进程。 )

在[1][2]中提到还需要设置IIS的应程序池信息,之前没有改变是因为我以试用Administrator身份运行此程序。按照[1][2]的方法,增加应用程序池设置。

<add name="ASP.NET v4.0" autoStart="true" managedRuntimeVersion="v4.0">
    <processModel identityType="SpecificUser" userName="administrator" password="**********" loadUserProfile="true" setProfileEnvironment="true" />
</add>

本Web App主要进行服务器管理,与操作系统(Win32 Api)交互较多,部分Api需要很高权限。在以上设置中增加了loadUserProfile="true" setProfileEnvironment="true" ,赋予程序池读取用户配置、环境参数的能力。重新启动应用程序池,App正常运行。

回过头来看,如果要部署LocalDB到IIS 可以参考Deployment of SQL Express LocalDB on IIS[3]。就此次实践来说,大概要经过这么几部:

  1. 环境为Widnows 2008 R2
  2. 需要安装SQL Server Express,安装SqlLocalDB.
  3. 需要配置C:\Windows\System32\inetsrv\config\applicationHost.cof,赋予应用程序池读取用户数据、环境数据的信息。

 

 

参考:

[1]Using LocalDB with Full IIS, Part 1: User Profile, https://blogs.msdn.microsoft.com/sqlexpress/2011/12/08/using-localdb-with-full-iis-part-1-user-profile/

[2]Windows 7 SP1 causes IntelliTrace Collection to fail on IIS, https://support.microsoft.com/zh-cn/kb/2547655

[3]Deployment of SQL Express LocalDB on IIS, https://blogs.msdn.microsoft.com/gaurav/2013/12/21/deployment-of-sql-express-localdb-on-iis/

[3]Stack Overflow上的提问, http://stackoverflow.com/questions/26248293/sql-network-interfaces-error-50-local-database-runtime-error-occurred-canno

使用LocalDB部署Asp.Net MVC网站时遇到的问题

标签:找不到   权限   ble   environ   nec   conf   .com   相关   服务器   

人气教程排行