简体   繁体   English

为什么我在 IAsyncAction 声明中得到 C3646?

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

Probably a dumb question (WinRT noob), but, here is goes...可能是一个愚蠢的问题(WinRT noob),但是,这里是......

The code from "App.xaml.h" is: “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();
    };
}

When I try to compile, Visual Studio gives me a C3646 (unknown override specifier) at the IAsyncAction declaration?当我尝试编译时,Visual Studio 在 IAsyncAction 声明中给了我一个 C3646(未知的覆盖说明符)?

The loadSettings implementation is: 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;
    }
}

EDIT: Full compiler output:编辑:完整编译器 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 ==========

Got it.知道了。 It seemed to be a namespace mismatch, since changing the declaration to:这似乎是命名空间不匹配,因为将声明更改为:

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

Solved the problem.解决了这个问题。 The interesting bit is that Intellisense does not catch the error (no red line underneath the type), only the compiler does.有趣的是,Intellisense 不会捕获错误(类型下方没有红线),只有编译器会捕获。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在另一个项目中使用NuGet包时,为什么会出现XamlParseException? - Why am I getting a XamlParseException when using my NuGet package from another project? 为什么我被告知类在我的命名空间中不存在? - Why am I being told a class does not exist in my namespace when it does? 我究竟做错了什么? 在构造函数中使用依赖项属性的值 - What am I doing wrong? Using the value of an Dependency Property in constructor 异步等待模式帮助。 我做对了吗? - Async await pattern help. Am I doing it right? 将动态内容添加到ContentPresenter时,为什么没有应用某些字体? - Why are some fonts not getting applied when adding dynamic content to a ContentPresenter? 如果我使用共享合同和共享文件,是否可以在Windows 8 metro应用程序中将主题设置为邮件应用程序? - Is it possible to set a subject to the mail app in Windows 8 metro application, if I am using share contract and sharing files? Windows应用商店应用程序:我使用全局变量和扩展初始屏幕正确吗? - Windows store app: Am i using global variable and extended splash screen correct? 在Windows Store应用程序中,如果我定期从LocalFolder内部的文件夹中进行读取,是否可以保留静态引用? - In a Windows Store app, if I am reading from a folder inside of my LocalFolder regularly, can I keep a static reference? XAML:为什么我不能将T的子类添加到T的集合中? - XAML: Why can't I add a subclass of T to a collection of T? 我可以知道我的应用程序是否在Windows RT上使用C#运行吗? - Could I know if my app is running on Windows RT with C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM