Statische Interface Member?

Hallo,

Ich habe mal einwenig im Code der .NET-Standart Bibliothek gestöbert und bin dabei auf dieses Interface gestoßen

//
// Zusammenfassung:
//     Defines a mechanism for parsing a string to a value.
//
// Typparameter:
//   TSelf:
//     The type that implements this interface.
public interface IParsable<TSelf> where TSelf : IParsable<TSelf>?
{
    //
    // Zusammenfassung:
    //     Parses a string into a value.
    //
    // Parameter:
    //   s:
    //     The string to parse.
    //
    //   provider:
    //     An object that provides culture-specific formatting information about s.
    //
    // Rückgabewerte:
    //     The result of parsing s.
    //
    // Ausnahmen:
    //   T:System.ArgumentNullException:
    //     s is null.
    //
    //   T:System.FormatException:
    //     s is not in the correct format.
    //
    //   T:System.OverflowException:
    //     s is not representable by TSelf.
    static abstract TSelf Parse(string s, IFormatProvider? provider);
    //
    // Zusammenfassung:
    //     Tries to parse a string into a value.
    //
    // Parameter:
    //   s:
    //     The string to parse.
    //
    //   provider:
    //     An object that provides culture-specific formatting information about s.
    //
    //   result:
    //     When this method returns, contains the result of successfully parsing s or an
    //     undefined value on failure.
    //
    // Rückgabewerte:
    //     true if s was successfully parsed; otherwise, false.
    static abstract bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out TSelf result);
}

Kommt es nur mir so vor oder kommt es euch auch einfach falsch vor das ein Interface statische und abstrakte Member vorschreibt und dazu noch das der abstrakte Member statisch ist (Wenn ich versuche einen statischen Member einer Klasse als abstrakt zu deklarieren kommt ein Compilerfehler).

Falls jemand eine Idee hat wozu das gut sein kann, dann bitte eine Antwort schreiben.

C Sharp, dotNet, Programmiersprache
Warum schlägt der Docker Build meines C#-Projekts fehl?

Ich versuche gerade mein C#-Projekt mit Docker zu bauen.

Ich baue aus dem Repo Root Context. Das Dockerfile liegt im Unterordner vom Gateway.WebApi.

Der Build schlägt leider mit einem Fehler fehl:

 error MSB3030: Could not copy the file "/Jwt.Service.Shared/Configurations/appsettings.json" because it was not found

Das ist mein Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Gateway.WebApi/Gateway.WebApi.csproj", "./"]
COPY ["Gateway.Application/Gateway.Application.csproj", "../Gateway.Application/"]
COPY ["Entitys.Shared/Entitys.Shared.csproj", "../Entitys.Shared/"]
COPY ["Gateway.Domain/Gateway.Domain.csproj", "../Gateway.Domain/"]
COPY ["Gateway.Infrastructure/Gateway.Infrastructure.csproj", "../Gateway.Infrastructure/"]
COPY ["Jwt.Service.Shared/Jwt.Service.Shared.csproj", "../Jwt.Service.Shared/"]
RUN dotnet restore "Gateway.WebApi.csproj"
COPY . .
WORKDIR "/src/"
RUN dotnet build "Gateway.WebApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Gateway.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Gateway.WebApi.dll"]
[1:14 PM]

Die Datei existiert und die Berechtigungen sind richtig. Ich bin auf Linux btw..

ASP.NET, C Sharp, dotNet, Docker
Wie lege ich einen lokalen Benuterz mithilfe eines Powersehll Skript an?

Hierzu möchte ich ein Formular vwerdenden.

Folgendes habe ich erstellt:

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$form = New-Object System.Windows.Forms.Form
$form.Text = 'lokaler Benutzer'
$form.Size = New-Object System.Drawing.Size(300,200)
$form.StartPosition = 'CenterScreen'
$okButton = New-Object System.Windows.Forms.Button
$okButton.Location = New-Object System.Drawing.Point(75,120)
$okButton.Size = New-Object System.Drawing.Size(75,23)
$okButton.Text = 'OK'
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $okButton
$form.Controls.Add($okButton)
$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Point(150,120)
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
$cancelButton.Text = 'Cancel'
$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $cancelButton
$form.Controls.Add($cancelButton)
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Benutzername:'
$form.Controls.Add($label)
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,70)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'vollständiger Name:'
$form.Controls.Add($label)
$Benutzername = New-Object System.Windows.Forms.TextBox
$Benutzername.Location = New-Object System.Drawing.Point(10,40)
$Benutzername.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($Benutzername)
$Name = New-Object System.Windows.Forms.TextBox
$Name.Location = New-Object System.Drawing.Point(10,90)
$Name.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($Name)
$form.Topmost = $true
$form.Add_Shown({$textBox.Select()})
$result = $form.ShowDialog()
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
   $x = $textBox.Text
   $x
}
New-LocalUser $Benutzername  -FullName $Name
Windows, programmieren, Code, dotNet, PowerShell
kann man in C# eine Konsolenanwendung für den OSX mahen?

Hallo zusammen

Ich bin in C# VS relativ neu. Habe ein ca. 3500 Zeilen-Programm mit vielen Klassen etc. gemacht. Funktioniert alles super und ist getestet.

Ca. 80% der Consolen-App habe ich auf dem Mac programmiert, 20% auf meinem Windowsrechner. Ich bin also heterogen unterwegs. Soweit so gut.

Eine .exe kann ich problemlos erstellen. Auf Windows auch entsprechend problemlos auszuführen. Wenn ich das auf dem Mac laufen lassen möchte, mache ich:

  • a) die Konsole auf
  • b) navigiere zur ProgrammXY.dll
  • c) gebe dotnet ProgrammXY.dll ein

und das Ding läuft. Nur!!!!!!!!!!!!..... Das möchte ich so nicht!

Ich habe aktuell den Fall, dass meine Schwester (auch Mac-Anwenderin) genau jetzt die App benötigt. Die Löst ein Problem welche sie (und das ist Zufall des Jahrhunderts) hat.

Ich möchte ihr die Consolen-App analog zu Windows auf einem USB-Stick o.ä. übergeben können, sodass sie mit einem einfachen DOPPELKLICK das Ding starten und verwenden kann. Ich möchte keine UI darum herum bauen und ich möchte nicht ins Web damit. Auch soll sie ihren Rechner nicht fit für dotnet machen müssen. Ich will die App auf der Konsole haben. Sowohl auf Mac als auch auf Windows. Genau gleich einfach.

Nun die Frage:
Kann man das überhaupt? ich finde keinerlei sinnvolle Anleitungen oder Antworten. Bei Stackoverflow werde ich angepöbelt und bei MS selber kann ich im DEV-Forum keine Fragen stellen.

Ich möchte nur wissen ob das überhaupt geht damit ich mit der Fragerei und Suche aufhören kann oder andere Wege / Technologien angehen kann.

Grüsse euch und danke schonmal.

Computer, Technik, programmieren, C Sharp, dotNet, Informatik, Softwareentwicklung, Technologie, konsolenanwendung, Visual Studio 2019

Meistgelesene Fragen zum Thema DotNet