|
Alas, I got work with the beautiful Entity Framework. As I'm trying to copy the exception details
System.ObjectDisposedException was unhandled
HResult=-2146232798
Message=Die ObjectContext-Instanz wurde verworfen und kann nicht mehr für Vorgänge verwendet werden, für die eine Verbindung erforderlich ist.
ObjectName=""
Source=EntityFramework
StackTrace:
bei System.Data.Entity.Core.Objects.ObjectContext.get_Connection()
bei System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
bei System.Data.Entity.Core.Objects.DataClasses.EntityCollection`1.Load(List`1 collection, MergeOption mergeOption)
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__DisplayClass7`2.<GetInterceptorDelegate>b__1(TProxy proxy, TItem item)
bei System.Data.Entity.DynamicProxies.Abstimmungungswochen_4B2170BEEFBCB0E3760C0A28F933A214FEE1AF613CEA6B3CD7752FA43966F7F3.get_Stimmzettel()
bei SuisseVote.Business.DomainModel.Urnengang..ctor(Abstimmungungswochenende a) in C:\Workspaces\SuisseVote\SwissVote\SuisseVote-2_1_Update_3_Happy Feet\SuisseVote.Business.DomainModel\Urnengang.cs:Zeile 57.
bei SuisseVote.Business.Shared.Repository.UrnengangRepository.<>c.<GetListAll>b__6_0(Abstimmungungswochenende c) in C:\Workspaces\SuisseVote\SwissVote\SuisseVote-2_1_Update_3_Happy Feet\SuisseVote.Business.Shared\Repository\UrnengangRepository.cs:Zeile 35.
bei System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
bei System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
bei System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
bei SuisseVote.Business.Shared.Repository.UrnengangRepository.GetListAll() in C:\Workspaces\SuisseVote\SwissVote\SuisseVote-2_1_Update_3_Happy Feet\SuisseVote.Business.Shared\Repository\UrnengangRepository.cs:Zeile 35.
bei SuisseVote.Business.Center.Repository.UrnengangRepository.GetListAll() in C:\Workspaces\SuisseVote\SwissVote\SuisseVote-2_1_Update_3_Happy Feet\SuisseVote.Business.BusinessLayer\Repository\UrnengangRepository.cs:Zeile 86.
bei SuisseVote.Ui.Center.OpenUrnengangControl.UserControl_Loaded(Object sender, RoutedEventArgs e) in C:\Workspaces\SuisseVote\SwissVote\SuisseVote-2_1_Update_3_Happy Feet\SwissVote\Urnengang\OpenUrnengangControl.xaml.cs:Zeile 40.
bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
bei System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
bei System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
bei MS.Internal.LoadedOrUnloadedOperation.DoWork()
bei System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
bei System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
bei System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
bei System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
bei System.Windows.Interop.HwndTarget.OnResize()
bei System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
InnerException:
to the Google, they inform me of performing an illegal request.
Why is MS now also breaking other company's stuff?
|
|
|
|
|
It has nothing to do with MS. Google search is rejecting your query because the search text is too large. But you probably knew that.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: But you probably knew that.
I did
|
|
|
|
|
Looks like the exception handling is sub-optimal.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
They are far more chance that the problem is in your own code... An object seems to be disposed twice! Maybe your connection? Maybe your code does not properly handle some events that occurs in a way you did not expect?
Philippe Mori
|
|
|
|
|
OK, time for a random guess of what your code looks like:
public Foo GetFoo(int id)
{
using (var context = new YourDbContext())
{
return context.Foos.FirstOrDefault(foo => foo.Id == id);
}
}
...
Foo foo = GetFoo(42);
Bar bar = foo.Bar;
You've retrieved an entity instance without loading any of its related entities. You've then disposed of the DbContext before trying to load a related entity. The lazy-loading proxy that EF created for your entity is then trying to load the related entity from the database, using the previously-disposed DbContext .
You can either turn off lazy loading, in which case the navigation property will return null ; or you can explicitly load the related entities before you dispose of the DbContext ; or you can use the Include extension method to eagerly load the related entities at the same time as the main entity.
Entity Framework Loading Related Entities[^]
And now, you've managed to sneak a programming question into the Lounge!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I just joined this forum, so wanted to say hi! sorry if this is the wrong place for introductions, I'm new here so still figuring out how it all works!
|
|
|
|
|
Hello new!
I am not a number. I am a ... no, wait!
|
|
|
|
|
Haha .. well my name is Jade. I am looking to start a career in working for web hosting companies, and wanted to join this forum to do some research
I have an interview next week ...
|
|
|
|
|
Plenty to look at here!
Search[^] is a good place to start.
But...you'd probably be best off if you start by researching the company you are interviewing for, not the subject. Find out what they do, what they use, and how that relates to your experience and knowledge. Then use research to brush up your knowledge - but never to pretend you are experienced in stuff you don't know! That way may get you through the interview, but it won't let you keep the job once it becomes apparent you know little or nothing....
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
This is the right place. Sit back awhile and tell us about yourself.
This space for rent
|
|
|
|
|
Welcome New
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello, I'm old (but young at heart!)
Tell us about yourself! What inspired you to join?
Marc
|
|
|
|
|
Welcome New, and don't feed the trolls animals.
I'd rather be phishing!
|
|
|
|
|
New, is that a German name?
Welcome.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Welcome to CodeProject!
/ravi
|
|
|
|
|
Hmmm I wrote a reply but I don't think it got posted ...
Anyway, I'm Jade. I am hoping to start a career working for web hosting companies and wanted to join this forum to do some research.
I have an interview next week ... eeek
modified 27-Jun-16 9:34am.
|
|
|
|
|
It was intercepted by the automated spam system and required human intervention.
We don't like spam here, and the system sometimes makes mistakes - as in this case. I let it through.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi and welcome and I won't call you New.
Kitty at my foot and I waAAAant to touch it...
|
|
|
|
|
Power Puff Boy wrote: and I won't call you New. Well that's a new response.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Hello new, it's good to be introduced to a serious operator!
Yes, I make terrible jokes.
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani
|
|
|
|
|
Where was your coat?
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Very far - 34° C. I'd peel away my very skin.
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani
|
|
|
|