성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
[정성태] 저렇게 조각 코드 말고, 실제로 재현이 되는 예제 프로젝트를 압...
[정성태] Modules 창(Ctrl+Shift+U)을 띄워서, 해당 Op...
[정성태] 만드실 수 있습니다. 단지, Unity 엔진 내의 스크립트와 W...
[공진영] 안녕하세요 좋은글 감사합니다. 현재 제가 wpf로 관제 모...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>Win32 핸들 관련 CLR4 보안 오류 사례</h1> <p> 만약, CLR4 보안 모델에서 APTCA 환경인 경우,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > .NET CLR4 보안 모델 - 3. CLR4 보안 모델에서의 APTCA 역할 ; <a target='tab' href='http://www.sysnet.pe.kr/2/0/1682'>http://www.sysnet.pe.kr/2/0/1682</a> </pre> <br /> System.Security.SecuritySafeCritical 특성을 지정하지 않는다면 다음과 같은 식의 예외가 발생할 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > System.MethodAccessException was caught HResult=-2146233072 Message=Attempt by method 'Microsoft.Win32.NamedPipe.CreateClient(System.String, Microsoft.Win32.PipeDirection)' to access method 'Microsoft.Win32.NamedPipe.CreateFile(System.String, UInt32, UInt32, IntPtr, UInt32, UInt32, IntPtr)' failed. Source=Jennifer5 StackTrace: at Microsoft.Win32.NamedPipe.CreateClient(String pipeName, PipeDirection direction) at MyApp.Test(String exePath) InnerException: </pre> <br /> 또한 NamedPipe I/O 관련해서 비동기로 메서드를 작성하는 경우,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using (ManualResetEvent completed = new ManualResetEvent(false)) { FileStream fsStream = _pipeStream; _pipeStream.BeginWrite(sendBuffer, 0, sendBuffer.Length, <span style='color: blue; font-weight: bold'>(ar) => { try { fsStream.EndWrite(ar); } catch { } if (completed.SafeWaitHandle.IsClosed == false) { completed.Set(); } }</span> WaitHandle.WaitAny(new WaitHandle[] { completed, _exitEvent }, maxWaitMillisecond, false); } </pre> <br /> 람다 메서드 안에서 SafeWaitHandle 속성 접근 시 다음과 같은 예외가 발생하게 됩니다.<br /> <br /> <div style='BACKGROUND-COLOR: #ccffcc; padding: 10px 10px 5px 10px; MARGIN: 0px 10px 10px 10px; FONT-FAMILY: Malgun Gothic, Consolas, Verdana; COLOR: #005555'> System.MethodAccessException occurred<br /> HResult=-2146233072<br /> Message=Attempt by security transparent method 'Microsoft.Win32.NamedPipe+<>c__DisplayClassa.<WriteString>b__7(System.IAsyncResult)' to access security critical method 'System.Threading.WaitHandle.get_SafeWaitHandle()' failed.<br /> <br /> Assembly 'TestDll, Version=5.0.5.0, Culture=neutral, PublicKeyToken=...' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.<br /> Source=Jennifer5<br /> StackTrace:<br /> at Microsoft.Win32.NamedPipe.<>c__DisplayClassa.<WriteString>b__7(IAsyncResult ar)<br /> InnerException: <br /> </div><br /> <br /> 이런 경우, 람다 메서드에는 System.Security.SecuritySafeCritical 특성을 지정할 수 없으므로 별도의 메서드로 정의하는 수고를 감내해야 합니다.<br /> <br /> 참고로, System.MethodAccessException 예외 뿐만 아니라 System.FieldAccessException 같은 예외도 발생할 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > System.FieldAccessException occurred HResult=-2146233081 Message=Attempt by method 'Microsoft.Win32.NamedPipe.Close()' to access field 'Microsoft.Win32.NamedPipe._pipeHandle' failed. Source=TestDll StackTrace: at Microsoft.Win32.NamedPipe.Close() InnerException: </pre> <br /> 정리해 보면, "CLR4 보안 모델 + APTCA" 환경에서 System.MethodAccessException, System.FieldAccessException과 같은 식의 ...AccessException 예외가 발생한다면 System.Security.SecuritySafeCritical 특성 지정을 고려하시면 됩니다.<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1935
(왼쪽의 숫자를 입력해야 합니다.)