0

考慮到下面的類,在調用home/index(這實際上是內部異常)時,在Visual Studio中啓動網站時出現以下錯誤。ObjectContext Dev中出錯但未發佈時

A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 0 - The handle is invalid.)

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) 
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) 
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() 
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error) 
at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj) 
at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket() 
at System.Data.SqlClient.TdsParserStateObject.ReadBuffer() 
at System.Data.SqlClient.TdsParserStateObject.ReadByte() 
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) 
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() 
at System.Data.SqlClient.SqlDataReader.get_MetaData() 
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) 
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) 
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) 
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) 
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) 
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) 
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) 
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) 

但是,如果我在本地發佈完全相同的代碼,並使用WebMatrix中擊中的部位,它工作正常。

我正在使用SQL Server 2008 Express,如果這樣做有所作爲。請告知是否需要更多信息。

控制器

public class HomeController : BaseController 
{ 
    public ActionResult Index() 
    { 
     var candidates = BusinessObj.AllOf<Candidate>().ToList(); 
     return View(candidates); 
    } 
} 

BaseController

public class BaseController : Controller 
{ 
    protected ITestBusinessObject BusinessObj { get; set; } 

    public BaseController() 
    { 
     BusinessObj = new Business.TestBusinessObj(); 
    } 
} 

TestBusinessObj(實體是一個EF EDMX類)

public class TestBusiness : ITestBusinessObject 
{ 
    private Entities DB = new Entities(); 
    private string ContainerName = "Entities"; 

    public IEnumerable<T> AllOf<T>() where T : class, new() 
    { 
     return DB.CreateObjectSet<T>(ContainerName.GetEntitySetName<T>()); 
    } 

    private static string GetEntitySetName<T>(this string containerName) where T : new() 
    { 
     var name = new T().GetType().Name; 
     if (name.EndsWith("y")) 
     { 
      name = name.Substring(0, name.Length - 1) + "ies"; 
     } 
     else 
     { 
      name = name + "s"; 
     } 
     return string.Format("{0}.{1}", containerName, name); 
    } 
} 
+0

可能是一個愚蠢的問題,但你是否因爲發生這個問題而重新啓動了你的機器? – Tommy

+0

@Tommy我有和令人沮喪的是,它再次工作。這是幾個小時,我不會回來.. – glosrob

+0

是的,當我做了一些周圍(並從個人經驗),似乎有時共享內存提供程序綁定一些後臺進程和重新啓動通常修復它。高興起來,再次工作。 – Tommy

回答

1

這開始了作爲註釋,因爲它是更建議比一個解決方案,但基於迴應,個人體驗與這看似隨意/每一個其他季度左右發生的本地事件以及互聯網搜索的結果,重新啓動似乎更多地解決了這個問題。

A transport-level error has occurred when receiving results from the server

http://www.garrypassarella.co.uk/2011/05/12/a-transport-level-error-has-occurred-when-receiving-results-from-the-server-provider-shared-memory-provider-error-0-the-handle-is-invalid/

http://www.soulsolutions.com.au/Blog/tabid/73/EntryId/666/A-transport-level-error-has-occurred.aspx

的共有圍繞存儲器管的共享特性爲中心並且陷入了一些其他後臺進程(ES),其導致錯誤,直到系統重新啓動。