C#

C

C#

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

Join

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....

NUnit, Dependency Injection, Hosting

Now that NUnit supports the new testing platform bits, I was wondering...would it be possible (or is it already supported) to do DI/IoC with test classes? My idea is this: I create a host in my entry point (which would require turning off the entry point that's automatically generated, and I'm not sure if that's a good idea or not), do all my service registrations and whatnot, and then, in my test, I can have these services injected and use them in my tests. This is primarily for integration or end-to-end testing scenarios....

Regex help.

For Learning purposes I want to match C# in given string. But the below pattern doesn't work for C# while it works for any alphabet word. ``` string s = "Just a random string in C#.";...

abstract methods inside EF core queries

I'm trying to model my domain as follows (some EF configuration stuff is left out for brevity) ```cs class Contract {...

✅ Hello i need help with my school project, i will pay for help or just to do it for me.

Here are the instructions: Final Project: Windows Forms Application in C# Each student will work independently to create their own Windows Forms application in C#. The project will be carried out over four weeks with a deadline of April 23. Step 1: Written Planning Each student begins by writing a brief plan (1–2 pages) that clearly describes...

winforms c# --> translateTo method

public void TranslateTo(PointF p) { // дали има избрани фигури за преместване if (Selection.Count == 0 || Selection == null) {...

Ping function message box not working

Hi all, I am trying to use several different buttons to ping different ip's. So far only the first 3 buttons have ip's on them using their tags There is no error output message and it builds correctly, however, the Ping messagebox is not displaying....

Help in understanding a concept in SignalR

Hey guys i am currenlty working with signal R (new to it) and i have a question. I have ClientTimeoutInterval to 30 seconds and KeepAliveInterval 15 second. what i am noticing is if i disconnect (remove lan cable), OnDisconnectAsync() gets called around second 16 and when i reattach lan cable (before 30 seconds timeout) it reconnects and connection stays alive. this is causing me confusion can someone please explain what is going on ? Thanks in advance

✅ which .net version should I be starting with?

i downloaded the latest version from the dotnet website, 9.0, and attempted to use this -> https://github.com/gui-cs/Terminal.Gui to build out a simple console app with a TUI, but I got an error saying that i need to be on .net 6, which is marked as end-of-support. is it fine to stick with 9.0, or should I roll back to 8.0? its not terribly important that I be able to use Terminal.Gui, I just don't want to be locked out of using other libraries because the version of .net i'm using is too new....

WPF Datagrid scrolling

I have a Datagrid that is bound to thousands of rows, so I have enabled RowVirtualization, but I also have large “RowDetail” sections so I can’t use ContentScrolling. But RowVirtualization requires ContentScrolling so I’m not sure what to do

SourceLink with private, authentication-required repo

Been trying to get this to work off and on for many months at this point, so hoping I'm missing something. We've got a number of new NuGet packages on a privately-hosted BitBucket server. They're configured with SourceLink support. When using Resharper, we can navigate into the source code of the packages after providing user credentials as shown. However, Visual Studio's native SourceLink integration doesn't seem to be able to comprehend the authentication portion of it. Whether I'm using the Git Credential Manager fallback or not, any attempt to debug into the same packages fails with a "Source Link authentication failed" error. There's an Authenticate button on the error screen, but it does nothing (i.e. the button can be clicked, but there's no popup or other control displayed). I'm running out of things to try, and really need this to work to meet our developers' needs. Git credentials are stored in the Windows Credential Manager, and work properly in git natively. Interestingly, if I try to open the SourceLink URL in the error through a Windows File Open dialog, it presents a Windows Security popup that allows me to enter credentials, but my domain credentials (used for normal BitBucket access) are never accepted, no matter which variant I try. Opening the same URL in a browser immediately downloads the file, as I've logged into BitBucket via the browser and therefore have appropriate session cookies in place....
No description