C#

C

C#

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

Join

having problems with random number generator in uni project

I was given a small assignment for a bit of uni project to make a program that generates a random number then asks you to guess. The problem is that after each guess the number gets randomised again, can someone help (I’ve tried putting it outside of any loops and it still does this)
No description

[WinForms] Need ideas/help where to start..

Hello im a first year CS student and its our 4th week of C# I've given a project in C# to do a small internet cafe management-like project Basically it should be done on WinForms. ...

i cant load data from DB to dataTable

Link to my github: https://github.com/buison1602/BulkyWeb_.Net_Core_MVC/blob/master/BulkyWeb/wwwroot/js/product.js Error: jquery.min.js:2 Uncaught TypeError: Cannot read properties of undefined (reading 'indexOf') at S.fn.init.data (jquery.min.js:2:34508)...

Number of projects in Visual studio

How many projects can a single Visual Studio solution contain? & Why?

Efcore - Database issues (Sqlite)

Hey I am getting this error code when I am attempting to do a method in my application. (Domain Driven Design) - MediatR - Domain Events. I can send code snippets if it could help with debugging....
No description

How do you implement paging on API requests?

Basically title. Do you implement it by yourself or do you use any nuget?...

Named function magically turns into anonymous method for no clear reason, cannot be used as Action

I am storing a list of delegates, which are added via calls to DefineFunction(string name, Delegate actualFn). I have a method with signature public void DrawSprite(string sprite, float x, float y, float w, float h, float rot, float grayscale01 = 0). But when I call DefineFunction to add this method to the list, for some reason, DefineFunction takes it in not as a System.Action or System.Func derivative like every other call, but as an <>f__AnonymousDelegate0 type, which cannot later be converted to a System.Action for invocation. ...
No description

[WinForms] Need help optimizing custom controls creation/updating of ui

I have custom controls that is being dynamically created based on data from several API calls. These controls are being created after the processing of data is finished. There were no issues from API calls/mapping of data since I can see that the custom controls are being created immediately after opening the form but the problem is updating the data on the UI. It takes several seconds for the UI to get updated and it gets slower the more controls there is. I have used SuspendLayout/ResumeLayout/PerformLayout before for updating a certain Custom Control, but I want to increase the speed on how the UI gets updated. This is the flow: 1. Click button to open the form 2. Parent Form gets created and creates some other UI control...
No description

WPF - Binding json data into datagrid and datagrid updates during runtime

Hey guys, I have attached screenshots here to help understand what im trying to do. so in my json file theres a bunch of usernames that are already there and during runtime i will want to add and delete logins (as the admin staff can do that). my issue here is that im trying to make the data grid output that data and read everything from the json file but i dont know the actual code for that in my XAML and cs. i tried the itemsource binding syntax but that didnt seem to work (o maybe it does bu...
No description

Need help finding a library for a specific job

I need a library that has a english dictionary that allows me to search through it for a word meeting specific criteria like how many of a specific letter it has.

Not a function? Service

Hey guys , I've gotten an error and I don't know why. I triple checked my variables but still getting an error. ``` app.service("MachineProblemService",function ($http) { this.staticConnect = function (userEmail, userName) {...

Setting a Default Value for Migrations

I have a relationship between two models but the relationship is not required, i.e. the first model which "belongs to" the other model can exists on its own. ``` class Item { ...

✅ Winforms not freeing memory when disposing of control

```csharp void NewButtonOnClick(Button btn) { //Delete the button completely, write code btn.Parent.Controls.Remove(btn);...

✅ SMTP server broke

We used to be able to connect using SMTP outlook.office365.com 587 but all of a sudden it no longer will connect. Error ``` The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 Client not authenticated to send mail. Error: 535 5.7.139 Authentication unsuccessful, basic authentication is disabled. [MW4PR04CA0249.namprd04.prod.outlook.com 2024-10-16T23:46:33.247Z 08DCEE0C14048537]...

MVVM Toolkit Messenger - RequestMessage

I have no idea why one of the methods is never executed... take a look at this vs Messenger
C#
public class AsyncRLoginMsgReq : AsyncRequestMessage<bool>{};
C#
public class AsyncRLoginMsgReq : AsyncRequestMessage<bool>{};
```C#...

I'm having a weird null reference issue with a Razor Pages view component.

I have a shared layout where I'm trying to pass either a student or teacher ID (or 0 if none) to a view component. Even though I'm explicitly handling null cases I keep getting a NullReferenceException. Here's my layout code: ```csharp @if (!ViewContext.RouteData.Values["page"].ToString().Contains("/Account"))...

Integration Test for 3rd party API

Guys, I would like to ask opinions regarding integration test related to 3rd party API. My Opinion for Integration Test - Do actual API request to the 3rd party API so that we can get the actual value and verify the application work flow in general. ( We don't pay per request) Reason : The purpose of integration is to check the current application can communicate with other applications without any issues. If Anything has been changed from the 3rd party, we can verify just by running the test all. No require to figure out where it came from....

Ubuntu 24.01 WSL build Package Microsoft.NET.ILLink.Tasks, version 8.0.10 not found

When building C# .NET 8 library extension on Ubuntu 24.01 WSL I get the following error even though the build finishes: Severity Code Description Project File Line Suppression State Details Error (active) NETSDK1064 Package Microsoft.NET.ILLink.Tasks, version 8.0.10 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. ArmaDragonflyClient C:\Program Files\dotnet\sdk\8.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 266...

problem with Rpc code

hello guys i tried to create bot with c# to send messege inside the discord bot depend on packet recived from app so its working and connection succed and get all info about channel but its not sent the messege so how can fix something like this its first time try to create something fo discord i don't know the good logic to set it its alread read data but not sent it C# project
No description