C#

C

C#

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

Join

EFCore - When to save changes

I have an application that uses EFCore. In this application, I have a method that gets some values from the database, and may or may not change them based on some conditions. How should I handle the saving of changes in this scenario? I've thought of a few solutions:...

✅ Azure Key vault - what is considered a transaction?

Hello, I am using Azure vault to load configuration values, just like from appsettings. What happens if I have 10 secrets in the vault, each needed by different services. Will .NET load them in one transaction, or is it done individually one by one? The package is from Microsoft: https://www.nuget.org/packages/Azure.Extensions.AspNetCore.Configuration.Secrets...
No description

✅ Scanning PDFs using ASP.NET

So in my current project im using iTextSharp to scan PDFs for text; But also something called "Tesseract" to scan images for Text; Then im filtering the text to get the information i am looking for. Figured a good way to go about this is using ReGex. The PDF/images in question are Invoices. Could use some tips to get the correct information....

ASP.NET CORE MVC VS ASP.NET CORE WEB API

For someone who has has been learning React for a while, would you recommend I skip the MVC and focus solely on the Web apis, or should I still learn the fundamentals of MVC?

Slow WCF requests

Hi, so I've generated a bunch of WCF request clients for ONVIF from WSDLs using svcutil and all the requests are extremely slow. It takes 1 second to get the 401, and then another second to get the result with Digest auth included. Not sure which details y'all need so I' m just gonna post this and wait for questions.

Using Azure ADB2C, new user claim is being sent on every sign in

I am trying to use azure ad b2c for user signup and signin. And after signup, I want to use the newUser claim to add the user email to queue storage for one of my azure functions to do a task around it. I am using ASP.NET as a web application for this. The problem is that azure ad b2c is caching the token in the browser. So, whenever I sign in, it is not sending a refreshed token. So, the newuser claim is being sent until I logout and login again. I wanted to manually check if the user is in database using microsoft graphs but the catch with this one is, by the time I am checking, the user is already in the users list....

Sudden compiling errors

Suddenly when I went to "publish" a new version of an application I help develop, I started getting all these POSTSHARP errors. However after I got these errors, another contributor to the project did a fresh clone of the github repo and was able to compile it perfectly fine, and github actions also compile it fine. Why am I the only one getting these errors and how do I solve them?
No description

razor page says the number 2 is invalid

I'm new to coding in general and I'm trying to take a numeric from a form and bind it, but whenever I try to enter a number into the form, the debugger says the value is invalid and it got converted to an empty string.I can't figure out why it's doing that. What am I missing?
No description

✅ need help in c#

Severity Code Description Project File Line Suppression State Details Error 'Could not load type 'System.ComponentModel.Design.IServiceContainer' from assembly 'System.ComponentModel.TypeConverter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.' DocReader E:\Acrobat-SDK\smartcite-win-app\DocReader\PDF_Viewer\LC
please fix this error...

Bonus

https://github.com/owill8/ITP--136/blob/master/week%207%20project/Program.cs Would my code follow these rules: Use a For Loop to loop through your code based on the number of bags entered(in method). Use a While Loop to loop through your code based on the number of seats entered(in method)....

Garbage collector

Hello, please tell me, who knows about the "garbage collector" in C#, how to search for garbage leaks in a C# program, are there any tools for viewing references to an object in the heap, because of which the "garbage collector" does not reach and does not remove them.

Need help with fixing my rounded rectangle calculation

Hi! I'm making script for Unity. I'm bad at understanding floating points calculations and geometry, so it might be silly. Help me please ```c# public RoundRect(float width, float height, float r) { if (width < r || height < r) { throw new Exception("Radius"); } this.width = width - 2*r;...
No description

I want a page to play music in my WPF app, I have it working at the minute, but there is a problem.

I have a function that when a specific page opens, it starts playing music. It works fine, but when you click off the page or go on it multiple times, the music starts slowing down and bugging out, and it starts using absurd amounts of RAM. Voice calls in Discord also sound ass when it starts bugging everything out, but I'm guessing that's due to the RAM problem. I just need help trying to figure out how to stop and sort of dispose of the music, so it's not even being used in the code anymore, untils it's page is opened again....

Is there a way to create an AWS SAM image on docker with compose ?

Hi , I 've a doubt about AWS SAM. Is there a way to create an container on docker who run like LocalStack , and provide SAM server and SAM build directly from container ? I want to do on this way, beacause i want segregate this from my computer, i dont want to install. I want to do this for .NET CORE 8.0...

changing a boolean value outside a loop from inside a loop

so im doing a leetcode challenge to detect duplicate numbers in an array, im trying to use the duplicate bool value so when a duplicate is detected, it edits the duplicate value to true and exits the loop, no matter what i try the output is always false however ```cs public class Solution {...

NUnit test with Asp net web API

Hello, Im having trouble to setup NUnit tests for the API, as of now it seems Ive managed to start the service and it's running yet whenever i send the data to my endpoint it simply returns a 500 message...

Convert from MSSql to MySql

I'm trying to convert this MSDoc tutorial project from a local instance of MSSql to a MySql server. I'm fairly certain I've gotten all the configuration correct, except the syntax differences of MSSql to MySql. (i.e nvarchar) I pushed it to GitHub if someone is able to take a peek at it. Thanks in advance. https://github.com/Cykotech/RazorPagesMovie...

what are hashtags for in C#?

i've written C# for a month and have zero idea what these hashtag symbols are for. like #define - what does that do?