C#

C

C#

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

Join

Beginner in C# – Need a Learning Path for Backend Web Dev

Hi everyone! I’m new to C# and want to focus on backend web development. Could someone suggest a step-by-step roadmap or resources to follow? Here’s what I’m looking for: 1- Basics of C#: Key concepts to master first (e.g., syntax, OOP, async/await). 2- Databases: What to learn (SQL, Entity Framework Core, etc.)....

[WPF/Chromium] How to modify a page displayed in WPF's HTML through background code

Learning WPF, using Chromium to have the application fetch a page and display it, and I'd like to be able to retrieve the entire HTML source of the page and edit it, as if doing it manually through inspect element, then feed it back to the display so its updated.

How to save signalR chat messages to database

```csharp public async Task SendChannelMessage(string channelId, string content, List<IFormFile> attachments = null) { var authorId = Context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value; var result = await messageRepository.CreateChannelMessageAsync(authorId, channelId, content, attachments);...

[C# console app .net4.7.2] Seemingly can't instantiate an object

Okay So I'm working on a text based adventure app for an entry level college class. I have an "Alien" base class which is inherited by a "CrabAlien" class, I'm trying to instantiate a crab alien in my "GameWorld" class but it's telling me that none of it exists in the current context and I'm not sure why. I'm sure it's something stupid I'm missing like some sort of permission level thing, but I just can't figure it out
No description

Warning about Trimmers and XmlSerializers

My library uses a trimmer to handle complex XML. But when I turned on code trimming for it, it showed warning IL2026: [...] Members from serialized types may be trimmed if not referenced directly., the code looked like this: ```cs [Serializable] [XmlType(nameof(MyData))]...

c# API + angular front end

Hi, This is more of a design question... I have a web api written in C# and a front end writtein in angular. The web api has a settings file associated with it. The web api and front end are both served by kestrel (same port). The front end has some settings as well (in the assets folder). One setting, for example, for the front end is a theme. The theme can be changed using the front end, where it makes a request to the API to set the theme setting....

[ASKING FOR JS] Javascript wont load after post refresh

this is offtopic cuz Its more about javascript, why do whenever I post refresh the second time, it wont execute my javascript code..but if I want it work, I have to refresh it or redirect to it.. ```js <div> <table>...

Query Rider TODO etc. comments for a solution, project, or file into console output

The TODO list Tool Window is very useful, but I would very much like the ability to pull that list into a markdown file as tasks for an Obsidian markdown note. Any ideas on how to do this, or must I copy the TODO patterns and filters into my SourceReporting Roslyn based app and apply the filters to all comments in a CSharpSyntaxNode or something?

I have a huge exam next week

So I have this huge exam next week as well as two projects that are due next week. I’m new to c # and everything seems so picky and confusing. I’m so overwhelmed by everything. Can someone please help me...

Code Forces Problem Way Too Long Words

So I am trying to solve problem way too long words from codeforces here 's the link to check it https://codeforces.com/problemset/problem/71/A now in my code i have created logic for word which have more than 10 characters would become in a special abbrevations and words which are less than 10 characters would be print as it is but i am not able to filter and remove int if user inputs integer with string here is my code ...

SignalR

await _hubContext.Groups.AddToGroupAsync(HttpContext.Connection.Id, "MND"); await _hubContext.Clients.Group("MND").SendAsync("InvokeNotification", User.Identity.Name, "responseMessage"); Not working and I can't find out whether the user is added to group or not...

Switch Expressions

Im trying to convert different numbers in a switch expression while switching over a Type and noticed a strange behavior, that when I do an int.Parse(...) Im actually getting a double out of the function, see my example here: https://dotnetfiddle.net/QrgZqP why is this designed this way?

Webview2 missing from toolbox

Tried to manually add it by right clicking and choose item -> browse and add the .dll manually as shown in image but i get an error i tried pre-relases and older version everything, edge is updated on my computer and i am running vs2022 community any tips?...
No description

I dont see the problem?

Can someone help me see the problem? i attached some photos....
No description

Microsoft Visual Studio autochanging a line of code because its "obselete" but the AI ruins the code

so intellisense change rb.velocity = new Vector2(speed * x, speed * y); to rb.linearvelocity= new Vector2(speed * x, speed * y); This ruins the code because linearvelocity messes up 2drigid stuff. How do i turn it off?...

Cant import scoped Javascript in Blazor Standalone WebAssembly

In the past I have already done this in InteractiveServer Blazor, which is to import {page}.razor.js in my razor page through IJSRuntime in the OnAfterRender step of the page lifecycle. as follows: Page.Razor.cs ```cs...

Worker Service .NET8 how to gracefully shutdown as a docker container

I'm a junior developer just starting to work with Docker, and I have a question regarding graceful shutdown of the worker services. I created a default worker service in Visual Studio, and my Worker class looks something like this: ```csharp...

My Database doesn't appear to be populated, yet when I run my program, the website does show correct

The information from my database initialiser does show up on my website, but when I look in the SQL Server Object Explorer, there seems to be no data Initialiser Code if it helps: https://paste.mod.gg/bxebrzqarvwn/0...
No description

Launch an api project multiple times with different appsettings with Aspire

I have an asp.net project X which should talk with multiple other asp.net projects Ys. I would like to start them all with Aspire, but I would need to give every instance of Y its own appsettings. Is this a possiblity with Aspire? I saw that I can run a project with different launchprofiles, but I'm not sure how that could help me in my situation. Thanks for the help!

✅ Dependency restores to incorrect package

I have a dotnet solution called A.sln which depends on another solution B.sln. Both A.sln and B.sln have some child projects which has some const value differences depending on the platform: * A.Win64.csproj, A.Win32.csproj, A.Posix64.csproj, A.Posix32.csproj * B.Win64.csproj, B.Win32.csproj, B.Posix64.csproj, B.Posix32.csproj ...