C#

C

C#

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

Join

Object reference not set to an instance of an object.

This error appears when I run the query shown in the picture. Even when I hardcode the userId, the same error persists. However, when I run the same query in SQL Server, it returns the expected result
No description

Telegram Bot Mindee integration

I'm trying to use a telegram bot to read data from a document. The request is sent, but nothing is returned.

βœ… Why doesn't this try catch, catch exception.

I have these two methods, in register I have a try catch but it's not catching the exception thrown in the try block. I'm doing something wrong but I cannot figure it out. isEmailUsed is definitely true. ```public async Task RegisterUser(UserRegistrationDTO userToRegister) { // await _userRepository.CreateUserAsync(userToRegister);...

Chess Game with WPF in Visual Studio + MVVM

Hey! I'm making chess as mentioned in the title and i was wondering if someone wanted to help me with one small implementation of it. I thought you guys might know better than Chat GPT and it might be more fun. On the picture you have a rough estimate on how far i've gotten. What i want to do now is implement some light interaction with wpf. For example when i click the farmer i want it to highlight that tile the farmer is on and (later on) the available moves that it can do.
Is this perhaps something someone has some clue about?...
No description

βœ… Microsoft.AspNetCore.OpenApi possible bug with valuetypes

I get this exception whenever i try having a baseresponse of type Guid or an enum type. The example endpoint can be annotated with: [ProducesResponseType<MyResponseWrapperClass<Guid>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)] ...

10.0-preview3, which git commit/branch/tag?

Hi, I was hoping to find a branch or tag in the dotnet/runtime repo for 10.0-preview3. anyone know how I can discover which git commit it was baked from? Thanks....

βœ… Object Reference is null, even with try/catch

What dumb thing could I be missing? I'm trying to add a custom object to a simple dictionary of string + custom object. In the debug, you'll see that the _storedPoints is not null, and the modifiedRow is not null. While not shown, modifiedRow.Name is not null either. Could it be that this error is caught on another thread (since this is from a Parallel.ForEach), and I'm just not seeing the correct object in my debug?
No description

[Async Hell] Messed up Stacktrace

Before the call, i have the following stack trace: Image 1 After it, its shortened and scrambled up: Image 2 Thing is, i have a Adapter which does some retry logic and it seems like it gets messed up in there. https://gist.github.com/JKamsker/8379749b3736b4c95028e6022709b88f...
No description

Logging System Design Advice for .NET CQRS Modular Monolith

I need to design a logging system for a .NET modular monolith application that uses CQRS pattern. Key requirements: Using custom mediator implementation (not MediatR) Logs don't need to be in PostgreSQL (though we currently use it) Need to capture full context for every action (Organization, Service Provider, Customer)...

βœ… Unable to publish a package despite having a valid API key

Hello, I created a key with push privileges, but when trying to publish a package I get a Forbidden response. Also, there's a section to select packages, but I have no packages, this would be the first push. I have checked it, and the package ID is unique. ...
No description

βœ… dotnet pack command fails

Hello, I'm trying to package a library, but dotnet pack fails to create the package. The docs says I should build the project it beforehand, or not use the --no-build flag, but I didn't specify the flag. https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5026 ...

Issues using `.json5` files for `appsettings.json`

I wanted support for trailing commas and comments in my appsettings.json, so I decided to go with JSON5. But here's the weird thing. I can add trailing commas and comments to appsettings.json and everything works perfectly fine. So far so good, but Rider complains that you can't have them in a json file. No biggie, Rider supports .json5 so I renamed the file to appsettings.json5 and changed ```cs...
No description

βœ… how to do a "login screen" in winforms

i'm building out an app with winforms, and I want a "login screen" that appears on startup and basically locks out the "main app" until you've logged in, is this done using a separate Form? or just a dialog of some kind? what's the best way to tackle it?

βœ… Good way to access methods from other classes?

I'm using separate class files to try and organize my code, as my code contains alot of stuff for specific things. Currently I'm accessing these seperate Class files by having all of them in the same namespace, and having a public class that has them all instanced. Problem is, I cannot use this same method for getting these classes in the MainForm, as for some reason it breaks my code. What are some ways you guys would recommend referencing a separate class file?

βœ… What have I done wrong here?

My course has it typed out the exact same way, and I dont have any errors but "Hello World" isnt being typed out.

JWT in front-end

Hi, I'm trying to use JWT as a auth for my app (because I also plan to create a mobile app) So I've made two projects : Project.Api and Project.Web (which is basically just the front-end) but i don't know how to correctly setup jwt for the front end project...

Change the struct size based on current architecture

Hi, I'm working on porting a C library to C# that contains architecture-dependent structs. Here's my C code: ``` typedef struct windowManager_t { char *name; void *window;...

βœ… enable single-click cell editing in Avalonia DataGrid

Hi all, In my Avalonia UI DataGrid, clicking on any cell currently selects the entire row, and I have to click the cell one more time before I can start typing. I'd like to achieve:...
Next