C#

C

C#

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

Join

how do I send data back and forth

I am new to c# and im using .net and I need help sending data back and forth.

Visual Studio 2022 (0xc0000409) Error Code

As usual, I was doing my coding and creating my program. However, although there were no errors when I debugged, whenever I tried to open my program, it did not open with the error code (0xc0000409).

Versioned API client architecture

Unfortunately the IPC implementation I made a post about a while back was completely useless as there is no IL2CPP API to get a class' static field data. So now I'm falling back to manual memory interop. For this, I need to handle many different versions of both Mono and IL2CPP. I need to expose methods such as these; ```cs nint GetMonoImage(string name);...

Cannot return null from an action method with a return type of 'Microsoft.AspNetCore.Mvc.JsonResult'

Context: I created a simple app which displays card view items on view. I have added a file picker in there. Once the file picker selected an image and the save button has been clicked, my code triggered the exception System.InvalidOperationException: Cannot return null from an action method with a return type of 'Microsoft.AspNetCore.Mvc.JsonResult'. My Rider does not let me debug like this (as per attached screenshot) so I have no idea what caused this exception. ...
No description

Reflection error Object type T does not match target type System.RuntimeType.

I'm trying to get the "Execute" method from in this case DefaultCommand. Can someone please help me I'm sure i made some stupid mistake :/ For Context the command.CommandReference can't be null it's checked before this Method is called. The CommandReference is the Class i'm trying to call a method from....

Is setting Jwt and fresh tokens as HTTP only cookies good ?

I'm building out authentication and currently send JWT and refresh tokens as HTTP only cookies and the backend validates the cookies instead of doing it through the bearer header is this an ok strategy?

Why isnt it outputting the same

im following this https://wpf.2000things.com/2014/07/01/1105-using-applications-windows-collection-to-interact-with-other-windows/ i looked up the error on ms docs and what i think im doing wrong is that im not referencing something but im not sure what to referense error: 'OtherWindow' does not contain a definition for 'OtherWindow' and no accessible extension method 'OtherWindow' accepting a first argument of type 'OtherWindow' could be found (are you missing a using directive or an assembly reference?)...
No description

Error acquiring .NET when offline but works when online in VS Code

I got error acquiring .NET when I am offline but it works when online without any changes to settings.json. I have attached screenshots of it when offline and online. I have got this error few months ago then it disappeared on its own and now I am facing it again. Any clue what's going on?...
No description

Handling Custom Assembly Attributes in Unit Tests After Migrating from .NET Framework 4.8 to .NET 8

I recently migrated my app from .NET Framework 4.8 to .NET 8 and ran into an issue with unit tests in MS Test. The problem is related to the OriginSetupPackage custom attribute applied to the entry assembly. In .NET Framework 4.8, the Product class loads this custom attribute from the entry assembly, like so:
see code sample 1 in attached screenshot
see code sample 1 in attached screenshot
...
No description

✅ XAML Constructor Error e0434352

Using VS 2022, after some time constructing it just started to show me this problem. In the main window I have a user control usage. So the XAML constructor can load the UserControl itself, but doesn't show it in MainWindow. It works neither in Visual Studio 2022 or Blend for Visual Studio 2022 and shows the same error e0434352 Help me pleeease...

Package Error

I am getting this error while adding identity into the project added class libraries and references also using .net 8 version...
No description

WireMock.NET match on domain

Hello. I want to use WireMock.NET to test my program. What is a good way I can make sure that each request I send out with a specific HTTP client gets sent to the WireMock server? So for instance if I send a request to domain1.com and domain2.com I want to be able to catch these in WireMock. Note, I have logic in my application that is dependent on the domain name and thus I can't configure the domain name as a configurable value....

Blank screen after launching app, only when done through VS

I have a WPF project, using net 8. Whenever I run the program, either in Debug or Release, the main window appears, with its content visible. But, after like half a second, the window becomes blank. However, if I run the release build's .exe, outside of VS, I don't get the issue. The content of the window seems to still be there, as I can click on the exit button (where it should be)....
No description

Beginner in C# – Need a Learning Path for Backend Web Dev

Hi everyone! I’m new to C# and want to focus on backend web development. Could someone suggest a step-by-step roadmap or resources to follow? Here’s what I’m looking for: 1- Basics of C#: Key concepts to master first (e.g., syntax, OOP, async/await). 2- Databases: What to learn (SQL, Entity Framework Core, etc.)....

[WPF/Chromium] How to modify a page displayed in WPF's HTML through background code

Learning WPF, using Chromium to have the application fetch a page and display it, and I'd like to be able to retrieve the entire HTML source of the page and edit it, as if doing it manually through inspect element, then feed it back to the display so its updated.

How to save signalR chat messages to database

```csharp public async Task SendChannelMessage(string channelId, string content, List<IFormFile> attachments = null) { var authorId = Context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value; var result = await messageRepository.CreateChannelMessageAsync(authorId, channelId, content, attachments);...

[C# console app .net4.7.2] Seemingly can't instantiate an object

Okay So I'm working on a text based adventure app for an entry level college class. I have an "Alien" base class which is inherited by a "CrabAlien" class, I'm trying to instantiate a crab alien in my "GameWorld" class but it's telling me that none of it exists in the current context and I'm not sure why. I'm sure it's something stupid I'm missing like some sort of permission level thing, but I just can't figure it out
No description

Warning about Trimmers and XmlSerializers

My library uses a trimmer to handle complex XML. But when I turned on code trimming for it, it showed warning IL2026: [...] Members from serialized types may be trimmed if not referenced directly., the code looked like this: ```cs [Serializable] [XmlType(nameof(MyData))]...

c# API + angular front end

Hi, This is more of a design question... I have a web api written in C# and a front end writtein in angular. The web api has a settings file associated with it. The web api and front end are both served by kestrel (same port). The front end has some settings as well (in the assets folder). One setting, for example, for the front end is a theme. The theme can be changed using the front end, where it makes a request to the API to set the theme setting....

[ASKING FOR JS] Javascript wont load after post refresh [SOLVED]

this is offtopic cuz Its more about javascript, why do whenever I post refresh the second time, it wont execute my javascript code..but if I want it work, I have to refresh it or redirect to it.. ```js <div> <table>...