0

I am writing a WPF C# application and I'm using entity framework 6.0. I use LINQ to run a query on a remote database and it returns an IQueryable. When I try to iterate over the return, the program crashes even in debug mode. For some reason, the debugger cannot catch it. This is the code that is throwing the error:

var schedules = context.Schedules.Where(s => s.Username == username);
                foreach (var schedule in schedules)

The output window shows:

The thread 0x4174 has exited with code 0 (0x0).
The program '[6128] EniproTutors.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

What could the problem be with the code?

7
  • Is 'schedules' returning a null? Is context null?
    – jdweng
    May 29, 2016 at 13:46
  • Any unsafe code? An AV is only possible with unsafe code or with a CLR bug.
    – usr
    May 29, 2016 at 13:47
  • @jdweng no, schedules isn't null or empty May 29, 2016 at 13:50
  • @usr Only managed code, no unmanaged blocks May 29, 2016 at 13:50
  • Create an executable program that demonstrates the issue. I don't think it's possible to resolve this otherwise. You can then use that program to report the bug.
    – usr
    May 29, 2016 at 13:52

1 Answer 1

0

I have been able to work around it. The good thing I had going for me was that the table Schedules was empty, so I created another table with the same schema, added it to the model and removed the schedules table. It stopped crashing after that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.