클래식 MIDLRT에서 MIDL 3.0으로 전환

MIDLRT는 MIDL 2.0이라고도 합니다. MIDL 1.0, 2.0 및 3.0을 참조하세요.

MIDL 3.0은 클래식 MIDLRT와 동일한 소스 파일에 공존할 수 있습니다. IDL 파일을 한 번에 변환할 필요는 없습니다. MIDL 3.0을 사용하고 있음을 표현하기 위해 새 컴파일러 옵션이 필요하지 않습니다. 기존 /winrt 옵션을 사용하면 클래식 MIDLRT와 MIDL 3.0을 모두 사용할 수 있습니다.

기존 MIDLRT 형식에 MIDL 3.0 콘텐츠를 추가할 수 있습니다. 특히 MIDL 3.0을 사용하여 MIDLRT에서 작성된 런타임 클래스 정의에 추가되는 인터페이스를 정의할 수 있습니다. 이렇게 하면 형식 또는 파일을 완전히 변환할 필요 없이 새 기술을 사용할 수 있습니다. 예를 들면 다음과 같습니다.

// Existing RTIDL interface definition.
[contract(FooContract, 1), exclusiveto(SampleClass), uuid(...)]
interface ISampleClass : IInspectable
{
    HRESULT Method1([in] boolean something, [in] HSTRING other);
}

// New MIDL 3.0 interface added; needs exclusiveto(), but not uuid().
[contract(FooContract, 2), exclusiveto(SampleClass)]
interface ISampleClass2
{
    Windows.Foundation.IAsyncOperation<String> TransformAsync(UInt32 count);
    String NameProperty { get; };
}

[contract(FooContract, 1)]
runtimeclass SampleClass
{
    [default] interface ISampleClass;
    // Reference to MIDL 3.0-defined interface.
    [contract(FooContract, 2)] interface ISampleClass2;
}

기존 MIDLRT 런타임 클래스 정의에 MIDL 3.0 구문을 추가하면 다음과 같은 오류가 발생합니다.

1>midl : error MIDL9008 : internal compiler problem - See documentation for suggestions on how to find a workaround.
errors in directory t:\compdev1\src\mincore\coreui\published\idl
t:\compdev1\src\midl : error MIDL9008 : internal compiler problem - See documentation for suggestions on how to find a workaround.
1>midl: Assertion failed: pN->NodeKind() == NODE_INTERFACE_GROUP_MEMBER, file com\rpc\midl\midlrt\front\nodeskl.cxx, line 1403
1>NMAKE : fatal error U1077: 't:\compdev1\src\tools\x86\midl.EXE' : return code '0x2330'

전체 클래스를 MIDL 3.0으로 변환하거나 위의 기술에서 새 인터페이스를 추가하고 클래스에 추가하는 방법으로 이 문제를 해결합니다.