C#

C

C#

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

Join

Using Blazor WebAssembly for client interactions in Blazor Server

Hello all! I'm building an admin dashboard sort of application that heavily interacts with the server, so I'm using InteractiveServer rendering by default. For small client side interactions such as a collapsible sidebar, it seems like there are a few options: - Use JavaScript (with or without a library such as Jquery or Alpine) - Use HTML + CSS "hacks" such as the checkbox method that ships with the default Blazor template ...

Easy to use C# audio library for spectrum analyzer?

Hi, I'm making a spectrum analyzer and wanted to know what's an appropriate audio library. My goal is to get the audio level of the desktop at a specific frequency at a decent rate (5-40ms). I specifically want the real-time desktop audio, not reading a file....
No description

Connection strings in WinForms?

How can I use the Connectionstring more effectively and securely in basic Winform C#?

decimal celciusDiv not working and being used as 0 when casted as int

Trying to convert from farenheit to celcius and it just isn't working and I'm not sure why exactly. i can't multiply by a decimal variable it seems so have to cast as int. It then seems to result in celciusDiv becoming 0 instead of 5.0m/9.0m. It's a logic error as well so it won't even tell me why it isn't working.
No description

I'm getting a .NET MAUI converter error

"Converter failed to convert value of type 'Windows.Foundation.IReference`1<Microsoft.UI.Xaml.GridLength>' to type 'Double'; BindingExpression: Path='TemplateSettings.CompactPaneGridLength' DataItem='Microsoft.UI.Xaml.Controls.SplitView'; target element is 'Microsoft.UI.Xaml.Media.Animation.SplineDoubleKeyFrame' (Name='null'); target property is 'Value' (type 'Double')." I encounter this error when trying to pull data from ViewModels into my XAML file. I have three ViewModels, all inheriting from a BaseViewModel. Since I need to retrieve data from all three ViewModels in a single XAML page, I created a ParentViewModel and referenced it in the page. However, when I navigate to that page, I get this error....
No description

microsoft visual studio 2022 professional

I cloned a GitHub repository and followed all the configuration steps as outlined in the documentation. However, I'm encountering an error: NU1101, unable to find telerik.zip and telerik.documents.flow. The error message indicates that no packages with these IDs exist in the sources: ABC Artifactory, Microsoft Visual Studio Offline Packages, and NuGet.org. Since ABC Artifactory should already handle Telerik packages, I don't think I need to add Telerik to the package sources separately. Despite trying multiple times to clean, rebuild, and restart, I'm still unable to resolve this issue. I'm not sure what else to try. I also tried to restore NuGet packages but that is failing as well....

How does one typically handle complex program flow?

I seem to be running into a weak spot in my C# journey - that being project management and workflow design. Embarassingly, I'm in a bit of a head scratcher as to how to handle a moderately-complex flow of an application. I thought this would be a cakewalk - I've dealt with a lot of nitty gritty problems with C#, how hard can simple control flow be? Apparently, it has hands....
No description

ASP Publish

Bro, I want to ask if anyone knows how to publish an ASP swagger file When I publish, it always gets a 404 error...
No description

✅ whats up with this console output

``` Value yellowThresholdWidth == 195.42857142857144 redThresholdWidth == 684 barWidth == 760...

SQL help

When trying to update a value in my database I get the error
No value given for one or more required parameters.
No value given for one or more required parameters.
however I heard this is common and usually means the SQL statement is wrong...
No description

✅ Windows Audio Capture

Building an XAML application. The eventual goal is to capture an audio source and stream it to another application using webhooks. This is my first time doing: 1) XAML 2) Audio anything...

✅ EFCore 8 MySQL - Table doesn't exist, but it does?

I'm trying to use EFCore to integrate with an existing database, but apparently the table doesn't exist, even though it clearly does. I'm manually writing the class for Products since EFCore didn't automatically generate it. What the heck is going on here?...
No description

Web-based game with ASP.NET

In the game, I want to include NPCs and implement AI so that they can make their own decisions. I want them to autonomously decide on actions such as assigning workers to mines, assigning workers for agriculture, making diplomatic agreements, etc. What would be the best way to achieve this? Would it be sensible to use C# ML, or is it better to write a service?

Console.WriteLine does nothing

So i am away from my PC for a bit, and so i moved to my laptop to code there for a few days. However, for some reason the same project that i was working on works on my laptop, but just Console.WriteLine does nothing anymore. It also is not the IDE that is the problem. In fact, i could even open the project in my cmd and run dotnet run and all the Console.WriteLine() do nothing. ...
No description

Blazor Static SSR - redirect after form submission

I woudl like to redirect user after successful login. However, after NavigationManager.NavigateTo, it throws an exception. I tried to find any useful information, but I found nothing. Here's my HTML form: ``` <EditForm Enhance="true" Model="LoginEmployee" OnSubmit="HandleSubmit" FormName="Login">...

✅ JsonSerializer ignoring encoding options?

This issue has been driving me crazy for the last hour. I have a json object that includes a string with an apostrophe in it, however it keeps getting converted to a unicode code. After some reading I found this was the default behaviour for the serializer and can be overridden with encoder options, however I have been totally unable to override this behaviour for some reason. This is the dotnetfiddle snippet I've been testing with https://dotnetfiddle.net/7VZABE. Am I doing something wrong here?...

Is there a method that throws an exception if a config value is not present in appsettings?

Hello, Getting configuration values from appsettings.json is done via calling builder.Configuration["name"]. This way few of my services might get a null property, without throwing error before build. Is there an existing method that will throw an exception if the config value is null?...

Scaling c# win Forms

so i have a problem when i maximize my screen i get this layout , which isnt ideal cause of the unnecessary space , i wish it be the first when its maximized
No description

Error 500.9 when I expand httpRuntime size

I have a error problem, and how do I solve it..I got error I tried to allowing website to upload more than 10mb..so I put ``` <configuration>...

✅ My RESX file still is supposedly invalid

You might remember I have a RESX file that VS refuses to open. Furthermore, the ResXFileCodeGenerator tool also claims it's invalid. I compared it to a RESX that I know works and don't see anything. Can someone take a look at it. This is what I see in the csproj file. ```XML...
No description