Base solution for your next web application
Open Closed

Error publishing to IIS #249


User avatar
0
hans abelshausen created

Hi, I published my project to my server, but if I try to start it, the following error occured, but I don't know a solution: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection


5 Answer(s)
  • User Avatar
    0
    daws created

    This error is too much generic to help us understand :)

    Can you provide the error contained in your log file ? (stored in your app folder)

    It's propably somewhere in your code where you call the database (or a dataset retrieved from the database) and that you are out of the unit of work (context of db).

    Is is just happening when publish in IIS, or also in debug mode on your desktop ? Are you sure your db provider on the IIS machin is well configured ?

  • User Avatar
    0
    hans abelshausen created

    Sorry for my short question. I'm trying to unterstand the error. The error occurs in my debug mode too, but somewhere else. In my console the following error appears (I have intgegrated module Zero. Something with getting users seems to be the error): exceptionMessage: "The 'ObjectContent1' type failed to serialize the response body for content type 'application/json; charset=utf-8'." exceptionType: "System.InvalidOperationException" innerException: Object exceptionMessage: "Error getting value from 'CreatorUser' on 'System.Data.Entity.DynamicProxies.User_4730030EBB16241189B87A85A8706EE27908E7C722E1DAFA1C3B46C6AEC5217E'." exceptionType: "Newtonsoft.Json.JsonSerializationException" innerException: Object exceptionMessage: "The ObjectContext instance has been disposed and can no longer be used for operations that require a connection." exceptionType: "System.ObjectDisposedException" message: "An error has occurred." stackTrace: " bei System.Data.Entity.Core.Objects.ObjectContext.get_Connection() ↵ bei System.Data.Entity.Core.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) ↵ bei System.Data.Entity.Core.Objects.ObjectQuery1.Execute(MergeOption mergeOption) ↵ bei System.Data.Entity.Core.Objects.DataClasses.EntityReference1.Load(MergeOption mergeOption) ↵ bei System.Data.Entity.Core.Objects.DataClasses.RelatedEnd.Load() ↵ bei System.Data.Entity.Core.Objects.DataClasses.RelatedEnd.DeferredLoad() ↵ bei System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.LoadProperty[TItem](TItem propertyValue, String relationshipName, String targetRoleName, Boolean mustBeNull, Object wrapperObject) ↵ bei System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.<>c__DisplayClass72.<GetInterceptorDelegate>b__2(TProxy proxy, TItem item) ↵ bei System.Data.Entity.DynamicProxies.User_4730030EBB16241189B87A85A8706EE27908E7C722E1DAFA1C3B46C6AEC5217E.get_CreatorUser() ↵ bei GetCreatorUser(Object ) ↵ bei Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)" proto: Object message: "An error has occurred."

  • User Avatar
    0
    hikalkan created
    Support Team

    It seems that you're returning Entity from application service. You should return DTOs. You can read the docs: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Data-Transfer-Objects">http://www.aspnetboilerplate.com/Pages/ ... er-Objects</a>

  • User Avatar
    0
    hans abelshausen created

    Hi! You are right, the last error occurs, because I have used the entity. But on the server, the login is not shown instead of, this error occurs:

  • User Avatar
    0
    hikalkan created
    Support Team

    Can you share your code?