성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
[정성태] 저렇게 조각 코드 말고, 실제로 재현이 되는 예제 프로젝트를 압...
[정성태] Modules 창(Ctrl+Shift+U)을 띄워서, 해당 Op...
[정성태] 만드실 수 있습니다. 단지, Unity 엔진 내의 스크립트와 W...
글쓰기
제목
이름
암호
전자우편
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'>Visual Studio 2022부터 DTE.get_Properties 속성 접근 시 System.MissingMethodException 예외 발생</h1> <p> 현재 이 문제는 Microsoft.VisualStudio.SDK 17.0.31902.203 버전으로 업그레이드 후 해결되었습니다.<br /> <br /> <strike> 2019 버전까지 잘 동작하던 아래의 코드가,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Property property = dte.DTE.get_Properties("TextEditor", "PlainText").Item("IndentStyle"); // 또는 Property property = dte.DTE.Properties["TextEditor", "PlainText"].Item("IndentStyle"); </pre> <br /> 2022 버전에서 (예외 정도가 아니라) crash가 발생합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Log Name: Application Source: Application Error Date: ... Event ID: 1000 Task Category: (100) Level: Error Keywords: Classic User: N/A Computer: ... Description: Faulting application name: devenv.exe, version: 17.0.31410.414, time stamp: 0x9a994a46 Faulting module name: KERNELBASE.dll, version: 10.0.19041.1023, time stamp: 0x924f9cdb Exception code: 0xe0434352 Fault offset: 0x0000000000034b89 Faulting process id: 0x56fc Faulting application start time: 0x01d764426e58bfe9 Faulting application path: C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\devenv.exe Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll Report Id: b4986db0-b5ff-4082-b479-ab498b66b309 Faulting package full name: Faulting package-relative application ID: </pre> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Log Name: Application Source: .NET Runtime Date: ... Event ID: 1026 Task Category: None Level: Error Keywords: Classic User: N/A Computer: ... Description: Application: devenv.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.MissingMethodException <span style='color: blue; font-weight: bold'>at TestExtension.Utility+<SetTextAsync>d__11.MoveNext()</span> at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon ByRef) at TestExtension.Utility.SetTextAsync(EnvDTE80.DTE2, Microsoft.VisualStudio.Shell.AsyncPackage, EnvDTE.TextSelection, System.String) at TestExtension.TestCommand+<Action_InsertAsync>d__9.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at TestExtension.TestCommand+<CallAsync>d__25.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at TestExtension.TestCommand+<MenuItemCallback>d__14.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) </pre> <br /> <a target='tab' href='https://docs.microsoft.com/en-us/dotnet/api/system.missingmethodexception'>MissingMethodException 예외</a>가 힘든 것은, 해당 메서드가 위치한 라인을 알려주는 것이 아니라 그것을 포함한 메서드만을 알려주기 때문입니다. 그래서 어떤 메서드의 부재로 예외가 발생하는지 알 길이 없습니다. 이걸 알려면 디버거를 걸거나, print 식 디버깅을 해야 합니다.<br /> <br /> <hr style='width: 50%' /><br /> <br /> 그런데 문제를 알아도 이런 식으로 수정하면 안 됩니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > void SetTextAsync() { Property property = null; Version version = new Version(dte.Version); if (version.Major <= 16) // 2019 이하 버전에서만 코드 실행! { property = dte.DTE.Properties["TextEditor", "PlainText"].Item("IndentStyle"); } } </pre> <br /> 왜냐하면, if 문에 상관없이 (문제가 발생한 메서드인) SetTextAsync를 JIT 컴파일할 때 MissingMethodException 예외가 발생하기 때문입니다. 따라서, 해당 코드를 JIT 순간에 방해가 되지 않도록 별도의 메서드로 분리해내야 합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > void SetTextAsync() { Property property = null; Version version = new Version(dte.Version); if (version.Major <= 16) // 2019 이하 버전에서만 코드 실행 { property = GetIndentStyle(dte); } } private static Property GetIndentStyle(DTE2 dte) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); return dte.DTE.Properties["TextEditor", "PlainText"].Item("IndentStyle"); } </pre> <br /> <hr style='width: 50%' /><br /> <br /> 검색해 보면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Missing EnvDTE Properties for Debugging -> Symbols ; <a target='tab' href='https://developercommunity.visualstudio.com/t/missing-envdte-properties-for-debugging-symbols/193262'>https://developercommunity.visualstudio.com/t/missing-envdte-properties-for-debugging-symbols/193262</a> </pre> <br /> 동일한 증상인데, <br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > EnvDTE.DTE dte = ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; dte.Properties["Debugging", "General"].Item("EnableJustMyCode").Value = true; </pre> <br /> "Debugging" 부분은 별도로 IVsDebuggerSymbolSettings120A / IVsDebuggerSymbolSettingsManager120A 인터페이스로 기능을 대체한 듯합니다. 이 글에서 문제가 된 TextEditor도 대체 인터페이스가 있을 듯한데 글쎄요... 테스트해 봐야 알겠지만 아래의 정도가 후보군이 될 수 있겠군요.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > LanguagePreferences.IndentStyle Property ; <a target='tab' href='https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.package.languagepreferences.indentstyle'>https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.package.languagepreferences.indentstyle</a> </pre> </strike> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1324
(왼쪽의 숫자를 입력해야 합니다.)