C#

C

C#

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

Join

Execute code in API Controller from a razor page

I have API controllers that are work just fine I'm trying to execute similar code via another class Is something being sent to the API controler constructor? If so what and can I send the same thing in the razor file? Or am I going about this the wrong way? ...

Visual Studio 2022 Theme Designer having issues with opaque dark backgrounds on characters in code

When using Visual Studio Color Theme Designer 2022 to create a new theme, what option is specifically causing this nearly opaque dark background for the Text Editor's characters? It is messing with the text highlighting colors I set. I already went through Text Editor categories and set the backgrounds I could find there to #00000000 to be transparent but no effect on the oddity I am seeing above. I did save and apply the theme. Then close and re-open Visual Studio and ensured the new theme is applied. I did fresh install Visual Studio yesterday so everything is latest version and should be clean. Ideas?...
No description

Blazor Wasm Standalone 'Could not resolve type' on publish - Release

Hi! I have a MVC web app and I've been trying to add razor components using blazor wasm. I've been having problems when publishing, when I debug everything works fine but after publishing to an IIS web server I'm getting an error while trying to load Blazor on the browser.
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Could not resolve type with token 0100007a from typeref (expected class 'System.Reflection.FieldInfo' in assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') System.TypeLoadException: Could not resolve type with token 0100007a from typeref (expected class 'System.Reflection.FieldInfo' in assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')...

Storing Secrets

I have a background worker and want to configure secrets but don't know whats the best practice for it. I have this worker and database to it containerized and want to inject connection strings and some passwords securly to simulate production. Whats the best practice and is there a youtube video I can watch for handling injection of sensetive info?

Smarter ASP.NET

Hello! Does anyone have experience with Smarter ASP.NET and can tell me if I can publish an ASP.NET Core API and Blazor app all under one website? Thank you!

✅ Can this produce an DeadLock?

Im not sure in combination with linq an dead lock can occur. But this runs in an Azure Function, and it just stopped working. No crashes, it timeout after 6 hours. No further logs
No description

Resoruces for Learning SOLID Principles and Practice in Unity

I'm a beginner with C# and am trying to learn the SOLID principles. Can you recommend any resources to help me understand and apply these principles? Also, what kind of projects could I replicate to practice effectively? I will need to apply these principles in Unity Engine, but not for game development, so I would need practical examples that can be adapted to this context....

Deserialize JSON With Dynamic Properties

I'm trying to build a deserializer for GCP log entries, and they all seem to have the same basic structure, and it looks like our own log info gets stored in the textPayload property of the JSON of a log entry, but that's not really relevant. My problem is many different entries have different structures for their labels properties. For example, one entry will have labels like this: ```json {...

✅ I am encountering NETSDK1082 in blazor web app

I recently working on a blazor web assembly application now I got this errors! 1. NETSDK1082 - There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'. file:Microsoft.NET.Sdk.FrameworkReferenceResolution.targets line:512
2. NETSDK1112 The runtime pack for Microsoft.NETCore.App.Runtime.Mono.browser-wasm was not downloaded. Try running a NuGet restore with the RuntimeIdentifier 'browser-wasm'. ProductivityHack.Client file:Microsoft.NET.Sdk.FrameworkReferenceResolution.targets line:512
what I had done: the project running properly but I migrated all the project from .NET8 to .NET9 by simply changing the properties of projects and checked all the project is compatible and updated to latest .NET9...

EF Core mapping to Viewmodels without duplicating viewmodels

```cs //EF Core Entities DogEntity { public string Nickname; public List<DogOwnerRelationEntity> Relationships;...

is linq capable of utilizing AVX1?

for operations such as sum/min/max/avg

Android SafeAreas changed from MAUI 8 to 9

Hello, I just upgraded from MAUI 8 to 9 and the "SafeAreas" disappeared. iOS has a UseSafeAreas property in iOS PlatformConfiguration. But in android the pages are now behind the android statusbar where the battery, wlan, etc. is. How can I fix this for android? If this matters - I'm still using NavigationPages instead of the new Shell. Did not have time to refactor this part yet.

When is it better to use Redis transactions?

Hi, With some help of AI, I am trying to learn the best practices for making a cache service with Redis. Currently, I am not quite sure when I should be making use of transactions, as I am getting conflicting answers from GPT and Claude for my specific method....
No description

Hi everyone 👋 I’m new here and focusing on improving my C#/.NET skills.

Quick background: I’m an engineering student in Computer Science & Networks (MIAGE option), graduating in 2025. I’ve worked on several academic and internship projects, including desktop apps in C#/.NET (WPF, Entity Framework, SQL Server), as well as web and mobile development using React Native, Angular, Spring Boot, and Python/Django. I also have some experience with Azure, Docker, and Git. If you were in my position, with this kind of background, what would you choose to specialize in to boost your career — going deeper into .NET, moving into DevOps, focusing on cloud (Azure), or something else? I’d really value your advice. Thanks! 🙏...

✅ Needing help with VS Code and postman

I am currently trying to create an app, am very new to it and want to know what im missing and how to navigate effeciently

✅ writeline and write for console question

so I was following a tutorial for C# beginners, and their code in the image has "Conosle.WriteLine();" before the "Console.Write". What is the point of doing that? i had tested the code and it runs fine without the use of the blank writeline.
No description

C++/CLI Dependency Issue

I'm trying to create a CLR project to utilize a C# class library in a game engine. I'm fairly certain the issue is on the C# side and not the game engine itself, my familiarity with the language and Visual Studio is extreemly limited so I haven't been able to make much progress on this problem for a few days. For reference, the project repo is here: https://github.com/ChronoVortex/GameMakerModManager

✅ MMTP(market message transfer protocol)

Hi guys, has anyone ever heard of the MMTP (Market Message Transfer Protocol) and managed to implement it ?

✅ how do i check when a slider is being dragged?

everything i've already tried either doesn't work or has some bug with it :zena_sad: