C#

C

C#

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

Join

Changing the default css for Identity pages in a Blazor Server app

Is it possible to change the default css for the Identity pages in a Blazor server app? I'm pretty new to Blazor, coming from Razor, I'm not sure why this is so complicated?

Setting up Azure OpenAI in my school project.

So i've been trying to set up Azure OpenAI in my school project and i feel like i've walked into a brick wall. I've managed to find a quota for my model and managed to Deploy the Assistant, but its not showing up in the Assistants field. Anyone with some experience with this?...

asp.net web forms

my global .asax form did not have // Initialize the product database. Database.SetInitializer(new ProductDatabaseInitializer()); what exactly does this do and do i need it ?...
No description

When to use a static helper class vs extension methods

When adding a static class, what criteria do you use to determine if it should be a helper class or an extension class? For example, I have a recursive hierarchical data structure (has Children list of more of itself) and I want to write methods to help searching and iterating through it. I could have a helper class like: ```...

✅ Visual Studio Doubt

Hello, folks. I have a question; I am new to programming in C# and.NET and have never used Visual Studio. How should I approach learning about it?

What security restrictions do anti-malware place on Windows processes?

Hi, I have an odd scenario where behavior is different on a computer with tighter security (e.g., endpoint protection services) . I have a .NET 4.5 app that uses Concurrent Dictionaries to track WIndows Service Status via Service Status Notification Callbacks (interop with Win32) . The logs show the call backs are working and correct and no errors or issues occur when the callback handler updates the ConcurrentDictionary. Overall logs (Win Application Log, Win System Log) show no runtime errors and endpoint monitoring system have not flagged the app in its' logs. The problem is that downstream (thread pool) tasks don't seem to have the correct service status. Currently, this problem is isolated to a single machine; other machines don't have this issue. I assume this is a defect in my logic, but I don't understand how it could work in other operating contexts, except for one machine. The app is running under the SYSTEM account as a Windows Service. Code that updates dictionary included. I have no idea what to look for from a security point-of-view. I am examining the process token privileges - what else could be different?...
No description

✅ IndexA and IndexB is nonexistent, don't know why

Hey, can someone look at my code real quick, please? I have no idea why it keeps saying that it's does not exist in this context. Here's the code: https://paste.mod.gg/ztfipbxurtap/0 (IndexA and IndexB is declared on the start of the code)
No description

Visual Studio and Unity C# integration issue

WHen opening scripts from Unity into Visual Studio the intellisense is not working. I have set it so Unity correctly opens Visual Studio 2022 for scripts. I have also made sure that the "Game Development with Unity" package is installed and on my current VS version. I have tried adding extensions like "Unity Code Assist Lite" from the extension manager, and in Unity I have tried "Reimport All" and have made sure that the "Visual Studio Editor" in package manager is up to date. The scripts all wo...
No description

Aspire and PgAdmin

Hi I'm trying to run PgAdmin but it is failing to connect and I am unsure why. ```cs IResourceBuilder<ParameterResource>? postgresPassword = builder.AddParameter("postgresspassword", secret: true); ...
No description

✅ How to optimize this code?

Hello, I'd like to optimize my code. The best time I got: 00:00:00.536 with chunks count = 256 536ms actually is not too bad but is it possible to speed up method? ```cs private async Task<IEnumerable<JsonNode?>?> GetDmnTasksAsync(IReadOnlyList<PassengerArrivalChunk> chunks) {...

browser-wasm hell

i'm trying to use raylib with browser-wasm and i get error whenever i try to call something from raylib: `` MONO_WASM: at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object , Span1 , BindingFlags ) ManagedError@http://localhost:52900/_framework/dotnet.runtime.js:3:26843 Jn@http://localhost:52900/_framework/dotnet.runtime.js:3:31615...

SignalR Call Outside of Hub or Controller

I am on .net 8 I am using Microsoft.AspNetCore.SignalR. My issue is that I am trying to send a message to all clients but when I am getting the service it says there are no connections....
No description

What can i use a check box and combo box for on my maze game? C#

i have an assignment and i dont know what to add and kinda need some help im pretty new.
No description

recursion

so I need to make a fibonacci sequence using recursion but bro idk how u achieve that??

Message header must separate key and value using ':', OmniSharpLSP

I get the typical err message for when your JSON rpc is somehow unformatted, but here the thing is I'm using OmniSharp, I could see how it could be a buffer issue if it was from scratch but your telling me Omnisharp doesn't handle that (doubtful)? I see no real problem with the way I currently have it set up, although every implementation I see does something completely different

Use DateTrigger to animate width of a Grid Column

I've linked the desised result I'm trying to make a grid collum occupy most of the window when the user's cursor is over a 'border' element. However, I can't get the CollumDefention width to change...
No description

Can I catch an error from Task.Run to stop threads crashing main program?

I have a bot that is meant to support multiple platforms like (Twitch, Discord, Spotify, Etc). I do this by loading them all as .DLL files. I've tried my hardest to make sure that any errors in commands from modules doesn't crash the bot, but the issue is that if the Task Initializing has an error, it would cause the main program to crash because the Try/Catch that starts it doesn't work because it's on a separate thread I assume? Anyway I know I could catch an error in each modules Initializing method to prevent this and to end the task gracefully, but I'd like to make the bot impervious to being crashes by any modules. I don't want to rely on the modules themselves to do it. Is that possible? If so then how?...
No description

Can't assign a method to a list, is there a way to get a list to execute code?

So in this turn based video game I'm trying to develop, thanks to some help from users on this discord earlier, the characters can now be selected and so can the Monsters. My new roadblock now is I want to change the selection menu in the game from a switch statement to a similar selection I have going with hero and monster selection, this will make it so that the command list can be any size I want, where as a switch statement is fixed and hardcoded. Unfortunately I can't wrap my head around trying to put the options from the switch cases into a list. A list only accepts Int's and strings, not methods. So it can't execute code. I'm not sure if I can assign an int nor string to a method either. First image is a visual representation of what I want it to do on a whiteboard, second image is the method, third is the hero selection, fourth is the skills class and the fifth is what the switch statement looks like that I'd like to switch into a foreach. As far as I'm aware array's can't execute methods either so I can't just make it an array instead. Also I'm currently assigning the skills to each character via a set of int's (though it could be strings too). Then I will have the computer read each number to determine if the character has that skill or not. So first number determines if they can attack, next number is defending, third is dodging, etc... This doesn't seem like a good way to do it but I can't think of a better way to assign skills to each hero....
No description

Where did I go wrong in making a loop of this 2D array?

So I spent a while trying to loop through my 2D array and draw my texture for each place in the array, eventually making a 15x15 grid, and I got to it in the end eventually with help but don't understand what I did wrong in my original code?
No description

Loading Form crashing (Windows Form)

So im doing a pdf viewver using winform. I wanted to add a form that indicate the progression when loading the pdf pages. The problem is that the application crash during the for loop, and the loading form is not showing up before and its showing at the end of the loop but this is useless since the content is already loaded and it close immediately. I've tried many thing like using Task.Run but i cannot fix it. (pls help)