2011-08-29 114 views
0

我正在使用實體數據模型連接到數據庫。它在當地很好地工作。當我上傳我的網站服務器時,它引發以下錯誤:實體數據模型System.ArgumentOutOfRangeException

Server Error in '/' Application. 
Non-negative number required. 
Parameter name: count 
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.ArgumentOutOfRangeException: Non-negative number required. 
Parameter name: count 

Source Error: 

Line 14:    //Fill the Route collection here. 
Line 15:    routes.Clear(); 
Line 16:    foreach (var page in context.PageInfos) 
Line 17:    { 
Line 18:     //get the friendly URL 


Source File: e:\HostingSpaces\homelink\dev.homelinkfamilysupport.org\wwwroot\Global.asax Line: 16 

Stack Trace: 

[ArgumentOutOfRangeException: Non-negative number required. 
Parameter name: count] 
    System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count) +0 
    System.Data.SqlClient.TdsParserStateObject.ReadByteArray(Byte[] buff, Int32 offset, Int32 len) +153 
    System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean& marsCapable) +173 
    System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +473 
    System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129 
    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +164 
    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195 
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232 
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185 
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33 
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524 
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 
    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479 
    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108 
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126 
    System.Data.SqlClient.SqlConnection.Open() +125 
    System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +52 

[EntityException: The underlying provider failed on Open.] 
    System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +161 
    System.Data.EntityClient.EntityConnection.Open() +98 
    System.Data.Objects.ObjectContext.EnsureConnection() +81 
    System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +46 
    System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44 
    ASP.global_asax.RegisterRoutes(RouteCollection routes) in e:\HostingSpaces\homelink\dev.homelinkfamilysupport.org\wwwroot\Global.asax:16 
    ASP.global_asax.Application_Start(Object sender, EventArgs e) in e:\HostingSpaces\homelink\dev.homelinkfamilysupport.org\wwwroot\Global.asax:7 


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

服務器上的數據庫肯定具有完全相同的結構和數據,因爲它是從原來的.bak文件(恢復從中電火花生成)。

對此的任何幫助將不勝感激。

回答

1

爲了參考:這是由於我的託管服務提供商更改了我必須用來連接到SQL服務器的端口。與代碼無關。