C#

C

C#

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

Join

✅ Unit Testing in Rider not working

Hello, I've unsuccessfully attempted to use NUnit 3.14 with Net 8.0, and Xunit 2.5.3 with Net 8.0, and Xunit (2.0 or 2.1.0.3179) with Net 4.0, and NUnit 3.5 with Net 4.0 - all respectively shown in this video: https://www.youtube.com/watch?v=PyY5X7ylGOc I've also tried both with Net 7.0 According to NUnit, Net 4.0 should be compatible with any NUnit underneath 4.3; I'm surprised NUnit 3.5 didn't work with Net 4.0: https://docs.nunit.org/articles/vs-test-adapter/Supported-Frameworks.html...

Looking for AI dev to back me up a little in open source project

Hi guys, trying to make some open source project for face blurring in C#, I need to remove one dependency from some small, (looks like) abandoned project to fully switch to OpenCvSharp. I want to use CenterFace ONNX model to detect faces. Code is almost done, I just don't have enough DNN knowledge to replace the "3rd party" library partial implementation with OpenCvSharp one. Anyone interested? 🙂

✅ random current value?

Hello, I'm using a naïve Random generator, and I'd want to display the current seed used, in the hope to replicate the current state for some later replay. How can I achieve that, apart from having a second Random seeding its .Next() int to the actual Random?...

✅ Creating multiple projects inside one solution in Rider on mac

I can’t find any way to create a second project inside my solution because the add drop menu simply doesn’t have anything related to adding projects/solution folders.
No description

My autoclicker project is not working.

I will attach the codes I am using for the autoclicker so you can check and review, there is no error when compiling. It is simply that when I have it compiled it does not set coordinates and therefore it does not activate either. I have 2 Timers added, Timer 2 is in Enabled True.
No description

Cannot get my ASP.NET site to publish to Azure app services.

I've been banging my head off the wall for 3 days now. This is the first site I've ever built and it has gone great upto this point. I added a view counter to the homepage to I could see how many uses it gets which worked just fine. Accept every night when the Azure servers reset the counter resets as well. So I learned how to create an SQL database to store the counter. It works perfect when I run it locally but when I try to publish it I get the error below. Error: Could not copy "C:\Users........\wwwroot\lib\jquery-validation-unobtrusive\dist\jquery.validate.unobtrusive.min.js" to "C:\Users........\obj\Release\net8.0\PubTmp\Out\wwwroot\lib\jquery-validation-unobtrusive\dist\jquery.validate.unobtrusive.min.js". Exceeded retry count of 10. Failed. I have tried verything from removing it from the dist folder up one. To manually copying it to the new location. To moving the entire project to a new directory because the file path was so long. ...

✅ stuck on getting 20 prime numbers C#

I have been trying to figure this out for 4 hours, I just can't. help me please. so I have to generate 20 prime numbers using for() and then sum them...

Project Installer

Hi, i've created a .Net 8.0 Wpf application and i'd like to know which project installer i should choose between wix Toolsets and Microsoft Visual Studio Installer Projects 2022 ? It seems likes Visual Studio Installer Projects 2022 are more .net Framework app oriented.

Multilayer architecture - explanation?

tl;dr: Have been mostly working on existing projects and have some problems in early stages of the architecture development. Hey all! I would need some additional explanation on how do you usually approach the multilayer architecture. I came across one early project which already had some of the projects made, but idk why and what should even be there (lets call this project ExplainMe. ...

✅ Issue with Sdk Targeting Multiple Frameworks

Hi everyone. I'm creating a sdk that targets both .net 6 and .net 8 frameworks. The publishing works fine but when I add the sdk reference to .net 6 project it is giving me the following errors: 0>CSC: Error CS1705 : Assembly 'SDK' with identity 'SDK, Version=8.0.0.8, Culture=neutral, PublicKeyToken=null' uses 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 0>CSC: Error CS1705 : Assembly 'SDK' with identity 'SDK, Version=8.0.0.8, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.AspNetCore.Mvc.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.AspNetCore.Mvc.Core' with identity 'Microsoft.AspNetCore.Mvc.Core, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'...

How to setup shared/common data in a web app

I've been working on a legacy project with .NET Framework 4.6. there is a Shift class and initially it had this code in its Shift entity class: ``` public static Shift None => Database.Find<Shift>(s => s.Department == null && s.IsNone);...

✅ What is a concrete class?

And what is the difference between a concrete class and an abstract class?

Looking for help to test Zebra printing on Linux

Hi all, I have a ZPL print service that allows you to send ZPL templates to a zebra printer. All is working well on windows machines. Recently an user created an issue, the request returns a 200 but nothing is being printed on Linux Ubuntu 22.4. I don't have a Zebra printer at my disposal at the moment and I'm looking for someone to help me test the possible fix I have. The issue is located here -> https://github.com/Tim-Maes/PrintZPL/issues/1 If possible could someone who has access to a Zebra printer clone it, update the service with the snippet I provide, publish as linux service and see if anything is being printed? ...

✅ EF not creating all tables from migration

So I can use dotnet ef migrations add <name>. It says it successfully created a migration. Then I use: dotnet ef database update and itll create a database with a _EFMigrationsHistory table but not any of the other tables that I actually would like to use.

c# beginner

so i noticed a few videos talking about job requirements and atuff, those that get accepted usually have a whole list of languages they know, so i guess my question id what i should be learning next / along with c#? from a fairly new beginner

(Still) Failing to process an XML API response

hi guys! still quite new to C# and .NET (coming from Java). i am working on handling an XML API response, but continuously fail to achieve this goal. as mentioned, payload is XML format. response headers seem correct (text/xml) and the encoding is set to UTF-8. however, i fail to deserialize the body to an object. tried to add some debug "WriteLine" statements, and saw that the response looked unnatural - what happened is that only the strings between the XML tags were part of the response body, but the tags themselves were lost. and i have no idea what happens there. i've tried a ton of stuff - processing the body as simple string or as stream did not work, the encoding is properly set to Encoding.UTF8... and played around with different solutions, debug logs etc....
No description

Generic converter bounding in EF Core

Is there an way to "easily" define converters for all properties which uses an generic type? Currently, I have something like this: ```cs protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) {...

.net does work with Android Studio on Mac M3

Hi! Both Android Studio and .net (via terminal) individually work on my Mac (M3 Air 24GB OSX 15). However, now I want to compile a Android GitHub project, that is based on the .net SDK and every time I try to build it, it throws out a generic "process command dotnet returns non 0 value "1"" error, or something like that I previously build it on my Windows PC already and I got that error there as well, because the project requires v9 and I only had v8 and after updating, the error disappeared. On my Mac however, I am stuck at this error. Any idea?...

Not found 404 at await fetch

I have been developing a simple ASP.NetCore web app. Now my task is to load backend data onto frontend which I struggle a lot I keep getting 404 errors on my Chrome devtool once the dotnet run is hit and a browser opens All the relevant codes right here https://pastebin.com/R8dCFJgC You can view my explorer tree per screenshot in the attachment...
No description