c# error(2): Cross-thread operation not valid

12/08/2009 at 13:58 | In programming | 1 Comment
Tags: ,

Cross-thread operation not valid: Control ‘textbox1′ accessed from a thread other than the thread it was created on.

error นี้หาอ่านแล้ว งงมาก พอจับใจความได้ว่าเป็นเรื่องของ thread วิธีแก้ที่เจอส่วนใหญ่จะให้สร้าง delegate ขึ้นมาซึ่งทำให้ งงกว่าเดิมมากๆๆ

จนสุดท้ายไปเจออีกวิธีคือใช้ CheckForIllegalCrossThreadCalls = false; เอาไว้ข้างหน้าก่อนที่จะให้ thread ทำงานบรรทัดเดียวจบข่าว

credit :
http://www.thaidev.com/board1/view.php?id=1546&bn=board_csc

http://www.programmersheaven.com/mb/csharp/309997/309997/cross-thread/

http://dev.mobixo.net/2008/07/cross-thread-operation-not-valid.html

http://bytes.com/topic/c-sharp/answers/567801-cross-thread-operation-not-valid

http://stackoverflow.com/questions/142003/cross-thread-operation-not-valid-control-accessed-from-a-thread-other-than-the-t

C# namespace could not be found

11/08/2009 at 20:07 | In programming | Leave a Comment
Tags: ,

วันนี้พยายามจะหัดเขียน C# เพื่อใช้ทำโปรเจคเจอหลาย Error มาก ลงอันที่น่าจะลืมง่ายสุดไว้กันลืมซักหน่อย

The type or namespace name ‘WinPcapNET’ could not be found (are you missing a using directive or an assembly reference?)

สาเหตุerrorนี้ คือหา reference ไม่เจอวิธีแก้ก็ตามนี้
1.คลิกขวาที่ references ตรงแถบ solution explorer
2.เลือก add references
3.ลองหาชื่อ reference ที่หายไป ในทุกแถบ ถ้าไม่เจอก็ browse หาอาจจะเป็นตัว .dll ก็ได้
4.Okay เสร็จ

บลอกที่ WordPress.com . | Theme: Pool by Borja Fernandez.
Entries and comments feeds.