C#

C

C#

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

Join

ASP.NET & EntraId: Acquire Token on Behalf of User for Azure Resource Manager

I have 2 Applications - A SPA thats authenticated with MSAL. - A ASP.NET web-api thats secured with Entra Id. I created 2 App-registrations in EntraId and im able to authenticate the User, obtain a Token for Web-API & call the backend....

View Injection

Hey everyone, is the view injection used often, or is it rare? And I would appreciate it if you have examples where the view injection is used :catHeyHello:

deserialize non-nullable

Hello, I want to deserialize JSON with System.Text.Json.JsonSerializer. I have classes with required properties and it by default throws an exception if any required property is missing, which is nice, I guess. But why doesn't it throw exceptions when I have nullable reference types and the value is null: ```csharp #nullable enable...

Reading in JSON-RPC for LSP msg returning Null???

So long story short Im building an LSP and it has been a process. I finally got it hooked up to read in stdin from vscode only for my message to never return anything but null. Its not hat at some points I dont have the full message but as you'll see from my custom scanner and Split function the whole purpose is to scan until I am certain I have a finished message from vscode once I do for right now I just send the actual message to the logger to a text file.

Weird behaviour with SpriteBatch.Draw in MonoGame

I'm creating a rhythm game. I'm trying to move automatically Notes from upside but something went wrong. Notes just stuck. Below is code, thanks in advance for help because I don't understand what I'm did bad. ```c#...
No description

✅ Auto Updating WPF applications options and best practices

So I'm building an internally facing application for a client, I've spent some time getting to know WPF and C# as this is my first major project. My main issue is how to handle auto updates, I've researched a bit online but struggling to understand what the best options are as most of them see pretty limiting. The application is being hosted with GitHub in a private repository, I initially had planned to handle updates entirely by using GitHub releases however open to suggestions on better/alternative ways to handle this. I come from a background of Full Stack development so have made heavy use of workflows and releases in the past but for Javascript and Python mainly so this is very much new teritory for me. Any help would be greatly appreciated thanks 🙂...

✅ "False Errors"??

Hello guys, every time I edit app.xaml code, somethings break, i did everything chatgpt Told me to do, nothing helped. Now im dealing with problems showed on screen shots.

Windows Forms EXE

When i compile my app to Release, the machine require dotnet or else it shows a messagebox thats tell to install it, however i dont wanna this.

In an UWP app, how can I get all currently open `Window` instances?

See title I want to get all open windows, and get their Window instances, I also want to get a callback whenever a new Window is opened Using WinUI 2...

Synchronization error, with threads

Hi i am busy with a small project, and i am stuck at some sycnhronization issue with my threads. I fresh mind would be appreciated highly!...

Http Post HELP

Hello. I'm very sorry for coming with such a request, but unfortunately I couldn't do the last part of a job given to me by my bosses because I was taking care of my grandfather. Although I know C#, I am not very experienced in .Net Core. My boss gave me this task, but even though I made it to the last one, I couldn't do the [HttpPost] part. I wonder if you can help me? A....

help with XML

https://github.com/win-ini/niuniakweb/tree/master <- my code if it's needed. so, I'm having trouble with XmlReader. I'm having it parse these from a URI, but it seems to get stuck on the ReadElementContentAsString() method (I've set up message boxes as debugging behaviour, and the one right before the call to the method appears, but nothing ever happens, and the next one's never triggered. the app isn't frozen, though). edit: here's exactly where it gets stuck https://github.com/win-ini/niuniakweb/blob/master/niuniakweb1/Form1.cs#L81...

Bunch of CS0246 and CS0234 errors.

Hello, I have been trying for hours to create a single WinUI3 project that can compile without any problems. I have all the required components installed. But when I try to compile the template project I get around 20 errors (attachment)

[Reading files from sftp server] is what i am trying to do possible?

hello, in the following code: ``` public async Task GetInformation(string url) { //Start Connections...

deploy rest api container from github & docker hub to Azure app service

Hi, I'm working on a project that needs to deploy as tht title, I already ask chatgpt but could someone double check if the suggestion from chatgpt is correct please? Thank you! chatgpt answer: https://rentry.co/am5d2czz...

Help on Covariance and Contravariance in C#

Hi there! I am trying to understand Covariance and Contravariance. Now I am thinking about why In and Out permitted only generic class T in parameter and output only? I found this example of Eric Lippert on stackoverflow to be great to illustrate why T in parameter for Out is impossible `interface IR<out T> { void D(T t);...

Debugging a ReflectionTypeLoadException

I'm using a tool called Cpp2IL to generate types like this in assemblies: ```c# // Cpp2IlInjected.WasmMethod.WasmMethod using System; ...
Next