C#

C

C#

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

Join

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

I can't find the problem with this bot

Hello everyone, These are code snippets from a bot that runs inside a trading platform called ctrader to modify trading positions, but the modify position shortcut (which is a signature method shortcut inside of ctrader API) is not working, please clarify the problem to be, Thanks. I attached all the code that I figured will be related to the problem, Iam new to coding so might have missed somethings ...

Hello i have a question i am trying to display this text on my game but it doesnt work can anyone h

Hello i have a question i am trying to display this text on my game but it doesnt work can anyone help me?
No description

✅ XF -> MAUI (Shell) - Trying to translate this weird navigation model 😵💫

Hey! So I'm currently trying to migrate my org's Xamarin.Forms app to MAUI (with Shell navigation) so that we don't get kicked by Apple over it. I'm finding myself using quite a lot of Syncfusion with this project! In the existing app, it used what I think is a rather convoluted system for navigating field service appointments (see diagram 1) Any ideas on how I can use this with Shell navigation? Or should I just give up on the whole rewriting to use Shell thing and try to copy over the existing structure from the old App? Biggest thing that's thrown me off is the warning on the Docs that FlyoutPage (the successor to the MasterDetailPage type that it's currently using) isn't compatible with Shell and that an exception will be thrown if you try to use it (https://learn.microsoft.com/en-us/dotnet/maui/user-interface/pages/flyoutpage?view=net-maui-8.0#:~:text=property%20changes%20value.-,Warning,-FlyoutPage%20is%20incompatible). I've got access to a full Syncfusion license so I'm debating whether I could maybe make it work with a TabbedPage or maybe a BackdropControl views with their own view models, inheriting a shared BaseAppointmentViewModel with the actual appointment object? I'm still fairly new to C# (and MAUI in particular), I only finished my apprenticeship 6 months ago and already have this entire rewrite on my plate :laughCry: Aware that I've probably not explained it very well, unfortunately I can't do much in the way of code sharing to demonstrate what I'm trying to convey as it's company IP and so I need to tread very carefully with discussing in public. Thanks in advance for any help, I'm really struggling to get my head around this! 😅...
Diagram 1 - Existing sub-nav hierarchy architecture

App.xaml

Hi guys, I'm fairly new to C# & WPF, but I'm trying to make some basic macro scripts, but I'm running into a problem and I can't seem to figure out whats the problem. I keep getting the error that my 'class' property not exist in the XML namespace, but it's cleary there. What am I missing?...
No description