I have a timer setup on a custom control that refreshes project numbers every 15 minutes. I started noticing that Visual Studio would randomly crash. Well, what seemed random, at the time, anyway. I started looking through the event logs and found that the timer on my control was executing. This was throwing an error due to a connection/entity framework lazy loading issue which then caused VS to crash.
Seeing that i'm using !this.DesignMode
below, what else can I do to keep this from running
Here's my timer_tick event:
private void timer_Tick(object sender, EventArgs e)
{
if (!this.DesignMode) {
LoadProjectNumbers();
}
}
Here's the exception text from the event log:
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException at
System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(System.Type)
at System.Data.Entity.Internal.Linq.InternalSet`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_InternalContext()
at System.Data.Entity.Infrastructure.DbQuery`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].System.Linq.IQueryable.get_Provider()
at System.Linq.Queryable.OrderByDescending[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Linq.IQueryable`1<System.__Canon>, System.Linq.Expressions.Expression`1<System.Func`2<System.__Canon,Int32>>)
at ACGICore.Controls.ProjectNumberSearch.LoadProjectNumbers()
at ACGICore.Controls.ProjectNumberSearch.timer_Tick(System.Object, System.EventArgs)
at System.Windows.Forms.Timer.OnTick(System.EventArgs)
at System.Windows.Forms.Timer+TimerNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr)