C#

C

C#

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

Join

✅ Weird VSCode & WPF bug with C# Dev Kit

Im trying to make a WPF app in VSCode (im trying to make it without XAML though i didn't remove any of the XAML files) and this error keeps appearing in my VSCode This problem is not present when i debug or build the project, it is only an intellisense problem Using C# Dev kit & C# extension...
No description

Insert into Access Database

Hey all, I've been trying to Insert into my access database for some days now and I'm still getting a syntax error which I have no idea why, my connection works I was able to delete buy I cannot add for some reason

✅ How to enable json mode for gpt-4o?

I'm using OpenAI dotnet oficiall API and want to make sure that output of the model would be only in this format.

Possible race condition?

Maybe I'm just totally off but... I'm not sure whether _credentials is implemented safely. I've been reading a lot on how async works under the hood (specifically the task scheduler) and I don't know whether this variable would be susceptible to a race condition if AuthorizeUserWithCodeAsync is called in rapid succession (see this endpoint which will be calling it). My fear is that if this endpoint is called in rapid succession, _credentials could be accessed or overwritten in an unintended way. Is this just a lock and move on situation or is this actually safe?...

✅ Creating random & unique page id

I want to generate id for a page that will be used to access it, something like example.com/2121424221. But generated id should have about 10-15 digits and be unique. How could I do that?

need help with binary serialization

Hi, need help with binary serialization, I need to pack game assets into a bin file the data can be class contain other classes or struct with list of other data
No description

Flyout Styling (Avalonia)

anyone know how to style a flyout? I want to animate the width and height of my control in the flyout I want my control to grow when the flyout is open and shrink when the flyout is closed...

Entity Framework Foreign Key restraint

Hi all, I'm trying to make an appointment scheduling system. The appointment section has its own database linked to a patients model and an appointment model. The error happens when I try save a new appointment - ```cs...

Overlapping sounds with mediaplayer?

I was just wondering if i could overlap sounds, like having a background music file playing and then having a sound effect play overtop of it at the same time. Whenever i try to do this it cuts off the background music. I just provided a image of what im using for clarity....
No description

WPF System.IO.IOException: Cannot locate resource 'mainwindow.xaml'.

Running the application crashes, leading to the first screenshot. The application is new and I recreated the MainWindow to try to fix it. In the 2nd and 3rd screenshots you can see that there is nothing in the classes.
No description

.NET 8 | Out of memory error in ActionBlock.Post (plenty of memory available)

Running Blender which is running a pythonnet which run my .net8 dll which just called the initalizer for a free C# game engine called FrooxEngine. Doing this on Ubuntu 24.04 How do i debug this? It seems like the issue is in the .net 8 VM c++ code. Im guessing that i can get debug symbols for libcoreclr.so and debug it with GDB, but how?...

✅ PdfPig

I don't know what I am doing wrong. I am trying to generate a PDF document and attach an image (PNG) to the PDF Document. The problem is that I keep getting an index out of range exception. I did the math, and the points I use for the image coordinates are correct (At least, I am 98% sure). This is what I have: ``` private const double POINT_VALUE = 2.83465f;...

WinUI 3 controls project dll misses XAML resources

Guys, I need a help with WinUI 3: I have solution with APP project and controls library. App project has defined all ResourceDictionaries.xaml and consumed in App.xaml - all they work correctly. Controls project has also a multiple ResourceDictionaries.xaml for each control and all they are combined in Themes\Generic.xaml ...

Webcam

So I am trying to make a horror game and for a jumpscare I want to take a photo from the webcam, and paste like a monster in the background of the picture. Now how would I even take a photo with the player's webcam?

Avalonia Data Trigger

Does anyone know if you can do data triggers in avalonia what i want to do is change the background color of a button if it is selected or not or could i do this with a checkbox but i want to change the check box to a star or some type of shape ... the shape would start out not filled and if it is selected then it would be filled ... can you change the shape of a check box?...

InstagramApiSharp

iam trying to login with user pass that give me challenge require error when i solve it in phone(taping it was me) and try login again i see this error how i must handle it i want all of challenges get solved in phone after that continue process and login

count positives and sum of negatives

hi, im doing an excercise that given an array of integers, I have to return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers. 0 is neither positive nor negative. If the input is an empty array or is null, return an empty array. i've been on this excercise for over 30 minutes but i cant figure out how to do the last step (If the input is an empty array or is null, return an empty array.) can someone help me out figuring out what im missing/ doing wrong? ============= using System;...

✅ Get bytes and append to List c#

```cs public class ByteWriter { public MemoryStream Stream = new MemoryStream(); public BinaryWriter Writer; ...
No description

Save button does not save the inserted data

So I have created a save button in my insert view as per screenshot The code behind it does not save as I wanted The view lets me insert any value but the button does not save it onclick. Once clicked there is nothing happening there, even no error messages. My code here https://pastebin.com/7LyeZxtt Could anyone kindly point me in the right direction?...
No description

✅ How to specify camel case for all response properties with Newtonsoft

This is the type of JSON I receive from an external API: ```json "phoneValidation": { "success": true, "data": {...