C#

C

C#

We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.

Join

How to resolve this unmanaged memory leak?

I've written a small mpv renderer for avalonia using opengl:




So far everything seems to work except when i'm done and call dispose almost no memory involved with the renderer is released even though i destroy the native pointers in a safe way. I'm not sure what i am missing. Any help would be appreciated. For more context, the whole repo is here and readily reproducible: https:///www.github.com/saverinonrails/avaloniampv...

✅ Error generating Commit message using the Copilot button

I have just upgraded to VS Version 17.14.15. When generating Commit message using the Copilot button in the commit window, VS fails with an error message: "The method or operation is not implemented". Any idea?
No description

✅ Help Building a C# Project

Hey all I am completely new to C#, my experience is mainly in Python and C++. Im looking to know if anyone could help provide instructions for building repo https://github.com/ousnius/NiflySharp/tree/main ? I need to extract the compiled dlls to execute C# scripts using the NiflySharp package. Any help is appreciated...

Having problem with TOML parser

Basically i'm building a console application, and i want the possibility of creating a .toml config file, for parsing the file i'm using Tomlyn, this is the code: This is the error it gives: ``` Tomlyn.TomlException: (1,2) : error : Unable to set the property Config on object type dinfo.core.Handlers.TomlConfiguration.ConfigFile....

How windows OS processes input events?

The way i understand it right now is that whenever you move the mouse or hit a keyboard, that event passes through a raw input thread, then gets stored in a system message queue (where all messages, like WM_PAINT are stored), then passes through a message-specific chain of hook procedures before finally arriving at the window-specific message queue that winforms gets messages from. Am i correct in this and where could i find more info on it?...

OpenTelemetry Metrics

I'm trying to configure an ASP.NET Core application to send metrics that I can then view via Grafana. I'm pretty confused about the whole observability architecture. Key points: - Everything is running within Docker Compose - I've managed to configure ASP -> OTLP -> Loki -> Grafana...

how to remove "auto complete" feature in VS2022

I am very new to coding and am going through a flappy bird tutorial for unity and as I'm following along, classes and interfaces and whatever else will autocomplete when I try to make a space or place a period. I've looked at 5 different tutorials about it and if just can't turn it off, very frustrating. anyone know a fix?

How does marshalling work?

```c# public static partial int MessageBoxW(nint hWnd, string text, string caption, uint type) { int __retVal; // Pin - Pin data in preparation for calling the P/Invoke....

Threadsafe async code design

With a single UDP/TCP client or serial connection, I want to send and receive concurrently. The sending and receiving code is asynchronous so locks are out of the question. Trying to follow closely with a hosted app and dependency injection. Been stuck thinking about it for a few hours because every solution I've been able to come up has a gotcha. Attached is the logic Thought splitting into two classes would be good but if I'm working with the same UDP/TCP/serial connection then it goes back to the locking issue. Adding a third class for message queueing could work but then you might end up waiting for bytes with outgoing messages in queue that could've been sent by the time you receive the next bytes....

dotnet minimal api extension method for logic validation

Hey guys I have three if statements that are repeated too often in many endpoints, how can I make an extension method to use on my endpoints? here is the current code ```c# app.MapPost( "create-income-register", [Authorize]...

Creating an algorithm to solve Number Match

Hey, I've recently discovered a new logical game called "Number Match". Link to the game Here is the set or rules describing it: ``` The game is played on a grid filled with numbers. Grid is x cells wide and infinitely high (it expands vertically if needed)...

upload csv file using httpclient problem

public async Task<Result<string>> UploadCsvFileAsync(byte[] csvData, string fileName, CancellationToken cancellationToken = default) { try {...

Blazor CSS not loading properly

Hey i am currently working on a Blazor project and the CSS is not loading. I already checked the Filenames, filepath, app.razor and everything is imported correctly. i don't know what the issue is or how i can find it. I googled and asked Chatgpt but i can't seem to find the problem. this is my app.razor: ``` <!DOCTYPE html> <html lang="en" data-theme="light"> ...

✅ WEB API AND EF toy project

I'd like to study the two technologies above by analyzing toy projects. Are there any good toy projects out there?

✅ Where can I learn about WEB API and Entity framework?

Where can I learn about WEB API and Entity framework?

Module initializer only running for one assembly

Hi, I have source generator to generate compiled meta data about classes, to register these for a scripting layer in C++. These are stored as a module initializer, but the module initializer won't run when I load assembly ``` [System.Runtime.CompilerServices.ModuleInitializer]...

✅ Restart Avalonia Application

How to restart an Avalonia Application on Windows/Linux? I know its not a built in feature but I would like to know how its done 🙂

How to capture request body in IIS managed module

Hi, I'm trying to create an IIS server module that can capture all the incoming and outgoing traffic and send it to my backend server. So, when I try to add the code below in my module and try to capture the request body, all the requests that contain a payload time out after 60 seconds. However, all the other requests that don't contain any payload work fine. If I remove the code below, then everything works fine, but I won't be able to capture the request body. ...

Hi any one have C# validator for Apple purchases JWC for storekit2?

I try to validate Apple purchases on my .net core website but I do not have good example and every things I try fail.

Confusion with nullability of a custom LINQ method

I have this custom extension method I used a lot in my project, however every time I use it, it trips nullability checks and thinks I'm using a possibly null value. ```csharp /// <summary>
/// Tries to get the first item that meets a condition from a collection. /// </summary> /// <typeparam name="T">Type of items in the collection</typeparam>...