Share via


RCW를 InterfaceIsIInspectable 인터페이스로 캐스팅하면 PlatformNotSupportedException이 throw됨

InterfaceIsIInspectable로 표시된 인터페이스로 RCW(런타임 호출 가능 래퍼)를 캐스팅하면 이제 PlatformNotSupportedException이 throw됩니다. 이 변경 내용은 .NET에서 WinRT 지원 제거에 따른 후속 조치입니다.

도입된 버전

.NET 5

변경 내용 설명

이전 .NET 버전에서는 InterfaceIsIInspectable로 표시된 인터페이스로 RCW를 캐스팅하면 예상대로 작동했습니다. .NET 5부터 InterfaceIsIInspectable로 표시된 인터페이스로 RCW를 캐스팅하면 캐스팅 시간에 PlatformNotSupportedException이 throw됩니다.

변경 이유

InterfaceIsIInspectable에 대한 지원이 제거되었습니다. 런타임에서 기본 지원이 더 이상 존재하지 않으므로 PlatformNotSupportedException을 throw하여 정상적인 실패 경로를 지원합니다. 또한 예외를 throw하여 기능이 더 이상 지원되지 않음을 더 쉽게 검색할 수 있게 합니다.

  • Windows 런타임 메타데이터(WinMD) 파일에서 인터페이스를 정의할 수 있는 경우에는 C#/WinRT 도구를 대신 사용합니다.

  • 그렇지 않은 경우에는 인터페이스를 InterfaceIsIInspectable 대신 InterfaceIsIUnknown으로 표시하고, InterfaceIsIInspectable 메서드의 인터페이스 시작 부분에 더미 항목 3개를 추가합니다. 다음 코드 조각은 예제를 보여 줍니다.

    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    interface IMine
    {
        // Do not call these three methods.
        // They're exclusively to fill in the slots in the vtable.
        void GetIIdsSlot();
        void GetRuntimeClassNameSlot();
        void GetTrustLevelSlot();
    
        // The original members of the IMine interface go here.
        ...
    }
    

영향을 받는 API