C#

C

C#

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

Join

EF Core not creating migrations

The title says it all. I'm running Add-Migration on Visual Studio 2022, but I'm stuck on the output: ``` PM> Add-Migration Initial Build started......

From WPF to Avalonia

Hey, i have a little question that somebody might know the solution to. Or a different way of dealing with it. So basically we created a WPF application, and we are not turning it in to an Avalonia application instead because we want it to be multiplatform. For this we thought we would have both WPF and Avalonia up and running at the same time while we are moving everything over. This works and makes it moving over really easy. However, Rider's intelligence in the xaml files are wrong. ...
No description

SemaphoreSlim wait without creating a critical section

Hello, I don't want to have a critical section, instead I should have a section where all threads are blocked until the semaphore is released. When it is released, all threads should start executing the section. For this semaphore.Wait() is not good, because threads will execute the section one by one. The outcome should be: No critical section, just blocking for all threads....

Identity Server 4 403 Error

Trying to follow this course and sometimes Identity server works sometimes it does not. ```cs builder.Services.ConfigureApplicationCookie(opt => {...

my shared projects are not found. how do I fix?

so as you can see it says my two other projects are not found but I can view them in my file explorer and open them just fine. I am assuming I just need to add them again but how? I tried doing a rebuild project but it only rebuilds one not all 3
No description

About .Net Aspire WithExternalHttpEndpoints()

Hi I'm adding Aspire orchestration to my solution which only contains a WebApi with a bunch of REST endpoints. But when I launch it over the AppHost, I'm unable to reach the rest endpoints (note: when a launch the project seperatly and place all connections string myself, everything works just fine). So obviously I have not understand a key point about aspire Routing :catderp: then I created a little dummy project with just one postgres container and plain Identity Endpoints to test it ... and t...
No description

Which Architecture to Choose?

I am working with two .NET-based architectures for processing HTTP POST requests, and I’m looking to wondering what to choose and how to measure things. Here's how the two architectures work: Architecture 1: Decoupled Worker with Kafka A POST request writes data to a database and sends a message to a Kafka topic. A separate worker app consumes messages from Kafka, processes them, and updates the database....

Microsoft Authentication in an iframe

Hello guys, I have migrated multiple apps to Azure and they're working great, however this one app is required to run inside of an iframe on another website. The issue is that Microsoft do not allow authentication inside of an iframe due to security concerns. I could disable auth on the app due to it being available internally only, but I still need the users email address to get the required information to load within the app. The website that the iframe needs to be embedded on uses Microsoft Authentication itself before getting to this point....

Entity Framework Core: How to build without Package Manager Commands?

I am looking at this sample project : https://github.com/Nedal-Esrar/Travel-and-Accommodation-Booking-Platform I notice that it automatically creates the TABP table as long as the connection string goes through, which is not the same for other EFCore projects I have created in the past in .NET 8.0. I have always needed to manually do Add-Migration "Add_Tables" and Update-Database but it seems this project does not?...

I need a silent updater for my project Console app .Net Framework

I’m currently working on a project for a company where I’ve built a console application in .NET Framework. The app runs in the background without user interaction and monitors hardware components like RAM, CPU, GPU, etc. I’ve completed most of the functionality, but now I’m stuck on the last part: creating a silent updater. The idea is when the app runs check my server for updates and automatically download and apply them if available. The server is written in Rust and runs on HTTP. I also tried using ClickOnce, but it didn’t meet my requirements....

Ending of curly braces results in an error?

```c-sharp namespace SpotifyLyrics { public class SpotifyAPI {...
No description

browser based client

We are running codespaces for dev containers and we need a browser based client that can connect to the codespace remotely and we should be able to develop on top of that client. Like some extensions for code completion etc.

Advice for learning C# (Beginner - New to C# not programming)

Hi all, I am not a programmer professionally, I am an Application Analyst. I have been working with Python, Bash, and PowerShell heavily in my free time for the past 4 years and I am looking to dive into C# as I am starting the process of making a game; I will be using the MonoGame framework with C#. Outside of YouTube and Google, does anyone have any advice/tips for learning C#, or a "best approach" for someone that knows nothing about how the language works? Any help and or advice is much appreciated!...

MAUI: scrollviewer's child focused.

I've tried nearly everything I could think of to get rid of this undesired behavior. I have an "AbsoluteLayout" element inside of a "ScrollView" element.
I have a "Tap_event" attached to the AbsoluteLayout, and so I need to interact with it. However, I want the panning of the ScrollView to be handled in the code behind ONLY. I don't want any manual panning. No clicks, drags, swipes, scrollbars, etc. I managed to get rid of most of the default panning, but whenever I click on the AbsoluteLayout, it seemingly gets focused by the scrollview, which then automatically scrolls to it. I have tried to get rid of the behavior but to no avail. Please help me. Thank you....

Unable to Install SQL Server

Hey ya'll, I've hit a snag trying to install SQL Server. I've attached the following error. I've tried uninstalling and reinstalling numerous times, and have followed a variety of guides suggesting which files to delete and which registry files to delete as well. It assisted in being able to remove SQL Server from my computer, as I could not even uninstall it before, but now I cannot install the service on my machine. In the summary report, the error code is "0x851A0019" with a message of "Could not find the Database Engine startup handle.". Poking around online has not provided any help whatsoever to figuring out the solution, and am hoping someone here might be able to help get SQL Server installed on my machine. Thanks in advance....
No description

✅ C# TCP connections Help

Hi i am trying to make a chat application P2P using TCP, and i make a initial connection to the listener and make a communication trade cancel the connection and then boot up a new client for a new connection and it keeps getting actively denied. i will provide code and output screen shots. Please help. I will also provide a timeline kind of thing for what is supposed to happen. Client- right how I understand it is that the my form Data_Input.cs sends a connection and sends the get request for the session info, the host receives this and handles and responds to it, with the session info, then the data input form closes its connection after it has made the new session, moving back to the homepage.cs which is where data input is created, the homepage now has the session loaded in form the information, the client opens the session and message window form opens up and attempts to connect to the same listener but currently that doesn't work for some reason. and then typing into the input box and clicking enter makes a new client and then sends the message over. Host - The host creates a new session and opens the session, the session detects that it is a host and then opens a listener waiting for a client, it receives the first client for the session and responds to it, however on the second connection I don't know if the listener is still going or not but the second message is not received. ...
No description

Race condition with Interlocked.Exchange

Hi, I found a weird bug which I can't quite understand... This is my class: https://github.com/AngryCarrot789/FramePFX/blob/master/FramePFX/Utils/RDA/RateLimitedDispatchAction.cs, it lets me add forced minimum interval between sequential executions (e.g. say you're dragging around a UI control but you only want to update the position text every say 0.1 seconds) InvokeAsync is called by the user and it choses whether to create a new task or set the current task to a "continue" state. ExecuteCore actually executes the action. ...

docker

Error response from daemon: Mounts denied: The path /ASP.NET/Https is not shared from the host and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing. See https://docs.docker.com/desktop/mac for more info. docker-compose process finished with exit code 1...

Openapi to have XML documentation of the properties and endpoints.

anyone used openapi document? to get the xml documentation included in the openapi/v1.json ? I was using MartinCostello.OpenApi library. Please suggest to fix that. when i used below logic, it is giving me 500 internal server error. services.AddOpenApiExtensions(options => { options.AddServerUrls = true; options.XmlDocumentationAssemblies.Add(Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly());...

✅ Disposable class level property

Hello If there is a singleton service that uses a disposable class level property, should the service implement IDisposable as well? Also, wouldn't the property be disposed automatically upon application shutdown, only if it implements IDisposable? ...