C#

C

C#

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

Join

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 ?

How do I go about making a project in c#?

A lot of projects people suggest are stuff like library manager, hospital manager l, note taking app and all of that, now while these are egood projects, how do I actually make them? Because you can't really make them as console applications, so I would like some guidance on that part, thanks!

✅ Unclear file structure

+---.github | ---workflows ---API +---Controllers +---Data...

VSS - Seeking Help

Can someone help me with a code? Im new, Its simple and easy but i just could'nt do it. Even chatGPT gave me something way different.
No description

Anyone knows how to code a Color Syntax?

So i have this empty function that runs 24/7 since it started can anyone make a script that highlights every word that contains "pause" and "test" to the rgb color 0,0,255? im trying to make a code editor Im using WinForm (i know my mistake but i cant reverse it) .Net framework 4.7.2 ...

Force Newtonsoft to deserialize into certain formats

I've been using JsonFx for a bit now and am trying to migrate away to Newtonsoft, but the biggest problem I've faced is that when you deserialize into Dictionary<string,object>, and the object is another nested object, it'll become a JObject. Is there any easy way to force Newtonsoft to deserialize T or List<T> (depending on the data), instead of JObject for all nested objects?

Struggling with JSON

Any Idea why does this operation makes half of the fields = null without any errors or anything, just half of the fields in the class become null without any real pattern
No description

Can anyone help me switch my primary key column from int to uniqueidentifier for my web app?

so does anyone know how to switch from int to uniqueidentifier in my database and update my webapp so it generates uniqueidentifier keys instead of normal int

Mono.Cecil TypeReference modifies TypeDefinition

i have this code: ```cs MemberReference member = instruction.Operand; if (Mappings.GetType(member.DeclaringType.Name, DefaultNamespace) is TypeDefinitionEntry typeDefinition) {...

✅ Working with npm in razor pages with vscode

I need to use npm for my project, and i don't quite understand how to add it t the solution. All of the info/tutorials i could find were about doing it with visual studio, and i could't find nothing useful about how to do it with cli. if i could get js/css files from npm standalone i could put them into the lib folder, but im entirely new to npm and don't know how to do it either. Can someone please help?

ASP.NET Core, prevent environment variables being exposed in launchsettings.json

I made my github repository public and immediately got an email from SendGrid saying my api key has been disabled cuz It was detected somewhere public. How do I tackle this, cuz all envarionment variables are in launchsettings? New to envirnoment variables. Prevent laucnhsetting.json from being pushed to GitHub?

Need pointers on code for console app.

I've been using c# inside of game engines for a while now, and I've just written some code for a simple console app for the first time for practice. Code: https://paste.myst.rs/4j1fa1ss I'm unsure about how good/bad this code is, the lack of an 'update loop' found in a typical game engine is throwing me off. My main concern is about the while loops when waiting for the player to make a valid input, is this standard practice? ...