C#

C

C#

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

Join

Loading Form crashing (Windows Form)

So im doing a pdf viewver using winform. I wanted to add a form that indicate the progression when loading the pdf pages. The problem is that the application crash during the for loop, and the loading form is not showing up before and its showing at the end of the loop but this is useless since the content is already loaded and it close immediately. I've tried many thing like using Task.Run but i cannot fix it. (pls help)

Connecting Lines in 3D space

Hey, I'm fairly a newbie to coding in general and first time asking for help on a forum so hopefully its a decent enough explanation. I have a list of Lines, and there will always be two outer vertical lines, which I can get easily enough. I'm now trying to create two lists of the upper lines and the lower lines. As shown in the images in blue/red. Any ideas on how I can best achieve this?...
No description

Apache dying on system cron job, but not everytime

Hello, i'm facing an issue with my apache 2 server crashing sometimes at 6 am due to a system cron, running at 6am to apt-upgrade, somestimes the apache2.service just cannot restart not much of the reason behind
No description

Pack URIs do my bloody head in - help needed

See image for setup. I'm getting a file not found on GreyscaleEffect.ps. As far as i can see and following the MS guidance, this path should be right. GrayscaleEffect.ps is set to Resource so should be being built into the assembly. Bane of my life these bloody Pack URIs!
No description

There was an error exporting the HTTPS developer certificate to a file

Hello everyone, I am facing the following issue with a brand new project (ASP.Net, SQL server and Angular: The only change that I ever did on the project was the connection to the SQl which worked. What I did so far was: dotnet dev-certs https --clean...
No description

How can I resolve this problem?

Hello Everyone, I am .NET learner. In the middle of one project, I have faced a problem and I can't resolve this alone so I post this. I can't run this project.I don't know this is right but in my thought it is because of .NET version. The project is using .NET 6.0 version but I installed .NET 8.0 in my laptop....

Entity navigation modelling so I can understand it better

I have 7 entities but i need help to configure the 3 entities so i can understand how it works better
No description

Custom msbuild task

hey i wrote a custom msbuild task and created a nuget for it. in the project Im using the task it seems to work, but in the CI it doesnt. i can reproduce the same error when cleaning my nuget folder locally. `[MSB4036] The "..." task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTas...

/reference flag in C# compiler

What is the use of this flag?

Why does this not print the firstname and lastname

Yo, im trying to make a login function in c$. Logging in works but it does not want to print the first and last name it only prints welcome back. How come?
No description

Trying to get started with threads but UI thread giving cross thread exceptions?

I have a thread that runs infinitely and what i believe is happening is that the new thread means events run on it leading to cross threading exceptions but i dont understand why that thread cant run in the background and events stay running on the main ui thread? This is the test i am using for my new thread ``` private void CalculateEngineOutput() //Calculate some of the main outputs...

Metro MahApps checkbox content change color when hovered.

I have a checkbox that will change the color of the content inside. As the gif shows, you can see that, the content does change color, however, the color is also changed when I hover the mouse over it, I try to find a way to disable the hover functionality but it seems to be no use at all. If anyone knows anything or could give me some suggestions, i'd be very grateful
No description

Simple help in httpclient c#

I started to learn C# recently. I tried to do on postman and it was successfull. i wanna implement that feature with httpclient c#, but i face an issue. Who can help me?...

C# and native interop with JNI

So I've been tinkering with this personal project of mine to try to get C# to interop with Java using JNI (Java Native Interface). This project relies heavily on unmanaged wrappers for JNI calls that I call later using C# and DllInterop. Here is my issue, After the native call to JNI_CreateJavaVM() and returning the pointers to the JVM and ENV (pointer to native method interface) back to the C# managing object everything appears fine and working as expected. JVM initialized, I've got pointers to the important structures to create Java classes on hand and ready, but when i decide to utilize the jvm pointer in a very simple case , to destroy it, I'm getting system AccessViolation Exception. At first i thought this was happening due to a silly mistake on my end where i wasn't allocating the structs on the heap, so when i exit the native function call the memory addresses returned are invalid, but I am now using malloc() which should store the structs on the heap and I received the same error. Is there something I'm missing when passing void pointers in C# to native function calls? Please let me know if im not very clear, I'm self taught and I'm not the best at conveying information. I can share code if it'll help....

Copy file to build directory

How would I make it so a file I added to the program files would get copied to the build directory when the program is built?

How to prevent nulls using this approach for Object Initializers?

In C# I have this class: ```cs using System.Diagnostics.CodeAnalysis; using System.Net.Mail; ...

What type of 3 layered architecture should I use

I'm building a project with the following techstack: ASP.NET EF Core SQL Server React...
No description

unmanaged struct issue

Do have experience if in c# casting nint pointers to other pointer types is bad? Like I want to allocate an unmanaged struct. And I just cast the nint pointer returned by NativeMemory / Marshal to T*. Should I be using Span<T> instead? because I read casting to different types will return more or less data on dereference than I'd want. And I cast the pointer to the memory a lot...

Azure Functions Dependency Injection "unable to resolve"

Why am I getting Unable to resolve service for type 'Bugreporter.API.HelloWorld' while attempting to activate 'Bugreporter.API.Function1'. ```c# using System.Text.Json; using Microsoft.AspNetCore.Http;...

A built in way to send SIGTERM ?

Hello there, is there a built in way to send a sigterm in .NET 8 ?