Program.cs(18, 44): [CS1061] 'AppBuilder'不包含“UsePlatformDetect”的定义;并且没有可访问的扩展方法“UsePlatformDetect”

发布于 2025-01-17 03:49:38 字数 1355 浏览 3 评论 0原文

  Program.cs(18, 44): [CS1061] 'AppBuilder' does not contain a definition for 'UsePlatformDetect' and no accessible extension method 'UsePlatformDetect' accepting a first argument of type 'AppBuilder' could be found (are you missing a using directive or an assembly reference?)

所以这是我的代码:

using System;
using Avalonia;
using Avalonia.ReactiveUI;

namespace AvaloniaCrossPlatformApplication1.Desktop
{
    class Program
    {
        // Initialization code. Don't use any Avalonia, third-party APIs or any
        // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
        // yet and stuff might break.
        [STAThread]
        public static void Main(string[] args) => BuildAvaloniaApp()
            .StartWithClassicDesktopLifetime(args);

        // Avalonia configuration, don't remove; also used by visual designer.
        public static AppBuilder BuildAvaloniaApp()
            => AppBuilder.Configure<App>().UsePlatformDetect()
                .LogToDebug()
                .UseReactiveUI();
    }
}

我的 avalonia 版本是 avalonia.0.10.13.nupkg.sha512

我正在使用基本模板。

Avalonia 上好像没有 UsePlatformDetect...

我用了 jetbrain rider & 。 dotnet new -i Avalonia.Templates

生成模板。

有什么想法吗?我在 ubuntu 22.04 上。

问候

  Program.cs(18, 44): [CS1061] 'AppBuilder' does not contain a definition for 'UsePlatformDetect' and no accessible extension method 'UsePlatformDetect' accepting a first argument of type 'AppBuilder' could be found (are you missing a using directive or an assembly reference?)

So here is my code :

using System;
using Avalonia;
using Avalonia.ReactiveUI;

namespace AvaloniaCrossPlatformApplication1.Desktop
{
    class Program
    {
        // Initialization code. Don't use any Avalonia, third-party APIs or any
        // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
        // yet and stuff might break.
        [STAThread]
        public static void Main(string[] args) => BuildAvaloniaApp()
            .StartWithClassicDesktopLifetime(args);

        // Avalonia configuration, don't remove; also used by visual designer.
        public static AppBuilder BuildAvaloniaApp()
            => AppBuilder.Configure<App>().UsePlatformDetect()
                .LogToDebug()
                .UseReactiveUI();
    }
}

My avalonia version is avalonia.0.10.13.nupkg.sha512

i'am using the basic template.

It seems that there is no UsePlatformDetect on Avalonia ...

I used jetbrain rider & dotnet new -i Avalonia.Templates

to generate the template.

Any ideas ? I'am on ubuntu 22.04.

Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失去的东西太少 2025-01-24 03:49:38

UsePlatformDetect 扩展在 Avalonia.Desktop 程序集中有其定义,因此您必须在 .csproj 中添加对其的引用

<PackageReference Include="Avalonia.Desktop" Version="0.10.13" />

The UsePlatformDetect extension has its definition in the Avalonia.Desktop assembly, so you have to add a reference to it in your .csproj

<PackageReference Include="Avalonia.Desktop" Version="0.10.13" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文