相关疑难解决方法(0)

CA1416。如何告诉构建器只有平台是 Windows?

dotnet run (在 Windows 上)原因 warning CA1416: This call site is reachable on all platforms. 'WellKnownSidType.WorldSid' is only supported on: 'windows'.

我的程序设计为只能在 Windows 上运行。

我试图添加SupportedPlatformMyApp.csproj,但没有运气。

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="5.0.5" />
    <PackageReference Include="System.DirectoryServices" Version="5.0.0" />
    <SupportedPlatform Include="Windows"/>
  </ItemGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?我怎样才能表明dotnet run这个项目是仅限 Windows 的?

.net c# msbuild .net-5

4
推荐指数
2
解决办法
644
查看次数

设置System.Console.WindowHeight会在Mono下抛出System.NotSupportedException

我得到了一个Unhandled Exception: System.NotSupportedException: Operation is not supported.使用Ubuntu 11.10在Mono下引发的异常.

阅读财产有效.该文档可能表明,该方法不构成问题.

关于如何最好地处理或解决这种情况的任何想法?

目前的解决方案相当尴尬,并没有解决通过System.Console-API设置窗口大小的问题:

        const int defaultConsoleWindowWidth = 80;
        const int defaultConsoleWindowHeight = 25;


        if (pid != PlatformID.Unix && pid != (PlatformID)128) {
            System.Console.WindowHeight = lastConsoleWindowHeight;
            System.Console.WindowWidth = defaultConsoleWindowWidth;
        }else{
            //assume *NIX system
            try {
                var p = new Process();
                p.StartInfo = new ProcessStartInfo(@"stty cols " + defaultConsoleWindowWidth + " rows " + lastConsoleWindowHeight, "-n")
                {
                    UseShellExecute = false
                };

                p.Start();
                p.WaitForExit();
            }
            catch …
Run Code Online (Sandbox Code Playgroud)

console mono window exception c#-3.0

1
推荐指数
1
解决办法
930
查看次数

标签 统计

.net ×1

.net-5 ×1

c# ×1

c#-3.0 ×1

console ×1

exception ×1

mono ×1

msbuild ×1

window ×1