Şimdi Ara

mvc de json ile veri çekmeye çalışırken The ObjectContext... diye başlayan bir hata

Bu Konudaki Kullanıcılar:
2 Misafir (1 Mobil) - 1 Masaüstü1 Mobil
5 sn
4
Cevap
0
Favori
981
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • mvc ile proje yapmaya çalışıyorum fakat, controller dan json ile veri çekmeye çalışırken aşağıda bulunan hatayı alıyorum, bir kaç gündür bu hata ile uğraşıyorum, yardımcı olabilecek arkadaşlardan yardımını bekliyorum.

    Server Error in '/' Application.
    The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
    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.ObjectDisposedException: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

    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:
    [ObjectDisposedException: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.]
    System.Data.Entity.Core.Objects.ObjectContext.get_Connection() +5068841
    System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +111
    System.Data.Entity.Core.Objects.ObjectQuery`1.Execute(MergeOption mergeOption) +31
    System.Data.Entity.Core.Objects.DataClasses.EntityCollection`1.Load(List`1 collection, MergeOption mergeOption) +134
    System.Data.Entity.Core.Objects.DataClasses.EntityCollection`1.Load(MergeOption mergeOption) +30
    System.Data.Entity.Core.Objects.DataClasses.RelatedEnd.DeferredLoad() +350
    System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.LoadProperty(TItem propertyValue, String relationshipName, String targetRoleName, Boolean mustBeNull, Object wrapperObject) +85
    System.Data.Entity.Core.Objects.Internal.<>c__DisplayClass7`2.<GetInterceptorDelegate>b__1(TProxy proxy, TItem item) +105
    System.Data.Entity.DynamicProxies.Drink_977799A9D96F4849D97806A88CC82A460AC26664CDE09ADAAA50368E1D00FF40.get_FoodMenu() +75

    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
    System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
    System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
    System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101
    System.Web.SecurityUtils.MethodInfoInvoke(MethodInfo method, Object target, Object[] args) +162
    System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat) +749
    System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) +2751
    System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) +371
    System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable enumerable, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat) +186
    System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) +2699
    System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) +371
    System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat) +57
    System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat) +83
    System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj) +44
    System.Web.Mvc.JsonResult.ExecuteResult(ControllerContext context) +817
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +116
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +106
    System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +321
    System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185
    System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
    System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
    System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
    System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
    System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +37
    System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
    System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
    System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
    System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +37
    System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
    System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
    System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
    System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
    System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +37
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9644037
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155







  • Context classına bunu yaz kendikininkine ayarlayarak.

    LazyLoading olayı yüzünden context bağlantısı kopar memoryi yormamak için.




    public class YourContext : DbContext
    {
    public YourContext()
    {
    this.Configuration.LazyLoadingEnabled = false;
    }
    }
  • ilginiz için çok teşekkürler, fakat hocam başaramadım, yine aynı sorun devam ediyor, benim yapı sanırım sizin bahsettiğinizden farklı, Class a DbContent abstract class ekledim, veriyi list olarak döndürdüğüm method a da bahsettiğiniz kodları ekledim yine aynı sonuç çıktı.



    < Bu mesaj bu kişi tarafından değiştirildi emreyilmazer -- 27 Mayıs 2016; 12:21:57 >
  • using (EntityModel Context = EntityConnection)
  • Yapay Zeka’dan İlgili Konular
    Daha Fazla Göster
    
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.