Naruto Mouri
Naruto Mouri

Reputation: 31

I can't compile my project which uses C++/WinRT after upgrading to Windows 10, version 1809 SDK

When I upgrade the Windows SDK to 17763, I have found I can't compile my project and I get the error message is "midl : error MIDL9008: internal compiler problem - See documentation for suggestions on how to find a workaround.". Here is the output:

1>Note: The Microsoft.Windows.CppWinRT Nuget package provides improved C++/WinRT project build support.
1>64 bit MIDLRT Processing G:\NagisaRepositories\Nagisa\Assassin\CustomConverter.idl
1>CustomConverter.idl
1>64 bit MIDLRT Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\winrt\winrtbase.idl
1>winrtbase.idl
1>64 bit MIDLRT Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\winrt\midlbase.idl
1>midlbase.idl
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.ai.machinelearning.machinelearningcontract\1.0.0.0\windows.ai.machinelearning.machinelearningcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.ai.machinelearning.preview.machinelearningpreviewcontract\2.0.0.0\windows.ai.machinelearning.preview.machinelearningpreviewcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.calls.background.callsbackgroundcontract\1.0.0.0\windows.applicationmodel.calls.background.callsbackgroundcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.calls.callsphonecontract\4.0.0.0\windows.applicationmodel.calls.callsphonecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.calls.callsvoipcontract\4.0.0.0\windows.applicationmodel.calls.callsvoipcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.communicationblocking.communicationblockingcontract\2.0.0.0\windows.applicationmodel.communicationblocking.communicationblockingcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.socialinfo.socialinfocontract\2.0.0.0\windows.applicationmodel.socialinfo.socialinfocontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.startuptaskcontract\3.0.0.0\windows.applicationmodel.startuptaskcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.devices.custom.customdevicecontract\1.0.0.0\windows.devices.custom.customdevicecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.devices.deviceslowlevelcontract\3.0.0.0\windows.devices.deviceslowlevelcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.devices.printers.printerscontract\1.0.0.0\windows.devices.printers.printerscontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.devices.smartcards.smartcardbackgroundtriggercontract\3.0.0.0\windows.devices.smartcards.smartcardbackgroundtriggercontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.devices.smartcards.smartcardemulatorcontract\6.0.0.0\windows.devices.smartcards.smartcardemulatorcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.foundation.foundationcontract\3.0.0.0\windows.foundation.foundationcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.foundation.universalapicontract\7.0.0.0\windows.foundation.universalapicontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.gaming.xboxlive.storageapicontract\1.0.0.0\windows.gaming.xboxlive.storageapicontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.graphics.printing3d.printing3dcontract\4.0.0.0\windows.graphics.printing3d.printing3dcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.networking.connectivity.wwancontract\2.0.0.0\windows.networking.connectivity.wwancontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.networking.sockets.controlchanneltriggercontract\3.0.0.0\windows.networking.sockets.controlchanneltriggercontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.services.maps.guidancecontract\3.0.0.0\windows.services.maps.guidancecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.services.maps.localsearchcontract\4.0.0.0\windows.services.maps.localsearchcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.services.store.storecontract\4.0.0.0\windows.services.store.storecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.services.targetedcontent.targetedcontentcontract\1.0.0.0\windows.services.targetedcontent.targetedcontentcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.system.profile.profilehardwaretokencontract\1.0.0.0\windows.system.profile.profilehardwaretokencontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.system.profile.profilesharedmodecontract\2.0.0.0\windows.system.profile.profilesharedmodecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.system.profile.systemmanufacturers.systemmanufacturerscontract\3.0.0.0\windows.system.profile.systemmanufacturers.systemmanufacturerscontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.system.systemmanagementcontract\6.0.0.0\windows.system.systemmanagementcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.ui.viewmanagement.viewmanagementviewscalingcontract\1.0.0.0\windows.ui.viewmanagement.viewmanagementviewscalingcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.ui.xaml.core.direct.xamldirectcontract\1.0.0.0\windows.ui.xaml.core.direct.xamldirectcontract.winmd
1>64 bit MIDLRT Processing G:\NagisaRepositories\Nagisa\Assassin\TransferManager.idl
1>TransferManager.idl
1>64 bit MIDLRT Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\winrt\winrtbase.idl
1>winrtbase.idl
1>64 bit MIDLRT Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\winrt\midlbase.idl
1>midlbase.idl
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.ai.machinelearning.machinelearningcontract\1.0.0.0\windows.ai.machinelearning.machinelearningcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.ai.machinelearning.preview.machinelearningpreviewcontract\2.0.0.0\windows.ai.machinelearning.preview.machinelearningpreviewcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.calls.background.callsbackgroundcontract\1.0.0.0\windows.applicationmodel.calls.background.callsbackgroundcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.calls.callsphonecontract\4.0.0.0\windows.applicationmodel.calls.callsphonecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.calls.callsvoipcontract\4.0.0.0\windows.applicationmodel.calls.callsvoipcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.communicationblocking.communicationblockingcontract\2.0.0.0\windows.applicationmodel.communicationblocking.communicationblockingcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.socialinfo.socialinfocontract\2.0.0.0\windows.applicationmodel.socialinfo.socialinfocontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.applicationmodel.startuptaskcontract\3.0.0.0\windows.applicationmodel.startuptaskcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.devices.custom.customdevicecontract\1.0.0.0\windows.devices.custom.customdevicecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.devices.deviceslowlevelcontract\3.0.0.0\windows.devices.deviceslowlevelcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.devices.printers.printerscontract\1.0.0.0\windows.devices.printers.printerscontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.devices.smartcards.smartcardbackgroundtriggercontract\3.0.0.0\windows.devices.smartcards.smartcardbackgroundtriggercontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.devices.smartcards.smartcardemulatorcontract\6.0.0.0\windows.devices.smartcards.smartcardemulatorcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.foundation.foundationcontract\3.0.0.0\windows.foundation.foundationcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.foundation.universalapicontract\7.0.0.0\windows.foundation.universalapicontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.gaming.xboxlive.storageapicontract\1.0.0.0\windows.gaming.xboxlive.storageapicontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.graphics.printing3d.printing3dcontract\4.0.0.0\windows.graphics.printing3d.printing3dcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.networking.connectivity.wwancontract\2.0.0.0\windows.networking.connectivity.wwancontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.networking.sockets.controlchanneltriggercontract\3.0.0.0\windows.networking.sockets.controlchanneltriggercontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.services.maps.guidancecontract\3.0.0.0\windows.services.maps.guidancecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.services.maps.localsearchcontract\4.0.0.0\windows.services.maps.localsearchcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.services.store.storecontract\4.0.0.0\windows.services.store.storecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.services.targetedcontent.targetedcontentcontract\1.0.0.0\windows.services.targetedcontent.targetedcontentcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.system.profile.profilehardwaretokencontract\1.0.0.0\windows.system.profile.profilehardwaretokencontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.system.profile.profilesharedmodecontract\2.0.0.0\windows.system.profile.profilesharedmodecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.system.profile.systemmanufacturers.systemmanufacturerscontract\3.0.0.0\windows.system.profile.systemmanufacturers.systemmanufacturerscontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.system.systemmanagementcontract\6.0.0.0\windows.system.systemmanagementcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.ui.viewmanagement.viewmanagementviewscalingcontract\1.0.0.0\windows.ui.viewmanagement.viewmanagementviewscalingcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.17763.0\windows.ui.xaml.core.direct.xamldirectcontract\1.0.0.0\windows.ui.xaml.core.direct.xamldirectcontract.winmd
1>
1>midl : error MIDL9008: internal compiler problem - See documentation for suggestions on how to find a workaround.
1>midl: Assertion failed: false, file com\rpc\midl\midlrt\inc\nodeskl.hxx, line 4884

I have tried to address the problem, and I found it will compile successfully if I removed the definitions of interface. But I need these definitions because it is important. Here is the IDL definitions which I had removed.

/******************************************************************************
Project: Assassin
Description: Definition for the TransferManager.
File Name: TransferManager.idl
License: The MIT License
******************************************************************************/

namespace Assassin
{
    enum TransferTaskStatus
    {
        Canceled  = 0,
        Completed = 1,
        Error     = 2,
        Paused    = 3,
        Queued    = 4,
        Running   = 5
    };

    [version(1.0)]
    [uuid(B70ACDED-7354-3082-BF73-D931D80C047B)]
    interface ITransferTask : IInspectable
        requires Windows.UI.Xaml.Data.INotifyPropertyChanged
    {
        // Gets the Guid string of the task.
        String Guid
        {
            get;
        };

        // Gets the URI which to download the file.
        Windows.Foundation.Uri SourceUri
        {
            get;
        };

        // Gets the file name which to download the file.
        String FileName
        {
            get;
        };

        // Gets the save file object which to download the file.
        Windows.Storage.IStorageFile SaveFile
        {
            get;
        };

        // Gets the save folder object which to download the file.
        Windows.Storage.IStorageFolder SaveFolder
        {
            get;
        };

        // The current status of the task.
        TransferTaskStatus Status
        {
            get;
        };

        // The total number of bytes received. This value does not include 
        // bytes received as response headers. If the task has restarted, 
        // this value may be smaller than in the previous progress report.
        UInt64 BytesReceived
        {
            get;
        };

        // The speed of bytes received in one second.
        UInt64 BytesReceivedSpeed
        {
            get;
        };

        // The remain time, in seconds.
        UInt64 RemainTime
        {
            get;
        };

        // The total number of bytes of data to download. If this number is
        // unknown, this value is set to 0.
        UInt64 TotalBytesToReceive
        {
            get;
        };

        // Pauses a download operation.
        // Parameters:
        //   The function does not have parameters.
        // Return value:
        //   The function does not return a value.
        void Pause();

        // Resumes a paused download operation.
        // Parameters:
        //   The function does not have parameters.
        // Return value:
        //   The function does not return a value.
        void Resume();

        // Cancels a download operation.
        // Parameters:
        //   The function does not have parameters.
        // Return value:
        //   The function does not return a value.
        void Cancel();
    }

    typedef Windows.Foundation.Collections.IVectorView<ITransferTask> ITransferTaskVector;

    [version(1.0)]
    [uuid(976D09B5-65EE-39DE-9C00-26E47D6538D7)] 
    interface ITransferManager : IInspectable
        requires 
            Windows.Foundation.IClosable, 
            Windows.UI.Xaml.Data.INotifyPropertyChanged
    {
        // Gets the version of Nagisa.
        String Version
        {
            get;
        };

        // Gets or sets the filter to use for searching the task list.
        String SearchFilter
        {
            get;
            set;
        };

        // Gets the last used folder.
        Windows.Storage.IStorageFolder LastusedFolder
        {
            get;
        };

        // Gets or sets the default download folder.
        Windows.Storage.IStorageFolder DefaultFolder
        {
            get;
            set;
        };

        // Gets the total download bandwidth.
        UInt64 TotalDownloadBandwidth
        {
            get;
        };

        // Gets the total upload bandwidth.
        UInt64 TotalUploadBandwidth
        {
            get;
        };

        // Gets the task list.
        // Parameters:
        //   The function does not have parameters.
        // Return value:
        //   Returns an object which represents the task list.
        Windows.Foundation.IAsyncOperation<ITransferTaskVector> GetTasksAsync();

        // Add a task to the task list.
        // Parameters:
        //   SourceUri: The source uri object of task.
        //   DesiredFileName: The file name you desire.
        //   SaveFolder: The object of the folder which you want to save.
        // Return value:
        //   Returns an asynchronous object used to wait.
        Windows.Foundation.IAsyncAction AddTaskAsync(
            Windows.Foundation.Uri SourceUri,
            String DesiredFileName,
            Windows.Storage.IStorageFolder SaveFolder);

        // Removes a task to the task list.
        // Parameters:
        //   Task: The task object. 
        // Return value:
        //   Returns an asynchronous object used to wait.
        Windows.Foundation.IAsyncAction RemoveTaskAsync(
            ITransferTask Task);

        // Start all tasks.
        // Parameters:
        //   The function does not have parameters.
        // Return value:
        //   The function does not return a value.
        void StartAllTasks();

        // Pause all tasks.
        // Parameters:
        //   The function does not have parameters.
        // Return value:
        //   The function does not return a value.
        void PauseAllTasks();

        // Clears the task list.
        // Parameters:
        //   The function does not have parameters.
        // Return value:
        //   The function does not return a value.
        void ClearTaskList();
    }

    [version(1.0)]
    runtimeclass TransferManager :
        [default] ITransferManager
    {
        // Creates a new TransferManager object.
        // Parameters:
        //   EnableUINotify: Enable the UI notify timer if true. 
        // Return value:
        //   The function does not return a value.
        TransferManager(
            Boolean EnableUINotify);
    }
}

I want to know which caused it, my fault or the Windows SDK's.

Upvotes: 3

Views: 990

Answers (2)

Dmitry
Dmitry

Reputation: 1339

After a few days of pulling my hair out around this problem trying to find a solution, the workaround turned out to be extremely simple:

namespace System {
    typedef Windows.Foundation.IClosable IDisposable;
}
namespace MyComponent.MyNamespace {
    interface IMyInterface : IInspectable requires System.IDisposable {
        ...
    }
}

The above typedef can be put into a separate shared .idl file, which can be included whenever external interface derivation is required.

Update (2020/06/06): A year and a couple of SDK updates later the problem is still there. :(

Also, I've encountered a specific situation when my fix does not quite work well - when one cppwinrt WRC project depends on another cppwinrt WRC project. Apparently, typedef becomes a raw type in the imported .winmd, so referenced project compiles fine, but referencing project is failing with the same old "internal compiler problem". Unfortunately, you can't fix it with the above include, since imported .winmd's are processed before project .idl's.

I've went to investigate the problem further and here's what I've found:

  • Error occurs not only with Windows.Foundation.IClosable per se, but with any other interface having it somewhere down the requirements tree
  • Error does not occur when you're deriving a runtime class from such interface (that's it only happens with interface "inheritance")
  • The workaround is pretty simple and quite similar: if you typedef such interface instead of using it directly - everything will be compiled fine.

Upvotes: 1

Kenny Kerr
Kenny Kerr

Reputation: 3115

I want to know which caused it, my fault or the Windows SDK's.

This is a known bug in the MIDL compiler that ships with the latest Windows SDK.

Upvotes: 0

Related Questions