473 links
267 private links
  • When 140 characters is not enough!
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
Links per page: 20 50 100
3 results tagged C# x
  • GUI in C# while using Linux (.NET Core)

    I've been reading up on the GUI situation for C# on linux and while it seems obvious that there is no support for Forms (or Windows Forms I guess) on Linux, there seems to be a lot of confusion for me regarding the GUI development. For context, I have just recently begun to learn C# and was looking to practice some simple commands while also trying to make a functional GUI with buttons that will execute some commands for me. I'm not exactly sure what next steps to take because any forums / wikis regarding this topic usually go like "Is it possible" while someone on the other end replies "Just use C++ lol".

    Would really appreciate any help and especially some beginning point or links for me to go to so I can start learning all of this. Loving C# so far!

    --

    Réponses : 

    • Avalonia - https://github.com/AvaloniaUI/Avalonia
    • Eto - https://github.com/picoe/Eto
    • Uno - https://platform.uno

    Également proposés :

    • Linux MAUI <<- version “communautaire” de MAUI, mais pas vraiment maintenu, et carrément pas prêt pour la prod
    • Winforms + Mono <<- on oublie
    • Razor <<- sérieux ? - pourquoi pas Electron tant qu'on y est, nan parce que quitte à faire de l'ASP.Net, autant faire du web)
    • Blazor, mais quand ça sera intégré <<- ça ne l'est pas.
    • Electron, “mais je vois pas comment intégrer avec C#” <<- Sérieux ?
    March 29, 2024 at 10:26:40 GMT+1 * - permalink -
    QRCode
    - https://www.reddit.com/r/csharp/comments/nyubg4/gui_in_c_while_using_linux_net_core/?rdt=33264
    c# dotNet Core Linux GUI
  • You can host a .NET Core MVC app on Linux | Declaration of VAR

    You can host a .NET Core MVC app on Linux

    On your local machine publish your project by running the following from the project folder:

    $ dotnet publish -c Release -o ../_deploy
    Create a website folder on the server:
    
    $ mkdir -p /var/www/YOUR-WEBSITE

    And copy the contents of ../_deploy from your machine to /var/www/YOUR-WEBSITE/ on the server.

    Change the owner of your website’s directory so it would belong to NGINX’s user (www-data):

    $ chown -R www-data:www-data /var/www/

    systemd service

    Create a systemd config for Kestrel instance:

    $ nano /etc/systemd/system/kestrel-YOUR-WEBSITE.service

    Edit it like that:

    [Unit]
    Description=YOUR-WEBSITE
    
    [Service]
    WorkingDirectory=/var/www/YOUR-WEBSITE/
    ExecStart=/usr/bin/dotnet /var/www/YOUR-WEBSITE/YOUR-WEBSITE.dll
    Restart=always
    RestartSec=10
    SyslogIdentifier=dotnet-YOUR-WEBSITE
    User=www-data
    Environment=ASPNETCORE_ENVIRONMENT=Production
    
    [Install]
    WantedBy=multi-user.target

    Enable and start it:

    $ systemctl enable kestrel-YOUR-WEBSITE.service
    $ systemctl start kestrel-YOUR-WEBSITE.service

    You can check its status:

    $ systemctl status kestrel-YOUR-WEBSITE.service

    If everything is okay, then it will show something like that:

    ● kestrel-YOUR-WEBSITE.service - YOUR-WEBSITE
       Loaded: loaded (/etc/systemd/system/kestrel-YOUR-WEBSITE.service; enabled; vendor preset: enabled)
       Active: active (running) since Thu 2017-08-10 11:30:09 UTC; 1s ago
     Main PID: 15628 (dotnet)
        Tasks: 14
       Memory: 25.4M
          CPU: 1.380s
       CGroup: /system.slice/kestrel-YOUR-WEBSITE.service
               └─15628 /usr/bin/dotnet /var/www/YOUR-WEBSITE/YOUR-WEBSITE.dll

    NGINX

    Install NGINX:

    $ apt-get install nginx

    Now, there are 2 options how NGINX can send requests to Kestrel: via TCP or via Unix socket.

    TCP

    Your Program.cs:

    // ...
    
    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseUrls("http://localhost:5000/")
            .UseStartup<Startup>();
    
    // ...

    NGINX config (/etc/nginx/sites-available/default):

    # ...
    
    server {
        listen 80;
        listen [::]:80;
    
        location / {
                proxy_pass http://localhost:5000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection keep-alive;
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
    
    # ...

    Unix socket

    This should be better in terms of performance as there is no TCP overhead. Even if there was no performance impact, on a local machine “talking” through Unix socket simply makes more sense than communicating over TCP.

    Your Program.cs:

    // ...
    
    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseLibuv()
            .ConfigureKestrel(
                (context, serverOptions) =>
                {
                    // /var/www/YOUR-WEBSITE
                    string root = Path.GetDirectoryName(
                        System.Reflection.Assembly.GetExecutingAssembly().Location
                    );
                    // if we are (behind NGINX) and on Linux, then can use sockets
                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                    {
                        // path to socket has to be absolute
                        string socket = Path.Combine(root, "kestrel.sock");
                        serverOptions.ListenUnixSocket(socket);
                    }
                    else
                    {
                        serverOptions.Listen(IPAddress.Loopback, 5000);
                    }
                }
            )
            .UseStartup<Startup>();
    
    // ...

    For that to work you need to add Transport.Libuv package, so you’ll have the following in your .csproj:

    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" Version="2.2.0" />

    NGINX config in this case:

    # ...
    
    location / {
        proxy_pass http://unix:/var/www/YOUR-WEBSITE/kestrel.sock;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
    
    # ...

    Save it and restart NGINX:

    $ systemctl restart nginx.service

    Now open your web-browser and go to http://YOUR-SERVER-IP/. It fucking works!

    March 28, 2024 at 02:39:09 GMT+1 * - permalink -
    QRCode
    - https://decovar.dev/blog/2017/08/10/you-can-host-net-core-on-linux/
    C# dotNet Core MVC Linux
  • thumbnail
    Yet Another Chris - C# and .NET - Latest posts - C# Pronounceable password generator

    This is the source code for the password generator page. The prounceable password generator is quite long in its initialisation arrays, so is a download. The alpha-numeric password generator is very simple and doesn't do anything complicated besides generate a random MD5 hash and truncate the output.

    February 7, 2013 at 10:46:51 GMT+1 - permalink -
    QRCode
    - http://www.yetanotherchris.me/home/2009/3/15/c-pronounceable-password-generator.html
    C# code source
Links per page: 20 50 100
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Help/documentation