Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
(연관된 글이 2개 있습니다.)

WPF - .NET 3.5 이하에서 TextBox에 한글 입력 시 TextChanged 이벤트의 비정상 종료 문제

다음과 같은 질문이 있군요.

WPF .net 3.5에서 TextBox 한글 문제
; https://www.sysnet.pe.kr/3/0/4831

위의 문제에 대한 재현은 간단합니다. 기본 생성된 WPF 프로젝트의 MainWindow.xaml에 다음과 같이 TextBox를 하나 얹고,

<TextBox Text="TextBox" TextChanged="TextBox_TextChanged"/>

TextBox_TextChanged 이벤트에 MessageBox를 띄우게 코딩한 후,

private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
    MessageBox.Show("TEST");
}

실행 시에 TextBox에 한글을 입력하게 되면 다음과 같은 예외가 발생하거나,
System.InvalidOperationException occurred
  HResult=0x80131509
  Message=There is no registered CultureInfo with the IetfLanguageTag 'ug'.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

Inner Exception 1:
ArgumentException: Culture name 'ug' is not supported.

아니면 다음과 같이 간단한 debug 로그만 남긴 체 응용 프로그램이 비정상 종료해 버립니다.

The program '[8296] WpfApp1.exe' has exited with code -1073740940 (0xc0000374).
The program '[8296] WpfApp1.exe: Program Trace' has exited with code 0 (0x0).

사실, "There is no registered CultureInfo with the IetfLanguageTag 'ug'." 예외 메시지는 몇몇 환경에서 나타나는 부가적인 메시지일 뿐 설령 그 오류 메시지를 해결한다 해도 결국에는 0xc0000374 (Heap Corruption Exception) 예외를 발생하며 비정상 종료를 해버립니다.

이벤트 로그에도 역시 간단한 메시지만 남게 되어 도대체 이게 무슨 현상인가 싶을 정도입니다. ^^;

Log Name:      Application
Source:        .NET Runtime
Date:          2017-05-17 오전 12:32:44
Event ID:      1023
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      TESTPC
Description:
.NET Runtime version 2.0.50727.8784 - Unrecoverable system error.

Log Name:      Application
Source:        Windows Error Reporting
Date:          2017-05-17 오전 12:41:35
Event ID:      1001
Task Category: None
Level:         Information
Keywords:      Classic
User:          N/A
Computer:      TESTPC
Description:
Fault bucket , type 0
Event Name: CLR20r3
Response: Not available
Cab Id: 0

Problem signature:
P1: wpfapp1.exe
P2: 1.0.0.0
P3: 591b1c8a
P4: WindowsBase
P5: 3.0.0.0
P6: 58dbbc47
P7: df
P8: 0
P9: FatalError
P10: 




이 문제를 사실 어떻게 해결해야 할지 모르겠습니다. ^^;

일단, 가장 권장되는 방법은 .NET 4.0으로 올리는 것입니다. 또는 3.5로 개발되었다고 해도 4.0이 설치된 PC에서는 CLR 4.0에서 실행되도록 다음과 같이 app.config을 조정해 주는 것입니다.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0.30319"/>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

그렇다면 3.5 이하의 .NET Framework이 설치된 곳에서는 어떻게 해야 할까요? 이렇게 되면 약간의 꼼수를 써야 하는데요. 제가 생각해 낸 그나마 가장 우아한 방법은 Dispatcher.BeginInvoke를 이용하는 것이었습니다.

private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
    this.Dispatcher.BeginInvoke( (Action)(
        () => {
            MessageBox.Show("TEST");
        }), null);
}

혹시 다른 방법을 알고 계신 분은 덧글 부탁드립니다. ^^

(첨부 파일은 이 글의 예제 코드를 포함합니다.)




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 5/17/2017]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 



2017-05-17 01시24분
[김신철] 항상 많은 정보 알려주셔서 감사합니다~ 큰 도움이 될것같습니다 ^^
[guest]

... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12198정성태3/17/202011714오류 유형: 609. SQL 서버 접속 시 "Cannot open user default database. Login failed."
12197정성태3/17/202010870VS.NET IDE: 144. .NET Core 콘솔 응용 프로그램을 배포(publish) 시 docker image 자동 생성 - 두 번째 이야기 [1]
12196정성태3/17/20208820오류 유형: 608. The ServicedComponent being invoked is not correctly configured (Use regsvcs to re-register).
12195정성태3/16/202010517.NET Framework: 902. C# - 프로세스의 모든 핸들을 열람 - 세 번째 이야기
12194정성태3/16/202012857오류 유형: 607. PostgreSQL - Npgsql.NpgsqlException: sorry, too many clients already
12193정성태3/16/20209517개발 환경 구성: 485. docker - SAP Adaptive Server Enterprise 컨테이너 실행 [1]
12192정성태3/14/202011979개발 환경 구성: 484. docker - Sybase Anywhere 16 컨테이너 실행
12191정성태3/14/202012318개발 환경 구성: 483. docker - OracleXE 컨테이너 실행 [1]
12190정성태3/14/20208514오류 유형: 606. Docker Desktop 업그레이드 시 "The process cannot access the file 'C:\Program Files\Docker\Docker\resources\dockerd.exe' because it is being used by another process."
12189정성태3/13/202013323개발 환경 구성: 482. Facebook OAuth 처리 시 상태 정보 전달 방법과 "유효한 OAuth 리디렉션 URI" 설정 규칙
12188정성태3/13/202015504Windows: 169. 부팅 시점에 실행되는 chkdsk 결과를 확인하는 방법
12187정성태3/12/20208257오류 유형: 605. NtpClient was unable to set a manual peer to use as a time source because of duplicate error on '...'.
12186정성태3/12/20209347오류 유형: 604. The SysVol Permissions for one or more GPOs on this domain controller and not in sync with the permissions for the GPOs on the Baseline domain controller.
12185정성태3/11/20209989오류 유형: 603. The browser service was unable to retrieve a list of servers from the browser master...
12184정성태3/11/202011457오류 유형: 602. Automatic certificate enrollment for local system failed (0x800706ba) The RPC server is unavailable. [3]
12183정성태3/11/20209795오류 유형: 601. Warning: DsGetDcName returned information for \\[...], when we were trying to reach [...].
12182정성태3/11/202011043.NET Framework: 901. C# Windows Forms - Vista/7 이후의 Progress Bar 업데이트가 느린 문제파일 다운로드1
12181정성태3/11/202011879기타: 76. 재현 가능한 최소한의 예제 프로젝트란? - 두 번째 예제파일 다운로드1
12180정성태3/10/20208476오류 유형: 600. "Docker Desktop for Windows" - EXPOSE 포트가 LISTENING 되지 않는 문제
12179정성태3/10/202019865개발 환경 구성: 481. docker - PostgreSQL 컨테이너 실행
12178정성태3/10/202011341개발 환경 구성: 480. Linux 운영체제의 docker를 위한 tcp 바인딩 추가 [1]
12177정성태3/9/202011020개발 환경 구성: 479. docker - MySQL 컨테이너 실행
12176정성태3/9/202010437개발 환경 구성: 478. 파일의 (sha256 등의) 해시 값(checksum) 확인하는 방법
12175정성태3/8/202010519개발 환경 구성: 477. "Docker Desktop for Windows"의 "Linux Container" 모드를 위한 tcp 바인딩 추가
12174정성태3/7/202010064개발 환경 구성: 476. DockerDesktopVM의 파일 시스템 접근 [3]
12173정성태3/7/202011060개발 환경 구성: 475. docker - SQL Server 2019 컨테이너 실행 [1]
... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...