2013-12-09 155 views
17

我看到了很多有关此错误的问题。但没有一个与形式有关。我在本地测试后托管了我的应用程序服务器。我认为它工作了几分钟,但我不确定,因为我可能已经看了一会儿localhost标签。然后它停止工作。当我在服务器上进行更改时,我可能已经改变了一些东西。“系统找不到指定的文件”

我检查了我的连接字符串,并尝试使用其他方式登录到数据库,它在线。所以,任何线索可能是错的。我不认为有可能sql服务器只响应来自应用程序的请求,并且如果您通过SSMS登录则可用。

下面是我得到的错误。

Server Error in '/' Application.

The system cannot find the file specified

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.

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified

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.

Stack Trace:

[Win32Exception (0x80004005): The system cannot find the file specified]

[SqlException (0x80131904): 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction) +5296071 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5308555
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +920
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +307
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) +434
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +225
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +37
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) +558
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions) +67
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1052
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +167
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 retry, DbConnectionOptions userOptions) +143
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource 1 retry) +83 System.Data.SqlClient.SqlConnection.Open() +96
System.Data.SqlClient.SqlProviderServices.UsingConnection(SqlConnection sqlConnection, Action
1 act) +79
System.Data.SqlClient.SqlProviderServices.UsingMasterConnection(SqlConnection sqlConnection, Action`1 act) +384
System.Data.SqlClient.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +241
System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +26

[ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.]
System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +170
System.Web.Providers.ModelHelper.GetStorageMetadata(String providerName, DbConnection connection, String ssdl) +35
System.Web.Providers.ModelHelper.CreateMetadataWorkspace(String providerName, DbConnection connection, String csdl, String ssdl, String msl) +154
System.Web.Providers.ModelHelper.CreateEntityConnection(ConnectionStringSettings setting, String csdl, String ssdl, String msl) +109
System.Web.Providers.ModelHelper.CreateMembershipEntities(ConnectionStringSettings setting) +28
System.Web.Providers.DefaultMembershipProvider.GetPasswordWithFormat(String userName, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& format, String& salt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +118
System.Web.Providers.DefaultMembershipProvider.CheckPassword(String userName, String password, Boolean updateLastActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +81
System.Web.Providers.DefaultMembershipProvider.ValidateUser(String username, String password) +105
System.Web.Security.Membership.ValidateUser(String username, String password) +26 Staff.Web.Account.Login.OnAuthenticate(Object sender, AuthenticateEventArgs e) in c:\Assembla\SVN\servicesdue\Staff.Web\Staff.Web\Account\Login.aspx.cs:28 System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +9449786 System.Web.UI.WebControls.Login.AttemptLogin() +119
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +75 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +114
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +159
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18055

有人也有过这样的错误,他们说,他们使用了错误的店来连接到数据库,因此错误。我的代码中只有一家商店。没有其他。

更新:

我发现了这个问题。它与会员有关。有些东西与我的会员连接字符串不符。但我不知道是什么。我的应用需要注册才能启用身份验证。我只保留了默认设置。还在App_Data文件夹中发布了mdf文件。 这里有一个类似的问题:Deploying ASP.NET membership to Godaddy。但解决方案并不明确,答案已标出。我加入了 连接字符串和我看到的错误

The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.

所以,我应该怎么办?这个会员资格在当地是完美无缺的。

更新:

我也试过这是什么人建议Godaddy ASP.NET membership database woes。我删除了conn字符串,并添加了名称“LocalSqlServer”,以使Godaddy快乐。然后我删除并添加以下这个connectionStringName - DefaultProfileProvider,DefaultMembershipProvider,DefaultRoleProvider和DefaultSessionProvider。仍然得到相同的系统错误找不到指定的文件。

+0

web.config中的'defaultConnectionFactory'是什么?我也可能有同样的问题,我相信它与defaultConnectionFactory –

+0

我遇到了几个问题,并解决了所有问题。不知道它是什么,但它与defaultConnectionFactory没有任何关系。我认为这个错误是我在配置中拥有TrustedConnection = true的地方。 – strider

回答

21

与SQL Server建立连接时发生网络相关或实例特定的错误。服务器未找到或无法访问。文字

一般发出这样的涉及到以下任何需要被看:

  • 防火墙设置从Web服务器到数据库服务器
  • 连接字符串错误
  • 启用适当的协议管道/ tcp-ip

尝试使用SQL管理服务器在安装了sql server的系统上连接到sql server并从那里工作。注意错误日志中的信息。

+0

看来我不能在生产服务器上使用.mdf文件。 SQL服务器需要配置成员资格。我想这就是问题所在。 – strider

+0

标记为答案,因为这非常接近我的实际问题。 – strider

+0

@strider我们有类似的问题?你的案子有什么问题? –

7

将我的项目发布到物理服务器后出现相同的错误。当我在VS2013上编译时,我的web应用程序在我的电脑上完美工作。当我在sql server manager上检查连接字符串时,在服务器上的所有东西都可以正常工作。我也检查过防火墙(我把它关掉了)。但仍然没有工作。我远程尝试通过SQL管理器连接数据库,使用完全相同的用户名/密码和实例名称等与协议pipe/tcp,我看到一切正常工作。但是当我尝试打开网站时,我收到了这个错误。有没有人知道解决这个问题的第四个选择?

注:我的应用程序:ASP.NET 4.5 (by VS2013),服务器:Windows 2008 R2 64bit,SQL:MS-SQL WEB 2012 SP1 另外其他Web应用程序在web浏览器的伟大工程,与他们在同一服务器上的数据库。


1天的痛苦后,我发现我的问题的解决:

首先,我检查了所有的日志和其他细节,但我能找到什么。突然我意识到这一点;当我尝试使用直接连接到已发布数据库的连接字符串并通过VS2013在我的计算机上运行应用程序时,我看到它正在连接另一个数据库文件。我查了本地目录,然后找到它。 ASP.NET身份不会像我在web.config文件中写的那样使用我的连接字符串。并且因为这个VS2013正在App_Data文件夹中创建或连接一个名为“DefaultConnection.mdf”的新数据库。然后我找到了解决方案,它在IdentityModel.cs

我改变了代码如下:

public class ApplicationUser : IdentityUser 
{ 
} 

public class ApplicationDbContext : IdentityDbContext<ApplicationUser> 
{ 
    //public ApplicationDbContext() : base("DefaultConnection") ---> this was original 
    public ApplicationDbContext() : base("<myConnectionStringNameInWebConfigFile>") //--> changed 
    { 
    } 
} 

所以,毕竟,我重新建造并发表我的项目,现在一切工作正常:)

+0

您是如何获得替代连接字符串的?以某种方式从Azure门户访问?哪里? –

+0

我一直在用我发布的应用程序间歇性地收到这个错误。我检查了ApplicationDbContext,它是不正确的。我做出了适当的修改,并且正确无误。再次,它是间歇性的(我会假设它会与这样的错误一致),但希望我不会再次得到这个错误。 谢谢 –

-1

最常见的原因可能是数据库连接串。您必须更改连接字符串attachDBFile = | DataDirectory | file_name.mdf。 主机名可能存在问题,它可能是(local),localhost或。\ sqlexpress。

1

如果您在部署.Net MVC Web应用程序后在GoDaddy中遇到此错误,并且您的web.config绝对正确...右键单击您的数据项目选择设置并确保GoDaddy的连接字符串正确服务器在使用中

+0

谢谢,你的小评论帮助我很多 – Moshii

0

Server Error in '/' Application.

The system cannot find the file specified

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.

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified

Source Error:

 { 
        SqlCommand cmd = new SqlCommand("select * from tblemployee",con); 
        con.Open(); 
        GridView1.DataSource = cmd.ExecuteReader(); 
        GridView1.DataBind(); 

Source File: d:\C# programs\kudvenkat\adobasics1\adobasics1\employeedata.aspx.cs Line: 23

如果你的错误是同样喜欢mine..just做到这一点

右键单击在SQLServer对象资源管理器的表,在那里一般选择左下角选择属性 是与服务器的连接块和连接specification.in你的网络配置为datasource =。或本地选择服务器在属性中指定的名称..

1

我有同样的问题 - 对我来说,这是SQL Server内存不足。释放一些内存解决了这个问题

+0

Yeap。这也适用于我。 – kord

0

我得到这个错误,当我启动我的ASP.NET应用程序,在我的情况下,问题是SQL Server服务没有运行。开始清理它。

0

启动SQL Server代理,这应该解决您的问题

0

考虑到一个的LocalDB实例只用于在开发使用。 LocalDb不适用于生产服务器部署最终结果时。

我觉得你的连接字符串指向的LocalDB实例,你需要采取一定的措施,把它变成了SQL Server数据库。这不仅仅是复制mdf文件的问题。它可能会有所不同,从一个托管公司到另一个,但通常情况下,您需要创建现有数据库(.bak文件)的备份,然后将其恢复到托管公司的SQL Server。您应该问他们在哪里可以找到有关将数据库部署到生产环境的说明。

相关问题