C#

C

C#

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

Join

Looking for some NoSQL database with this characteristics

Good people, did any of you know some NOSQL database with this characteristics: - (Hopefully) an API or some other code neutral way to interact with it directly. - Reliability > Speed (Or anything else really, i need it than the data is reliable). - Have scripting capabilities, something similar or on point with SPs right out of the box would be good. - Can be installed locally, preferably using Docker but that is not a requirement....

✅ Avalonia Message Box

In Avalonia you can create a message box with this tool: https://github.com/AvaloniaCommunity/MessageBox.Avalonia, but how can I see what I clicked on the Message Box. Imagine I had a messagebox with Yes or No as an Option. How can I simply find what option I clicked and do something if i clicked either yes or no?

✅ Else condition refusing to work- looks correct.

first one is what i'm trying to solve, second one is what the error shows, and the third is something else that looks the same but still doesn't work.
No description

Cookies and JWT for Authentication

I'm working on a project and need help identifying an authentication issue I'm facing. My project uses ASP.NET Core 9 for the backend and React for the frontend. I recently converted JWT authentication to use cookies, but now authentication is not working. The claims properties are missing, and the user is not getting authenticated. If anyone has experience with this, please help. I Update the ProgramFile as well
`builder.Services.AddAuthentication(options => {...

Avoid a Build Every Time I Call MSBuildWorkspace.OpenSolutionAsync

I'm working on an app to help me do some analysis or querying of a codebase, using the Microsoft.CodeAnalysis features. I start out like this: ```cs public async Task<SolutionModule> OpenSolutionAsync(string solutionFilePath) { var workspace = ConfigureWorkspace();...

✅ how to store token in server side

InvalidOperationException: JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendered. When prerendering is enabled, JavaScript interop calls can only be performed during the OnAfterRenderAsync lifecycle method. #server-feedback

QuickSort implementation gets me an out-of-range error

I'm having some trouble with a quick sort function. Although I checked to make sure the bounds were the correct numbers when calling the method, I still get a System.ArgumentOutOfRangeException error message upon execution. Is there something within the method itself that causes it to go out of range? Or did I perhaps miss something silly? Below is a snippet of my code: ```C# static int MakePivot(List<int> mylist, int left, int right){ //for quick sort. int pivot = mylist[right]; //pivot on the right...
No description

✅ How does explicit loading differs from lazy loading when using EF Core

Hello guys, I was reading about the methods used to load data in EF Core. I came across eager loading, explicit loading and lazy loading. I understood that eager loading is loading data directly with the query, while lazy loading is loading the data as we go, like in a for-each loop. But I didn't understand the explicit loading can someone explain please. If explicit loading is loading data when we need, isn't it the same thing as lazy loading?

Problems with NVIDIA driver

Hi! Have you ever used a local generative language model? What is the best way to use gemma-2-2b-it or any language model locally? Is there a C# tool to do that easily or do I better stick to Python? I downloaded and installed Gemma-2-2b-it to my local computer (Asus VivoBook 17, 8GB ROM, intel code i3 processor) I followed this tutorial: https://youtu.be/7PbUaMdLGaA?si=uMpV_MSlM_8Ql7gs. I followed along the video tutorial, I copied testGemma.py in PyCharm and started the program, but it never gives an error, saying Found no NVIDIA driver on your system even though I have installed CUDA Toolkit 12.8 for WIN11, latest stable release. The program does not give me the answer. Any idea why? The pictures show the downloaded files and what I see in the IDE....
No description

lookin for a teacher

jst asking can any1 like teach/coach me c# in unity i got some experience (i hope i remember)

✅ Local csproj

I am currently working on a project which is used as a library. My problem is that if I locally develop the project it is a standalone project and should be run as WinExe. When I use the project as Library in another project the .csproj needs to be changed. Is there an easy way to have a "local" .csproj and a "github" .csproj. If I am on the wrong track, please let me know....

asp-net notation does not recognise attribute notation from a model class

My Rider flagged this ListingImage notation as unrecognisable in cshtml ``` <form enctype="multipart/form-data" > <div class="custom-file">...

✅ Dispose method to "dispose" file resource when using LogTo method

Hello guys, I'm trying to implement some simple logging in my DbContext. I want to write the logs in a file; when done, I need to dispose/close the file. I read that we can't use the using keyword because this would mean that our file stream will be closed and we won't be able to open it again (I thing, can someone please confirm please) and so we need to use the Dispose method. ```C# public override void Dispose() {...

Implementing SignalR for Real-Time Notifications with Offline Fallback

I'm exploring how to implement SignalR for push notifications and evaluating two connection management strategies: 1. In-memory tracking with ConcurrentDictionary – Simple but does not persist connections if the server restarts. ...

✅ StreamWriter not writing to file

Hello guys, I changed my file properties to "Copy if newer" (I didn't understand why we need to do that, would really appreciate if someone can explain) .... I was able to read a file but when it comes to write to it, it seems that nothing is being written and no exception is being thrown (I added the .close method). ```C# // How to read and write to file in C# string filePath = Path.GetFullPath("sample.txt");...

I don't understand why function pointer works this way.

In this code, an error occurs when TestMode = 1 or 2 and no error occurs when TestMode = 3. I get the same result whether I use Release Build, Debug Build, or Ctrl+F5. I am using C# 9....
No description

Native AoT dependency issues

I'm not familiar with how any of these concepts work - I just found a library called NPlug (for developing VSTs using C#), and it uses PublishAot to compile. When I try to add any dependencies, like SkiaSharp or OpenTK, the vst can't find the dlls. I managed to brute force it for SkiaSharp like this: ```cs NativeLibrary.SetDllImportResolver(typeof(SkiaSharp.SKImage).Assembly, (libraryName, assembly, searchPath) =>...

Format text in file - Windows Forms

I'm creating a class creation automator, basically a Windows Forms that has components like the class name, and the properties that the user wants to insert, when he clicks on add class, a savefiledialog opens. The problem is that I need help formatting the text in the class file, I tested with String builder but it didn't work well, because I can't indent the keys, or can I? I'm a layman on the subject so any help or path to follow will help a lot. Thank you.
No description

Tried to use unitys eventsystem to set a tag to a clicked gameObject, getting nullReferenceException

Hey yall. Im trying to give the "selected" tag to my tile gameobjects when I click on them. The attached script is a child of the tiles. It is supposed to work as follows: 1. Find the previously selected tile. 2. Remove its selected tag(if no previously selected tile exists(this is the first tile that has been selected), skip this step) 3. Apply the selected tag to gameObject we just clicked on. However, I get an error "Object Reference not set to an instance of an object" when I attempt to run the last line(step 3). Perhaps I am not using the event system properly?Any help will be greatly appreciated...
No description