C#

C

C#

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

Join

Tilemap control in MAUI

In WinForms I have a TileViewer control, which basically just displays a Bitmap on the background image. While reacting to mouse events, I can leverage the Graphics object from said background image to draw a tile cursor and other things over the image. All together, this works as a fantastic tilemap editor for old games. In an effort to port such an application over to MAUI, I now need a replacement for such a tile display. So far my search was unsuccessful. It seems like no one has wanted this before and ChatGPT started halucinating some Draw functions that do not exist when I asked it the same question....

How to make a sliding panel animation on Avalonia>?

Hi, im working on a avalonia project , but its similar to wpf i have a login panel, (username password etc) but id like to add a sliding animation to that to make it look more professional, how would i do this?...

How to break programming plateu

Been programming for 11 months learnt the fundementals of c#. and chose a ui structure (wpf/ avalonia) but then what? i feel like i almost know nothing, bulding stuff is hard. doing easy problems on leetcode is even harder, i almost feel like im learning nothing like ive been stuck in tutorial hell...

I am trying to add a custom cursor to my winforms app

i cant figureout how to do it and when i look it up its not working

Need Unity audio help.

So basically i have 5 audio clips for walking that i want to play when walking, crouching, and sprinting. I also want it to change randomly in pitch, and frequency depending on what type of action im doing. Finally i also want the sound effect to be randomly chosen from the 5, some help would be majorly appreciated.

Using code to reference code

So I have a collider, and I have code elsewhere that tells my UI counter to go up. That code lives in LogicScript and it's called addScore. I'm trying my best to reference it within my collider's script using the tag "Logic", but there's definitely something wrong with that big logic = line as well as the logic.addscore line. Does anyone have any advice? :')
No description

Priority queue, queue empty error.

Hi, I am getting an error when trying to use the peek method that says that the queue is empty. However just before this I use the enqueue method to put something into it. Why is this error occurring?
No description

The good way to store user info

I'm making a web app for apartment reservation and i have those models: user, apartment(has fk user), reservationDate(pk is date+apartmentId, fks: user, who reserved this date, and occupancy, to what associates this date), occupancy(fks: reservedBy, apartment, and collection of reserved dates). First I display apartments list that fits to the requested date range (in the service I filter query to get apartments with requested dates in 'empty' state). When user choose an apartment from apartments list and then hits reserve button, I want to create a new occupancy instance and change dates states to 'reserved' (there only 2 states: 'empty' and 'reserved') and add wire this occupancy to user. ...

✅ Unit of Work for just Repositories or Services as well?

When you create a unit of work and you add repositories inside of it so you aren't constantly newing up additional ones across your applications, should services also be added to the same unit of work? Another unit of work or not at all? I don't see the harm in adding services to the unit of work so would that be a valid thing to do or will that cause issues somehow?...

how to see the console programm output in vs, WPF

I've got some Console.writeLine stuff but I can't find the console where it is displayed ! thx for any help

Having an issue implementing A* pathfinding

Hi, I am trying to add pathfinding into a game that I am creating and have tried to use the A* pathfinding algorithm. It kind of works as it does eventually find a route however it can take a very long time when nodes are far apart and when I look at it when it searches it looks like it goes over the same nodes over and over again and I'm not too sure why? My guess is that I am exploring nodes that are already in my closed list. I have added the code as an attachment to this post....

Visual Studio Settings

So, I installed VS in a new computer, but it now lacks the feature from the pic above: it shows the Type of the variable IEnumerable<EntityEntry> and EntityEntry, without needing to hover at it. I remember activating it, but I forgot exactly where in the Visual Studio Options....
No description

Issue with not being able to register with google ReCaptcha v2

so I wanted to implement google recaptchav2 in my project but while doing so I got a problem where when I add click register button I am not able to register and it just reloads then when I want to the console to look for problem I saw Migrate entirely to Https to have cookies sent to same-site sub resource as issue what can I do to fix this ...

✅ How to hide sensitive data, like database credentials api keys etc

I know you enter this stuff in your appsettings.json, but from what I can see your apisettings.json gets stored in your gitrepo, so is there something like a .env file in the .NET ecosystem where i can store everything in there omit it from git and then load that data into appsettings.json? Everything I found so far is talking about setting the variables in an azure key vault or setting them inside of the terminal, am I missing something here? I'm just developing locally atm but even if i deploy this app, i dont think I will be using azure because of how expensive it is and would like to not use the key vault because of that, but at the same time i dont want any of this to be on my git repo for random ppl to potentially see as well....

Issue with JSON serialization of a nested dictionary

I can update the allMediaSource nested dictionary fine and vs2022 debug shows it has new values, but when I serialize the nested dictionary, it has original values ```Dictionary<string, Dictionary<string, Dictionary<string, string>>> allMediaSources = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>(); string jsonString = Properties.Settings.Default.MediaSources; if (!string.IsNullOrEmpty(jsonString))...

Help Needed: Issues Compiling and Running Avalonia App on macOS

Hi everyone, I'm having some trouble compiling and running my Avalonia app on macOS, and I could use some help. Here's a summary of the steps I've followed and the issues I'm encountering: Creating a New Project...
No description

Strange Marshalling issue

Hi, I'm hitting a strange issue. My Handle_t type, which simply contains an Int32 is the same length as an Int32, as expected. However when it's included in another struct and it's size is checked, the size is incorrect. See below code sample: ```c# using System; using System.Text;...

MySqlException: Table 'searchhome.aspnetusers' doesn't exist

So I wanted to do the following: I have already created a simple database with a table. On that db table some values have been added. I wanted to display that added value on my simple ASP.NET Core app. However, the dotnet run gave me the error as per screenshot attached (aspnetusers does not exist) The dotnet ef database update leads to the same error (aspnetusers does not exist). I have tried adding that aspnetuser table or tried updating the database( INSERT INTO __EFMigrationsHistory (MigrationId, ProductVersion) VALUES ('00000000000000_CreateIdentitySchema', '7.0.2');) None of these helped me out....