Code/C#
[C#] 에러 해결 An object reference is required for the non-static field, method, or property Dispatcher.BeginInvoke
codens
2020. 2. 1. 15:59
WPF 프로그램을 WinForm으로 변경시 비동기 쓰레드 함수에서 문제 발생하는 경우
* 문제의 소스
private void BrowserView_OnFrameLoadEnd(object sender, FrameLoadEndEventArgs e)
{
Dispatcher.BeginInvoke((Action) (async () =>
* 에러 메시지
An object reference is required for the non-static field, method, or property Dispatcher.BeginInvoke(Delegate, params object
* 해결 방법
- Reference 추가
Solution Explorer -> References -> 우클릭 Add Reference -> WindowBase
- 소스 추가
using System.Windows.Threading;
- 소스 변경
Dispatcher.BeginInvoke
-> Dispatcher.CurrentDispatcher.BeginInvoke
반응형