Question

I recently added a new field("Category") to a database table. Updated the model from Database. When I make a query and get a collection of this table I try to add a value to this field. I am not event saving it at this point. The program runs like it is in infinite loop. When I stop the debugger it is on the ReportPropertyChanged("Category") of the model designer code. If I step into code it goes into the Get portion of another field and just gets stuck in this Get loop - very strange. I have Cleaned/Rebuilt solution, deleted the model and reattached with the behavior remaining. I have successfully added fields in the past without this strange result, any ideas?

Winforms, EF 4.0.

Line of code (location of problem):

rec.Category = category 
Was it helpful?

Solution

It sounds that perhaps there is an event listener where you are inadvertently changing the property again.

Perhaps try setting a breakpoint in the setter of the generated code, as suggested by this answer https://stackoverflow.com/a/9005656/141022 to try and spot the loop.

And turning of step over properties in the visual studio debugger settings.

And perhaps removing the DebuggerStepThrough from the generated code temporarily (if it's there) to see if you can step into the property.

The linked answer (although not directly related) may give you some hints.

Perhaps the callstack might give you some hints as well, but I'm guessing it could be tricky to read if it's across threads.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top