C#

C

C#

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

Join

Hello guys totally new to coding need some help

I'm 17 and just starting to learn coding with c#, if you could go back in time to my age would you recommend 1. Using YouTube and tutorials to learn 2. Focusing on going in blind with just the basics 3. Reading books and code to try and understand ...

Asynchronous batch processing (queue) in C#

Hey guys, I have some batches to process and to do so I have to send each of my batches to external APi to process. I have no experience with async programming so I simplified it a bit by using Parallel.Foreach that create thread/task for each API calling and waiting for response. The reason I dont want to call API synchronously Is that processing of one batch can take a one sec or 30min (max). With the Parallel.Foreach solution it looks it works fine but form what I read on internet it's not a good approach so I want to implement kind of async queue that will take a few items from my collection of batches starts processing and after some of them is finished replace it with another etc. I tried to came up with something using ChatGPT but it only process specified number of batches (3 in my case) and than it does nothing but even if the code is short there are lot's of new concepts for me so I have no idea how to fixed this. ```public async Task ProcessBatchQueueAsync(IEnumerable<int> batchIds) { var semaphore = new SemaphoreSlim(3); var tasks = new List<Task>(); ...

Signalr

Hi! For work I have to connect the middleware with the backend in a fast way so I ended up deciding to use signalr. I have a serverless signalr instance running in azure and an azure function for the bindings I am start with a small poc to fully understand how it's working...

Application Insights Auto Instrumentation

banging my head against the wall on this one, anyone had the same issue i'm having with auto instrumenting an asp.net core web api running on azure app service linux container? It's not attaching and i'm losing it. It worked before but now it doesn't .net 8...
No description

code explaination

hi im new and i would really like someone more advanced to explain what this code does and also answer up my following up questions, thanks :D

.Net Aspire

wanted to know if my client is Unreal engine and i want to link it to my .net Aspire project with microservicees just want to know which ip should i give my unreal project to be able to talk to my backend i just want to use 1 ip or hostname. i'm guessing we don't connect to the apphost or do we or do i need to create a api to give to unreal like i know how to create deploy aspire but no tutorial showing a nother client connect to aspire....

Trying to log information about event being used

Hello, i am a beginner in C# and i just want to know, how can i log info about an event in-game (CS2)? I have tried to use this https://docs.cssharp.dev/api/CounterStrikeSharp.API.Core.EventPlayerJump.html but when i copy and paste in into my code it doesnt work. I did a basic w3schools exercise on C# and some calculation tasks, so i really dont know much more about anything else in C# :D

✅ i have 44 errors that I don't know how to fix

I seriously don't know what I'm doing wrong my program only has 106 lines

migrate to .NET 9

Do we have a guidelines or steps to migrate a solution to .NET 9 from older versions example .NET 8?

Class separation

I've got a console app that does a lot of heavy lifting. Let's say it's got a service class (that performs http calls) as a dependency and the main class is calling it a multitude of times. The unit testing for the main class of the console app is becoming huge. Is it a good approach to just create a class that aggregates all the calls to the service class?

In App Billing purchased fetching on mac os causes restore failed issue sometimes

I am trying to use the InAppBilling plugin library by james montemagno (https://github.com/jamesmontemagno/InAppBillingPlugin) in an avalonia program. I have setup subscription and well configured the settings, info.plist and entitlements for this purpose. But the problem is, the library, when fetching from app store, it sometimes work and sometimes says failed due to restore issue, which I think means that it was not able to connect to app store and fetch purchases.. I saw a solution saying that we just have to keep trying in a loop, but still the error is not clearing. It particularly happens when I am trying to fetch purchased subscriptions list to check if the user has purchased our product or not. Has anyone ever faced this and found solution for it? Looking forward for any help. Thank you!...

Windows Forms drawing not saving

When im drawing on the picturebox (pageImage) and im saving, the data is not saved
No description

Declaring a struct as a constant

None of these methods work, how would I go about it?
No description

✅ How is JsonConverter(typeof(JsonStringEnumConverter<MyEnum>)) evaluated?

Hello, This makes it possible that enum is serialized to string when the request comes in. Is this evaluated on each request, or only once at compile time?...

NuGetCommand@2 restore always picks some old .NET SDK version on custom agent

I have a solution with projects of both old and new .net. When I try to restore the solution as a whole i always get some error like this
##[error]The nuget command failed with exit code(1) and error(c:\w\_tool\dotnet\sdk\6.0.428\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. [c:\w\21\s\Webjobs\<proj_name>\<proj_name>.csproj]
##[error]The nuget command failed with exit code(1) and error(c:\w\_tool\dotnet\sdk\6.0.428\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. [c:\w\21\s\Webjobs\<proj_name>\<proj_name>.csproj]
...

✅ Why ins't this EF Core query being evaluated client-side?

Currently, I have this query: ```C# var board = Database.KanbanBoards .Where(k => k.OwnerUserId == AuthUser.OwningId && k.Id == boardId)...

✅ how do i install c# on my pc?

i am trying to learn c# but idk how to install it

✅ ASP.NET CORE Web Application

I am using ASP.NET CORE in my web application and when I am trying to upload a file to an input field even if I don't upload a file and just click the upload button my iis express server just crashes does anyone have any idea? ``` <div class="row"> <div class="col-md-4">...

Issue with code execution

static public int GetMain() { try { Console.Write("Choose A project Type 1-Backend 2-fronted 3-fullstack:");...