我的網絡主機有故障。現在終於重新開始了,我還不知道技術人員修復了什麼。 問題是,現在我收到的錯誤:實體框架在關閉數據傳遞器時調用「讀取」
Calling 'Read' when the data reader is closed is not a valid operation.
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.InvalidOperationException: Calling 'Read' when the data reader is closed is not a valid operation.
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:
[InvalidOperationException: Calling 'Read' when the data reader is closed is not a valid operation.]
System.Data.Common.Internal.Materialization.Shaper`1.StoreRead() +93
System.Data.Common.Internal.Materialization.SimpleEnumerator.MoveNext() +30
System.Linq.Enumerable.Single(IEnumerable`1 source) +119
System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__2(IEnumerable`1 sequence) +5
System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable`1 query, Expression queryRoot) +25
System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +43
System.Linq.Queryable.Count(IQueryable`1 source) +240
BusinessLayer.Car.GetCarCount() in xxx
UserControls_SiteInfo.Page_Load(Object sender, EventArgs e) +225
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
我沒有改變任何東西,所以它可能會有一些權限?我仍然可以使用相同的憑據登錄到我的數據庫,因此它不是登錄信息。任何人有想法?
更新:我發現當我嘗試將IQuery轉換爲列表時,出現錯誤。我以前從來沒有收到過錯誤,這是否給了你們任何線索可能是錯誤的線索?
當您執行直接SQL查詢時會發生什麼? (不使用LINQ到SQL) – 2009-06-15 15:16:12
我發現它是我的數據庫或與我的網絡主機的網絡錯誤,所以它與實體框架本身無關。 – Dofs 2009-06-17 07:45:09
將IEnumerable改爲IList解決了我的問題 我從一個sproc中返回了一個複雜的對象 – safhac 2010-02-19 08:14:03