C#

C

C#

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

Join

✅ is there a Winforms API reference?

i have to build a winforms app as part of this school project i'm doing, and i'm opting not to use VS or the designer. i need an API reference and found this https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms?view=windowsdesktop-9.0 but I want to ask if everything i'm going to need for the UI stuff is under System.Windows.Forms or are there other namespaces I'd need to look at? right now i'm mainly interessted in the controls, layout managers, etc that I'd need to put together a basic, non-functioning UI...

✅ Connection razor and cs class

I'm trying to connect my razor using .NET MAUI Blazor so I'm trying to connect it to the cs class "Customer" so I can use the property there. I already used the @using "the namespace"
No description

In Unity: Enemy script not responding.

No idea if it´s something with the layers or on the code itself. The enemy doesn´t move. It can be pushed by the player but nothing else. When testing the next error message appears: NullReferenceException: Object reference not set to an instance of an object I can show the script is needed....

Help with understanding this logic question.

After 1 pm sonething went wrong with the mechanism of a certain clock and at 1.30 pm it struck 2 hours. Then went on striking every half an hour in the routine way indicating wrong hours. Find out when did it strike the correct hour next? (A) 12.30 am (B) 11 pm (C) 6.30 pm (D) Never...

How to interpret IDE suggestions like method signatures

Hello guys, when using Rider, sometimes, their are some suggested arguments that can be used for a particular function. For example consider the picture uploaded. I'm trying to use a LINQ expression. I want to be able to interpret the message shown so that I can quickly remember what the arguments refer to. Can someone explain how do I do that please, like I know func<> refers to a method type/delegate but for the this keyword in this context etc... I'm a bit lost
No description

WPF App wont send keys when the shortcut "RightAlt + Z or X" is pressed

I'm trying to make an app to add a shortcut for the pipe and backslash symbols, but when the shortcut is pressed the corresponding key doesn't get inputted. My code is in the file attached....

Rider suddenly can't run source code, SDK issue

``` You must install or update .NET to run this application. App: C:\Users\Test\RiderProjects\driving-school-booking-system\MainProject\MainProject\bin\Debug\net8.0\MainProject.exe Architecture: x64...

Most efficient way to modify json in C#

I am storing data as json string, and before store I need to update a value I know I could deserialize to an interface set the property and serialize again but this would cost a lot at least i think (advantage to ensure it has the key) I have done with now like this: ``` public OfflineEntry this[string key] { get => _db.GetCollection<OfflineEntry>(_collectionName).FindById(key);...

Regex to match text between nested tags

Question:
Write a program that extracts all the text without any tags and attribute values from an HTML document. Sample text: <html> ...

Publishing WPF app with local db

Hi all, just trying to publish my app, however everytime i do, the local db is not published with it. Is there a setting or something i need to turn on in order to do so? Any guidance would be greatly appreciated....

Issues running BenchmarkDotNet fron NUnit test

I am trying to have BenchmarkDotNet run a Benchmark when running (NUnit) tests for one of my services. However the Benchmark fails with 'Build Error'. My whole project has no trouble building and running, so i don't understand what its issue is... I have included the testlog, for anybody who wish to look through that......

✅ Help with an Algorithm on time intervals

Sooo I want to create a discord bot that helps our alliance schedule events by evaluating how many members are available at what time intervals My users will input a start and end time when they are available. I got an idea in mind how to solve it and just wanna make sure my algorithm is right:...

HSTS strict transport security header is present in web api response but missing in web response.

I have site where i need to improve the security which is a .net core 6 application. The response header for the site abc.com and for the api is attached. response header for abc.com doesn't have the strict transport security header whereas the api response has the header....
No description

Free C# Learning

Looking into learning C# for free somwhere. Not sure what to go with

Workload ID maui is not recognized.

Hello, I am on MacOS on an apple sillicon M2 chip. I have spent countless hours trying to install maui from dotnet@8. Specifically 8.0.114. I hae tried uninstalling homebrew, dotnet, getting it from the website, unintalling xcode, vscode, rider, and reinstalling all of it but still cannot find the issue. When prompting " sudo dotnet workload install maui" i am met with "Workload ID maui is not recognized." when i try to search the workload for maui its not there. My workload itself is tiny and...

How to use OfflineDatabaseFactory of FirebaseOptions to store locally with LiteDb?

I am building a maui application which connected to Realtime Database with Firebase, it works as expected. Now I would like to cache the online data locally by default OfflineDatabaseFactory provides in memory solution but I am trying to create a factory in order to save locally and not in memory so if the app restarted and no internet it is still possible to do crud operations and when its online it automatically sync.

✅ How to setup environment variables in Azure Web App

I've deployed my Blazor Server App to Azure Web App. And in App settings I've added some items e.g my Cloudinary URL and in Connection Strings section I've made a connection string named as "DefaultConnection" same as it was in my appsettings.json file. However I'm getting some Postgress EFCore error in production. Here's my Program.cs: https://paste.mod.gg/ltvubhnjcema/0 ...

single-tenant

I need some help, please. I know it is a long shot. I need every hotel to be its own db, but not to create a new db. At the moment when I create a new hotel, it creates the same database. Is there a way to do it properly? I would love some guidance or ideas. I appreciate any help you can provide.
Single-Tenant Architecture Data Isolation: Each hotel has its own database, ensuring that its data is completely separated from others. Security: Reduced risk of data leakage between tenants....
No description

Dapper - Unit of work between 2 repositories

I need to keep a common transaction between 2 repositories, but I'm not sure who will be responsible for rolling it back in case of failure. Those 2 repositories do share connection and transaction via parent, but one of them has to commit the transaction. How do people usually go about this? - Do I make it so that the service is responsible for coordinating the repositories? I'm too new but this sounds wrong because a transaction commit/rollback is the responsibility of the database layer....