C#

C

C#

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

Join

Graphic Editor using WinForms

I have to create an application in winforms. It will create a polygon in the top of the image to colorize the image. What Control to i really need to build this application.
No description

creating migrations on an existing DB to add a column(efcore)

so I have a webapi project, dotnet 8 efcore 8 and postgres project was DB first and hence scaffolded. now I wanna add a property to an entity of mine AND/OR add a column to a table I have always done db first and never done code first and have never touched migrations. tried adding migration but doing so it wants to create all tables with updated columns. tables already exist and have data I'd rather not lose (though it wouldn't be end of the world as it is a personal project for learning) so wondering how can I add a column without dropping my tables and not updating my table with sql command scaffolding it again. Most resources I've found involve somewhat hacky way of adding migration and deleting the content in up and down methods in migration though I don't understand how that might help ?...

Missing logs in Aspire after changing env and IDE

Recently I made a move from Windows device with VS 2022 to a MacOS and Rider. For some bizzare reason all app console logs stopped being monitored. For example the 1st API call trace is being logged but everything afterwards is not. At the same time I can see all the logs being written to a server log file. Any idea how to fix it?

✅ StreamReader returns empty string on valid file stream

I have this code:
using var reader = new StreamReader(stream, Encoding.UTF8, false, 0x400, true);
str = reader.ReadToEnd();
using var reader = new StreamReader(stream, Encoding.UTF8, false, 0x400, true);
str = reader.ReadToEnd();
...
No description

get playing track title

if i have some app playing music on my computer (NO API IN THE APP) can i get the song name from windows NPSMLib HAS NO documentation or else i would just use it...

[solved] How to mark this post as solved

how can i add a libary from github to my project on vs2022

2048 android project

Im making a 2048 school project, I dont really know xamarin in visual studios that well so im kinda reliant on AI tools, and help from friends. I want a log in and register system and I have the code for it and have already linked my project to firebase services, but there is a runtime error, something about multiple protobufs? Pretty sure my net version is 8.0 or 9.0 (not sure), and im using firestore to do this log in. I also have a problem with animating blocks that I would like help with but that is less of a priority. I need help solving the protobuf issue and make sure that the firebase is working...

✅ Docker Container Can't connect to remote SQL Server

Currently I have a Worker service that will interact with a sql server on a remote server. when it is deployed to my local machine, it works. But once I deploy it as a docker container, it fails the connection and printout this error
Main loop Exception: Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)
Main loop Exception: Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)
I have tried to search online from stackoverflow and in docker community, I have checked the firewall and tried different combinations compare to their post but it still did not work out......

Should I use lock to update element of ConcurrentBag?

I have following code: ```cs using System.Collections.Concurrent; var obj = new object();...

✅ [SOLVED] app hangs during JSON serialization

Whenever the program gets to the part where it has to read or write to file, it succeeds but then doesn't continue farther

✅ Program is running in rider but I kept having the red line on my file names

Hello guys, can someone explain why I kept having the red lines as if my files contain any errors please. The project does run though. I even invalidate all caches and restart
No description

Mixing `Volatile` with `Interlocked`

I believe this is safe to do so, but I'm asking this just in case. ```cs private int refreshing = 0; private void RefreshLobbies()...

✅ Can't update database in docker.

I'm very new to docker, but I've setup 2 Docker files one for my api and one for my client, and i can run them an access both but my database is always empty, and I can't run any ef commands to update or apply migrations and I have no idea why, it keeps saying I don't have the SDK but I'm almost positive in my Dockerfile I'm bringing in the SDK. ``` $ docker exec -it ripple-api dotnet ef migrations add InitialMigration The command could not be loaded, possibly because:...

[SOLVED] Integration Tests | .Net Core WebApi | Fails seeds data when overriding a service in a test

Context: I've coded a custom WebApplicationFactory to setup a web host configuring an in-memory database and seeding data for User table. Expected Test: Ensure global handling exception when an exception is trown in GetById() userService method. Issue : When I run it, it fails in dbContext.SaveChanges(); logging that it couldn't seed the data, I've debug it and saw that it only happens after overriding the service. ``` Message: ...
No description

How to get regex matches between optional start and end tokens

I have a massive string with occurrences of the strings do() and don't(). I have to find all text before a don't(), ignore all text after it, until another do() or end of string, then all text from that do() until another don't() or end of string. So far I have this (.*)don't\(\).*do\(\)(.*) and I'm processing it like this: ```cs var rx = new Regex(@"(.)don't().do()(.*)"); var matches = rx.Matches(Input); foreach (Match match in matches)...

BCrypt lib functions not working

I'm learning how to do a bank login and i'm tryning to save the password by hash but this functions are not working
No description

ignore this not a help question( gpt prompt that I use)

Act as my personal strategic advisor with the following context: • You have an IQ of 180 • You’re brutally honest and direct • You’ve built multiple billion-dollar companies • You have deep expertise in psychology, strategy, and execution...

How to uninstall windows service on UWP app uninstallation?

We have following things: 1. UWP app 2. Windows service 3. Msix bundle app package (packages both UWP app and windows service) ...

Issue when deserializing web response

Hey, I'm making a simple call to the api and looking at the text reponse it looks correct (check first image). ```cs HttpResponseMessage response = await client.GetAsync(nextPageUrl); string responseBody = await response.Content.ReadAsStringAsync(); ...
No description

Native AOT Shared Library - Correct Typing for Struct Pointer Parameter

I'm trying to define an exported static method to conform with the following procedure: void retro_get_system_info(struct retro_system_info *info) Currently I'm defining my method as:...