C#

C

C#

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

Join

✅ CSharpFunctionalExtensions.Result implicit conversion

Why does C# not allow implicit conversion in this case even though CSharpFunctionalExtensions.Result contains an implicit operator Result<T, E>(T value)?
No description

If I handled the SSO oauth as client in the backend [ASP.NET] how to integrate it with the frontend?

I'm not familiar with OpenIdConnect/OAuth and I had to integrate my project with my organization's SSO In the backend (ASP.NET) I did it and handled the callback and everything and made it as an OAuth client and it is that what gets the access token and everything now the frontend (Angular) is another service with another domain how to make the angular app to read the authentication if the user is authenticated or his authentication is expired or not and what's his role and claims and so on and the right way to do it
...
No description

P/Invoke boolean call always returns true in Release builds

I have a simple boolean function in a native C++ DLL (for keyboard input in my case), which I P/Invoke from C#. In debug builds, everything works fine. But in a release build (of both the C# and C++ projects), the C# side always receives true from the P/Invoke call, even when the native side returns false. I've checked my build settings but I can't figure out what is happening here- any recommendations for how to debug this or what could be the potential cause? ...

im new to C# and im trying to learn if you lot could help me with this that would be amazing

its a brand new form and im trying to make a keysystem ill even hire you to get this sorted for me
No description

ASP.NET help to do a design

Hello, i am doing a school proyect in .net framework, and i would like to have some help to find a tutorial of how to do a nice view of the program im doing, like adding background, colors etc. I already have an idea of how i want it to look but idk how to aply this idea using the tools of visual studio gives:sadcat:...

ASP.NET endpoint logging

I am building an ASP.NET api. I want to log info about who is accessing my API and how. I want to log the IP address of the user, the end point they called and the parameters they passed ind and the current time. I've done some research on this already and found Serilog, adding it to my middleware ```cs...

Can you use winAPI gdi and wpf with each other in c#?

Can you natively with no dll use winapi gdi graphics functions inside of a wpf xaml window?

Creating a game of ships with C#/ASP.NET

Hi! I am completely new to ASP.NET and C#, and I have to write a project for a web application that will be a two-player Battleship game. It must use at least two of the following solutions: • Lock/Mutex (thread synchronization). • Semaphore (thread synchronization). • Barrier (thread synchronization). ...

Question about reactivity in Blazor

Hi, I'm working on a Blazor project. I have some experience with C# in general and professionally I work with Angular. Specifically Angular recently tackled a big issue with reactivity with Signals. Before that I often used RxJS, and in .Net a similar implementation of RxJS is System.Reactive. In Blazor I do not fully understand how the reactivity works out of the box, without using any additional libraries. The goal of the project is to be able to parse replays of the game Supreme Commander: Forged Alliance and to show various information about the replay on different pages. Just like in Angular, one can use a service to deal with data that needs to exist across pages. To set that up, in program.cs I have the following snippet to make sure the replay service is a singleton: ```cs...

Support generic method NativeAOT JsonTypedInfo all together

Hello, I'm in the process of rewriting some of my libs to support native aot. But I have one use case for which I don't know how to do it. My use case look like this: ...

✅ Nullable<int> and xUnit

I'm writing unit tests for a method that has int? as a return type. When I do: Assert.Equal(null, parser.GetNumber(myArguments)); xUnit tells me...

Random ERR_CONNECTION_RESET when uploading PDF files

I have angular SPA and .NET web API. One functionality is file upload, which usually works fine, but sometimes I am getting random ERR_CONNECTION_RESET errors which I can't explain. They only occur on PDF files and they are completely random. The file can be 50kb, or 5MB. Sometimes you can upload one file normally, later the same file fails 5 times. Funny thing is, the file is still sent and processed on the server, but I looks like something cancel/ignore upcoming response. One more problem is that this can only be reproduced when the apps are deployed on the server, when I debug it locally, everything works fine. Any idea what could be the problem? Honestly I don't know what should I even look for. Is this the API problem, or the ANgular application?...

Problems with compiling OLD-Projects

First, I decompiled the DLL file using DotPeak. Opened the .cproj file in Visual Studio. After searching for a solution to the problem on the Internet, I installed libraries 4.0 ( Microsoft.NETFramework. ReferenceAssemblies.net40 ) from the NuGet website into the frameworks folder. And this window as in the first screenshot disappeared. But after I compile the project, many errors appear like cs1525, cs 1002, etc. So, how can I work with an old project in the current version of Visual Studio?...
No description

WPF LiveCharts

Using WPF LiveCharts 2 I set the XAxes by hand but they are taking too much space. Tried couple of things but nothing worked to make them stay closer. Bars are okay but their labels are spread out too much....
No description

Populating a Dictionary from a CSV File with Words Separated by Semicolons

Hi, I want to create a small console app for learning new vocabulary, and I need to populate a dictionary (source language: target language) from a CSV file that contains vocabulary in this format: english;german\n. How could I populate a dictionary?

✅ Reading/Writing in Excel with C#

It seems there are plenty of options to read/write .xlsx files (EPPlus, OpenXML, ClosedXML, ...)? Are there some that are "more official" / "better" and that I really should use? Or are they all more or less the same?

.Csproj problems

Is this supposed to be like this? or should it not be in /obj because i keep getting the missing file problem but i dont remember changing anything in this file
No description

Slider Image

Why Im having an issue with the images not displaying correctly in the slider
No description

WaitOne for EventWaitHandle makes program crash without error?

im using mutex and some events to sending some data to other program, but my program crashes completely after bool a = attachEvent0.WaitOne(waitTime); without any errors. it doesn't run the codes after :/ btw when the attachEvent0 is already signaled(turned on?), it works well without crashing,,,...
No description