static 클래스가 있는데 Initialize함수로 명시적 초기화를 하고 있다. 이 클래스의 함수를 다른 static 클래스의 생성자에서 호출하면 the type initializer for threw an exception등의 원인 파악이 힘든 오류 발생


1. 가능하면 static 클래스/생성자 사용하지 말자
2. 어쩔 수 없이 쓰더라도 수동초기화 하는 정적 클래스의 함수는 호출하지 않기
3. static 생성자는 항상 예외처리하여 vs ouput창에 trace log남기기

'library > .NET' 카테고리의 다른 글

예외처리  (0) 2019.06.27
Panel Resets Scroll Position after Focus is Lost and Regained  (0) 2012.10.06
wcf 프로젝트 설정  (0) 2011.09.05
블로그 이미지

란마12

,

예외처리

library/.NET 2019. 6. 27. 12:31
  1. 꼭 필요한 경우에만 예외를 잡자.
  2. 예외를 연속적으로 던져버리고 싶다면(스택추적정보를 깨뜨리지 않고) throw를 사용하자.
  3. 잡은 예외에 뭔가 더해서 던지고 싶다면 항상 inner exception으로 original exception을 전달하자.
    예) throw new ApplicationException("operation failed!", ex);

'library > .NET' 카테고리의 다른 글

static 클래스 초기화 주의  (0) 2020.08.13
Panel Resets Scroll Position after Focus is Lost and Regained  (0) 2012.10.06
wcf 프로젝트 설정  (0) 2011.09.05
블로그 이미지

란마12

,

블랙홀 이미지

yonjh 2019. 5. 16. 15:00

https://youtu.be/uyMtsyzXWd4?t=370

블로그 이미지

란마12

,



3,000만원의 금융소득

1) 2,000만원의 사업소득금액이 있는 경우

 금융소득 중 2,000만원을 초과하는 1,000만원에 대해서 사업소득금액에 합산하여 누진세율이 적용

 세율구간이 16.5%(지방소득세 포함)이므로 이미 원천징수 된 15.4%(지방소득세 포함)의 세율과 비교해 그 차이인 1.1%(지방소득세 포함)

 1,000만원의 금융소득에 대해 11만원의 세금

2) 사업소득금액이 1억원인 경우

 누진세율 38.5%(지방소득세 포함)를 적용

 금융소득 중 2,000만원을 초과하는 1,000만원에 대해서도 38.5%(지방소득세 포함) 세율이 적용

 금융소득에 대해서만 231만원(38.5%-15.4%)의 세금이 추가로 발생

'yonjh > 재테크' 카테고리의 다른 글

펀드투자  (0) 2015.06.05
저축  (0) 2013.08.20
임대주택의 전환보증금  (0) 2013.06.11
마이너스 통장  (0) 2013.03.04
블로그 이미지

란마12

,

(멀티바이트->유니코드->TCHAR)


strcpy -> wcscpy -> _tcscpy (문자열을 복사)

strncpy -> wcsncpy -> _tcsncpy ( 사이즈 만큼 복사)

strlen -> wcslen -> _tcslen (문자열 길이 확인)

strcat -> wcscat -> _tcscat (두 문자열 이어 붙이기)

strncat -> wcsncat -> _tcsncat (사이즈 만큼 이어 붙이기)

strcmp -> wcscmp -> _tcscmp (문자열 비교) (반환 값(-1, 0, 1))

strncmp -> wcsncmp -> _tcsncmp ( 사이즈 만큼 문자열 비교)

stricmp -> wcsicmp -> _tcsicmp (대소문자를 구별하지 않고 문자열을 비교)

strnicmp -> wcsnicmp -> _tcsnicmp (사이즈 만큼 대소문자를 구별하지 않고 문자열을 비교)

strchr -> wcschr -> _tcschr (문자 찾기)

strrchr -> wcsrchr -> _tcsrchr (문자 찾기 (문자열 끝에서 부터 검색))

strstr -> wcsstr -> _tcsstr (문자열 찾기)

strpbrk -> wcspbrk -> _tcspbrk (문자 찾기 (두번째 인수를 찾고자 하는 문자들의 집합(문자열)으로 구성)

strtok -> wcstok -> _tcstok (문자열 자르기 (두번째 인수를 집합(문자열)으로 구성 가능)) => 해당 문자가 NULL로 치환 됨

strset -> wcsset -> _tcsset (문자 치환, 첫째 인수의 모든 문자를 두번째 인수 문자로 변경함) => "abc" -> "bbb"

strnset -> wcsnset -> _tscnset (사이즈 만큼 문자 치환)

strupr -> wcsupr -> _tcsupr (대문자로 치환)

strlwr -> wcslwr -> _tcslwr (소문자로 치환)

strrev -> wcsrev -> _tcsrev (문자열 역정렬) => "가나다라마" -> "마라다나가"



출처: http://mrhook.co.kr/202 [Mr. 후크의 잡동사니]

블로그 이미지

란마12

,

송곳

yonjh/영화 2018. 5. 10. 13:59



'yonjh > 영화' 카테고리의 다른 글

Wild Horses  (0) 2015.07.27
블로그 이미지

란마12

,

Exceptions

language/C# 2017. 8. 21. 21:28

1. 모든 함수에 try~catch 처리 하지 말자.


2. 모든 thread 진입 함수에서 반드시 try~catch 처리


3. main thread 시작지점에서 unhandled exception 처리


  Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);

  AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

  Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);


 //main thread exception

 static void Application_ThreadException(object sender, ThreadExceptionEventArgs e){

   try { ... }

   catch { ... }

   finally reportErrLog(); }

 }


 //other thread exception

 static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e){

   try { ... }

   catch { ... }

   finally 

     reportErrLog(); 

     Application.Exit(); //다른 스레드는 continue할 수 없다. 무조건 종료처리.

   }

 }


블로그 이미지

란마12

,

"파일경로" 파일을 "xxx.exe"(으)로 복사할 수 없습니다. 'xxx.exe' 파일은 다른 프로세스에서 사용 중이므로 프로세스에서 액세스할 수 없습니다. 


VS 버그인듯...


빌드전 이벤트에 추가


if exist "$(TargetPath).locked" del "$(TargetPath).locked"

if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

if exist "$(TargetDir)$(TargetName).pdb.locked" del "$(TargetDir)$(TargetName).pdb.locked"

if exist "$(TargetDir)$(TargetName).pdb" if not exist "$(TargetDir)$(TargetName).pdb.locked" move "$(TargetDir)$(TargetName).pdb" "$(TargetDir)$(TargetName).pdb.locked"

블로그 이미지

란마12

,

EventLog el = new EventLog("Application");

el.Source = "my_src_name";

el.WriteEntry("오류 메시지", EventLogEntryType.Error);


다음과 같은 오류 발생

Security Exception

 Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.

Source Error:

[No relevant source lines]


Source File: c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\license\3ebadbd0\51884812\App_Web_2wv6qvf1.0.cs    Line: 0

Stack Trace:

[SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.]
....


해결방법

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog -> NETWORK SERVICE user에 Full Control 퍼미션 추가

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\my_src_name 키 직접 추가

블로그 이미지

란마12

,

IIS8에 PHP설치 삽질기

web 2015. 8. 21. 16:30

1. MS에서 간단히 설치지원해준다.

 1) http://www.microsoft.com/web/downloads/platform.aspx (웹 플랫 폼설치 관리자)

 2) Free Download 클릭 후 실행하고 상단에서 제품탭을 클릭 후 검색창에 PHP로 검색

 3) 최신 버전 선택 후 추가버튼 누르고 하단에 설치버튼 클릭


2. PHP 5.5.11버전을 설치했는데 PHP파일 소스가 그대로 보이는 문제 발생

 1) php.ini파일에서 short_open_tag = On 설정 바꾸고 웹서비스 재시작해도 소용없음.

 2) PHP설치 하면 IIS관리자에 PHP Manager라는 항목이 생긴다.

 3) PHP Manager에서 php.ini의 항목들을 설정할 수 있는데

    PHP Settings의 하위항목 중 Manage all settings를 클릭하여 설정창을 연다.

 4) short_open_tag 항목을 On으로 바꿔도 소용없다.

    다시 자세히 보니 short_open_tag항목이 두개가 있고 한놈이 Off로 설정되어 있다?

    On으로 바꿔도 바뀌질 않는다.

    Off로 설정된 항목을 삭제해버리니 해결됨.(버그인가?.. 뭔가 재시작을 확실히 안해서 그런 느낌.. 아마 OS재시작 했으면 됐을 지도...)

 5) 기본적으로 PHP오류 발생 시 브라우저에 오류내용이 표시되지 않는다.

    개발환경에서는 디버깅을 위해 필수로 보여져야 하므로 display_errors항목을 On으로 바꾼다.

블로그 이미지

란마12

,