C#

C

C#

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

Join

DateTime rounding struggles

While writing tests for my api, I've noticed an interesting issue. My assertion comparing an object returned by an api with a reference in the database kept failing, while they were querying the same object in the database. The difference was apparently a microsecond property of DateTime that did not make it through Json serialization, while EF core returned the full value, thus the objects were different. ...

Ef core help

Hi! Working on my first blazor project for work and habr a few questions if anyone has any help with any of them . 1. Using ef core 9 (prob) and I used ef core power tools to reverse engineer the db I have (I need a few tables for this project of the 100 or so the other projects use ). It generated the classes in the models folder but I need to add some helper functions. I kinda just added another folder and dropped a file for each and made the same partial class. What's the right way to do that ? 2. The model I'm doing in ef core 9 currently exists in ef6 (non core) and is used by many other projects . Would a good way to migrate be to use ef core 3 on this and kinda add this to the old stuff ? Or would migrating the ef6 to ef core 3 be better ? The old code is all .net is .netframework 4.7...

Handle Closing Form?

Hello, I'm having some trouble handling the closing of my form. Currently I'm using the method below, but it for some reason runs 5 times instead of just once. ```private bool Closing = false; Classes Classes = new Classes(); public MainForm()...

Paste Help

So I'm trying to make a program where you can paste the link of a youtube playlist and it copys all the individual video links from the playlist and pastes them into Cobalt Tools (if you don't know what that is, it is a program that lets you paste a youtube link into it and it turns it into a downloadable file all for free) and then pastes them all into a directory. How would I do this in JetBrains Rider?

Handle DbContext and IDbContextFactory<T> lifetime in Blazor InteractiveServer

Hi, I have some trouble getting EfCore to run properly with Blazor components and pages. I scaffolded a project using the Identity UI template and implemented business logic. I wanted to deploy a first version on production but I'm stuck with flaky instances of the DbContext. For example, the autogenerated Components/Account/Pages/Manage/Index.razor page contains the following initialization method: ```cs...

convert c# to .exe

hey, can anyone convert this file to .exe? Iwatched 10 videos, but it didn`t work. xD

JetBrains Rider Android Physical Dotnet Application performance profiling.

how to trace and memory profile using JetBrains Rider IDE in dotnet maui android applicaiton in phyical device ? or they have any better free tools for performance profiling ?

MAUI CarouselView Out Of Memory Issue.

Maui android project CarouselView out of memory issue and laggy issue, when i load too many data.

βœ… Func app database dependency

Hi all, at my job we have this setup web api with clean arhitecture and func app project in same solution. With azure func app we use timer, file upload and http triggers. Each function have logic for example timer triggers function will go to database and check if user received mail notification and will send user emal and update state in database. Questions, how bad is to have database dependency in func app project? Should I keep business logic in func app or keep it in separate library?...

βœ… How see that exception from my code?

Hello, i am stupid and i can't understand why my Visual Studio 2022 drop exception on internal code.. I'd like to see the error right inside my written code. :pepecry:...
No description

SQL overwrites instead off adds

public bool AddNewCustomer(CustomerClass customer) { SqlCommand command = new SqlCommand(); command.CommandText = string.Format("INSERT INTO tblCustomer VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", customer.CTitle, customer.CForename, customer.CSurname, customer.CEmail, customer.CContactNum1, customer.CContactNum2);...

βœ… Switch - return πŸ€” ( attached )

I’m getting an explanation on switch in C# and I don’t quite get what the last return outside the scope has to do with it - does. Any idea?
No description

βœ… new to MySql and trying to set up a basic database that will get connected to a .net projekt

ive set up my MySqlworkbench file and called it WordDatabase but cant seem to open a connection to the MySql server saying it cant connect dunno how to make it actually connect would gladly appreciate some guidance...
No description

βœ… [SOLVED] MSBuild Task says file does not exist

I've made a custom MSBuild task to zip up the newly created .dll along with relevant files for release whenever the project is built. For some reason though, it says the newly created .dll does not exist... When the log literally shows its existence in the exact location like two line up: ``` CopyFilesToOutputDirectory: Copying file from "/home/newmaz/Documents/HFF_ObjectGrabber/build/obj/ObjectGrabber/Debug/Debug/ObjectGrabber.dll" to "/home/newmaz/Documents/HFF_ObjectGrabber/build/bin/output/ObjectGrabber.dll". ObjectGrabber -> /home/newmaz/Documents/HFF_ObjectGrabber/build/bin/output/ObjectGrabber.dll...

βœ… bracket pairing isn't working

my brackets keep joining into the wrong pairs whenever I finish my function how do I solve this
No description

βœ… Memory issue in ASP.NET Core video playback endpoint

```cs [HttpGet("filePreview")] public async Task<IActionResult> GetFileForPreview(string filePath) { if (!System.IO.File.Exists(filePath))...

Struggling with Securing Environment Variables in Deployed Desktop Apps

Hello, I'm creating an Avalonia desktop app that takes user input and generates a pdf by overlaying input text over a template image. The end result is a certificate for the completion of a canvas course for the interns at my company. The pdf generation is done, and I didn't have any issues with that. However, I would like the end user, whoever is handing out a certificate, to have an email send to the certificate recipient when the pdf is generated. I've used Gmail SMTP to successfully send the emails, but I couldn't figure out how to secure the environment variables in the deployed app. I then tried setting up an AWS Lambda function to hide the environment variables, but now I have the API Gateway endpoint that I don't want hardcoded into my application. It seems like any solution to this will just continue to push the issue further back. So, my question is: is there any way to deploy a .NET desktop application that does what I want it to do while keeping environment variables safe? My thought is that I might need to set up some kind of authentication and an actual web server on an ec2 instance to do this. Maybe I should just drop my goal of sending emails from within the application, but it seems like there would be some way to do this....

Trying to figure out what project preset type is best for deploying my project.

Could use some tips; I'm looking at deploying a project at work towards a Linux server. i currently have an ASP.NET Web API project (for the backend) and i've got an MVC project for the Frontend. I've been recommended to use a Blazor app for the frontend; Which makes me wonder if it's generally considered good practice to place both the Front and Backend into the same Project for easier deployment? Or should i keep them separated in their own projects under the same Solution?...

Go To Declaration doesn't consider RID for a Nuget package

I'm developing a OS-specific library with bunch of #if directives. As an example, consider the following method: ```csharp public static void Method1() { #if WIN_X64...
No description
Next