C#

C

C#

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

Join

FluentValidation validators not registering in DI despite using extension method

I’ve implemented a validation pipeline, but it doesn’t retrieve any validators. The dependency injection container returns an empty collection, even though the validators are registered.
No description

Reorder itemscontrol without resetting the item

Hi. I have an ItemsControl. It takes in an ObservableCollection, and it generates a long list with input boxes and other forms based on that observablecollection. I have been trying to reorder items in the list (the application is supposed to be a sort of scriptlike thing), but every time I change the order it resets the textboxes for instance to old values. ...

project rename > folder rename > sln/slnx reference directory rename

for years and years, whenever I want to rename a project in dotnet i have done the following: project rename > folder rename > sln/slnx reference directory rename. is there a right or better way to do this? am i fundamentally doing it wrong? for once id like to adhere to DRY and not repeat this dance!

Csproj Content Include Behaviour

So i have a setup that requires me to build my C# project after a nodejs project has been built, i managed to get that done using ```cs <Target Name="NodeJS Compile" BeforeTargets="BeforeCompile"> <Exec Command="npm install" WorkingDirectory="Http\Frontend"/>...

ASP.NET: setting the OpenAPI spec version not working

I'm trying to set the OpenAPI spec version to 3.0 for the time being, yet neither the delegate method nor the MSBuild method proposed in the docs are working. I need it as 3.0 for the correct OpenAPI.json file to be generated, and have tried this: Program.cs:...

How can I use Microsoft.Diagnostics.Tracing.TraceEvent to see when a filed opened and location

Hi begginer here. I am trying to use ETW to get notified when a file opened and log its file location to somewhere. Is it possible with this library and where should I read for more information or examples. Couldnt find anything up to date at google ty

Anyone tried C# 10 with Aspire 13 + EF 13 + MySQL?

Steps to reproduce: - Create Aspire Startup solution, add Aspire.Hosting.MySql to Aspire project with var mysql = builder.AddMySql("mysql") .WithLifetime(ContainerLifetime.Persistent); var mysqldb = mysql.AddDatabase("mysqldb"); Then add Aspire.Pomelo.EntityFrameworkCore.MySql (version 13) with code ...

Integration test cases with DB project

I'm currently building integration tests using xUnit and Testcontainers. We use Dapper and the way we handle migrations is not exactly standard. We have a database project and there's a MSBuild PreBuildEvent that keeps track of which migrations have been applied to the DB. Once the DB project builds, it produces a .dacpac file that can then be deployed easily either through CD or manually through SSMS via Upgrade Data-Tier Application. So I can easily spin up a SQL Server container using Testcon...

Implement Zooming in Drawing application

Trying to implement zooming on a canvas in such a way a that the point where the mouse is pointing at pre-zoom and post-zoom stays the same. Can't figure out why the offset isn't being calculated properly. I'm trying to adapt the logic gotten from here: https://youtu.be/ZQ8qtAizis4?si=zLbqZok2fDN5aNe-&t=874...
No description

String manipulation etc

https://paste.mod.gg/qiqfbdvjrwru/0 I have this task: Print to the file ManoKnyga.txt a merged text, composed according to the following rules:...

Migrate Visual Studio Extension to VS 2026

Visual Studio 2026 has updated the look of extension settings, how should extension developers update their extension to make use of this? When you go to the settings page for the csharpier extension I see the message "These settings haven't been migrated yet. Links will open in the legacy Options dialog" and the option to open the legacy settings (IIRc using DialogPage). I can't see any information online for migrating the dialog box. Has anyone else solved this issue or is the ability for migrate settings coming in a future update?...
No description

✅ how does one setup raylib with c#

I'm trying to figure it out, but I'm damn near stupid when it comes to this stuff. Just started programming in c# don't clown on me too much!

API Development & Integration

Hi, I'm beginner .NET developer with 1 year of experience, I have to learn API Development and Integration whats the best platform for it. And How I can practice this to get strong grip on it.

service-oriented Web application

for this application, im curious why the wording in this assignment is so confusing, the local components part is not totally clear. If each member has to have at least 2 types of componets from (a, b , c, d), and we have 3 members, then there is no way for us to have at leas 1 unique component. I'm unsure if any of the components can be separated into other components, but that would make no sense. My current assumption is that Session and Cookies can be split into different components.
No description

Default data in Configuration Table for User created using Identity

Hello, I'm a total newbie in the backend/database field. I'm trying to implement a simple application with authentication using Identity. Let's say I have a Configuration table in a one-to-one relationship with the User table. I'd like to create an entry with default values when a user is registered. How should I approach this? 1. Can I use the endpoints generated by Identity? Can I override them so that creating a new user also creates a default entry in the Configuration table? Or should the database have a transaction defined to cascade the addition of an entry in the related table? 2. Should I create my own endpoint to register a user and handle the creation of an entry in the Configuration table? What should the approach be in this situation?...

Looping the game

I made this game but when the game ends, I need to restart every game each time. How can I loop it so I can play another game right after ```cs using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates;...

✅ MSB4236/WorkloadAutoImportPropsLocator Error on a fresh .NET 10 project

[MSB4236] The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found. C:\Program Files\dotnet\sdk\10.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props at (14:38)
[MSB4236] The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found. C:\Program Files\dotnet\sdk\10.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props at (14:38)
Just installed the .NET 10 SDK, updated Rider, created a brand new console project with .net 10. Project refuses to load in Rider with this error. I can't seem to find any results that don't have to do with Visual Studio or Rider on OS X. any clue?...

Learning Developer needs .NET Architecture advice

Hello all, I've been learning for a year and got the hang of making basic apps with .NET. I've had experience with a normal layered 'coupled' architecture with EF CORE, viewmodels and Razor pages. Now I have to build a website with accounts, files uploading etc some other features that i will work on for 6 months. But I will work on it solo and i want it to be scalable after, and clean code....

Minimal endpoints or one controller per feature in VSA?

How do you usually structure your APIs in VSA? Do you prefer a minimal set of centralized endpoints, or do you use a dedicated controller per feature? I’d like to hear which approach you prefer and what advantages you see compared to the other option.

Populating IOptions in integration tests

Hi, I'm struggling with IOptions when building integration tests specifically, as I'm getting the 'InvalidOperationException: Section 'MySection' not found in configuration' on startup. Those options are mandatory. I know two approach, which both didn't seem to work. First is with AddInMemoryCollection ```cs...