I am using vs2010 + blend4 for Dongdong, because I am writing code on vs, blend is engaged in the interface, and after vs2010 completes the code, it suddenly crashes to blend and blend4 is re-opened, or even restarting the system.
Error Page:
Error output
Microsoft Expression crash report:
Date: 2010-08-24 17-16-43
User: ThinkPad @ THINKPAD-PC
Application version: 4.0.1000.1000
Operating system version: Microsoft Windows NT 6.1.7600.0
Common Language Runtime version: 4.0.30319.1
System. unauthorizedaccessexception: Invalid cross-thread access.
In Ms. Internal. xcpimports. checkthread ()
In Ms. Internal. xcpimports. createobjectbytypeindex (uint32 typeindex)
In system. Windows. Threading. dispatchertimer .. ctor (uint32 nativetypeindex)
In system. Windows. Threading. dispatchertimer .. ctor ()
In system. Windows. Threading. Dispatcher .. ctor ()
In system. Windows. Threading. Dispatcher. get_maindispatcher ()
In system. Windows. dependencyobject. get_dispatcher ()
At the position of Vega. toolbar. <. ctor> B _ 0 (Object OBJ ............................... XAML. CS: row number 21
In system. Threading. _ timercallback. timercallback_context (object state)
In system. Threading. executioncontext. Run (executioncontext, contextcallback callback, object state, Boolean ignoresyncctx)
In system. Threading. _ timercallback. Wait mtimercallback (object state)
............
Because there is no problem in vs2010 and compilation works well, it is regarded as a blend problem. Then, I deleted some newly added code and blend won't crash, finally, I confirmed the error code.
New timer (OBJ => This. Dispatcher. begininvoke () => this.txt time. Text = datetime. Now. tolongtimestring (), null, 0, 1000 );
Did I use the trendy syntax? I changed it to this and tried again.
New timer (OBJ =>{ this. Dispatcher. begininvoke () => this.txt time. Text = datetime. Now. tolongtimestring () ;}, null, 0, 1000 );
Still crash. Try again:
New timer (New timercallback (
OBJ =>{ this. Dispatcher. begininvoke () => this.txt time. Text = datetime. Now. tolongtimestring ());}
), Null, 0, 1000 );
Try again:
New timer (New timercallback (delegate (Object OBJ)
{This. Dispatcher. begininvoke () => this.txt time. Text = datetime. Now. tolongtimestring ());}
), Null, 0, 1000 );
I am about to crash. Try again:
New timer (New timercallback (delegate (Object OBJ)
{
This. Dispatcher. begininvoke () => this.txt time. Text = datetime. Now. tolongtimestring ());
}), Null, 0, 1000 );
Try again
New timer (New timercallback (delegate (Object OBJ)
{
This. Dispatcher. begininvoke (delegate ()
{
This.txt time. Text = datetime. Now. tolongtimestring ();
});
}), Null, 0, 1000 );
At this point, I'm sure it has nothing to do with Lambda expressions, and it should have nothing to do with anonymous delegation. I also found a detail, and it's okay if I deregister this line of code, however, restoring the code will crash after a lifetime of Project creation, and then try again.
New timer (OBJ => This. Dispatcher. begininvoke () => this.txt time. Text = datetime. Now. tolongtimestring (), null, 1000,100 0 );
This is a good change. I think blend is to pre-run the compiled DLL, but if the timer is executed immediately, blend is not ready yet, and a multi-thread exception occurs.