共用方式為


從傳統 MIDLRT.EXE 根據轉換到 MIDL 3。0

MIDLRT.EXE 根據也稱為 MIDL 2.0。 請參閱 MIDL 1.0、2.0 和 3.0

MIDL 3.0 可以與傳統 MIDLRT.EXE 根據並存于相同的原始檔中;您不需要一次將 IDL 檔案轉換成全部。 不需要新的編譯器選項,就能表示您使用的是 MIDL 3.0。 現有 /winrt 選項會啟用傳統 midlrt.exe 根據和 MIDL 3.0。

您可以將 MIDL 3.0 內容新增至現有的 MIDLRT.EXE 根據類型。 具體而言,您可以使用 MIDL 3.0 來定義加入至 MIDLRT.EXE 根據撰寫之執行時間類別定義的介面。 這可讓您使用新的技術,而不需要完整轉換類型或檔案。 以下為範例。

// 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;
}

將 MIDL 3.0 結構新增至現有的 MIDLRT.EXE 根據 runtimeclass 定義會產生如下的錯誤。

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,或透過上述技術將新介面加入至類別。