C#

C

C#

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

Join

Temporary Pause

I am using .NET 8 I've got an ASP.NET API that i would like to pause. The goal of this is to prevent any endpoints from being called for a short amount of time. I could do this procedurally with a constant variable that's checked, but I would rather not send nothing. Is there some kind of HTML code i could return that would indicate that the API is offline but like on purpose? Instead of just returning nothing. ...

Storing types as strings

I need to store a Type as a string, then convert it back to a type. How do i do this? I've tried Type.Name then doing Type.GetType(typeName) but this returns null

SQLServer Express in docker - can update DB, but cant connect

I have a SQLServer Express in a docker container and my small (still learning) app in VS 2022. Ive used Update-Database in PMC and it works fine. When I try to hit my simple GET route (built-in swagger) Im getting errors that "the server was not found" - implying it cant connect to SQL. Connection string seems fine since I can update/migrate DB. ...

Run Powershell inside VS

I am using VS 2022 with .NET 4.7.2. and I want to run the debugger inside VS instead of having the terminal open as a new Window
No description

✅ Error code 127 (Windows)

IntPtr hKernel32 = GetModuleHandle("kernel32.dll"); if (hKernel32 == IntPtr.Zero) { Console.WriteLine("Failed to get module handle for kernel32.dll. Error: " + Marshal.GetLastWin32Error()); return false;...

✅ C# linux

I have created a solution and created interface file IEmployee.cs now I want to inherit this file in newly created IEmployeeBase.cs in visual studio code

admin but no access?

pretty new to coding, got done making a .net windows form app that downloads files from github to a folder in program files x86, required admin perms, and it just will not download. (error message below)
No description

New in the game

I started to learn C# / HTML. Any time saving advice and some more u would like to say to a rookie? https://tenor.com/view/cat-wif-hat-catwifhat-cwif-gif-17193762039885744356
No description

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...