簡體   English   中英

為什么我在 IAsyncAction 聲明中得到 C3646?

[英]Why I am getting C3646 on an IAsyncAction declaration?

可能是一個愚蠢的問題(WinRT noob),但是,這里是......

“App.xaml.h”中的代碼是:

namespace winrt::Precog::implementation
{
    struct App : AppT<App>
    {
        App();

        void OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&);

    private:
        std::wstring cfgDatabase = L"";
        winrt::Microsoft::UI::Xaml::Window window{ nullptr };

        IAsyncAction loadSettings();
    };
}

當我嘗試編譯時,Visual Studio 在 IAsyncAction 聲明中給了我一個 C3646(未知的覆蓋說明符)?

loadSettings 實現是:

IAsyncAction App::loadSettings()
{
    PHKEY regKey = NULL;
    LSTATUS regResult;

    regResult = RegCreateKey(HKEY_CURRENT_USER, L"Precog", regKey);
    if (regResult != ERROR_SUCCESS)
    {
        ContentDialog errorDialog = ContentDialog();
        errorDialog.Title(box_value(L"Erro"));
        errorDialog.Content(box_value(L"Pateta"));
        errorDialog.CloseButtonText(L"Ok");
        errorDialog.XamlRoot(window.Content().XamlRoot());
        auto result = co_await errorDialog.ShowAsync();
    }
    else
    {
        co_return;
    }
}

編輯:完整編譯器 output:

Build started...
1>------ Build started: Project: Precog, Configuration: Debug x64 ------
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3106: Assembly strong name "C:\Code\Precog\packages\Microsoft.WindowsAppSDK.1.0.0\build\native\..\..\lib\uap10.0\Microsoft.Windows.System.winmd" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3106: Assembly strong name "C:\Code\Precog\packages\Microsoft.WindowsAppSDK.1.0.0\build\native\..\..\lib\uap10.0\Microsoft.Windows.PushNotifications.winmd" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
1>App.xaml.cpp
1>C:\Code\Precog\Precog\Precog\App.xaml.h(17,22): error C3646: 'loadSettings': unknown override specifier
1>C:\Code\Precog\Precog\Precog\App.xaml.h(17,34): error C2059: syntax error: '('
1>C:\Code\Precog\Precog\Precog\App.xaml.h(17,36): error C2238: unexpected token(s) preceding ';'
1>C:\Code\Precog\Precog\Precog\App.xaml.cpp(35,19): error C2039: 'loadSettings': is not a member of 'winrt::Precog::implementation::App'
1>C:\Code\Precog\Precog\Precog\App.xaml.h(7): message : see declaration of 'winrt::Precog::implementation::App'
1>C:\Code\Precog\Precog\Precog\App.xaml.cpp(48,30): error C2065: 'window': undeclared identifier
1>Done building project "Precog.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

知道了。 這似乎是命名空間不匹配,因為將聲明更改為:

winrt::Windows::Foundation::IAsyncAction loadSettings();

解決了這個問題。 有趣的是,Intellisense 不會捕獲錯誤(類型下方沒有紅線),只有編譯器會捕獲。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM