C#

C

C#

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

Join

im watching a course about asp.net and creating some kind of web

but everytime i try to do "dotnet ef migrations add init" it says "Unable to create a 'DbContext' of type 'RuntimeType'. The exception 'Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions`1[api.Data.ApplicationDBContext]' while attempting to activate 'api.Data.ApplicationDBContext'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728"
No description

Planning an app out before starting

I want to make a gong fu cha (tea brewing style, the main thing is that it involves even up to 10 steeps, first ones are short and they're getting progressively longer) timer & steep counter app with a statistics tab. The timer should allow to set a base steep time and an increment to be added each round. The app should allow to see how many brewing sessions there were each month. Each session should have the tea's name in it and a space for flavor and scent description. I'll be using AvaloniaUI and focus on mobile. I guess I'm going to need some sort of database for the descriptions and saving the sessions, I worked with entity framework and postgresql before. I want to give test driven development a try, seems like a good thing to know, although I don't know if I'll be able to do it before determining the app's structure down to each function and accurately tell what needs testing and what doesn't. Did I miss anything important?...

Serializing a Function in Unity using AnimationCurve

Hey there guys, I'm working on a game with Unity right now and I have a few classes which basically represent certain types of functions that I want to use in some contexts. What i would like to know is if there is a way to translate my functions into animation curves (ideally using a custom attribute such as SerializeCurveAttribute) so that I can use Unity's built-in serialization for said curves. I'm not quite sure how to go about this, as I've barely written any attributes, and the decompiled code for Unity's SerializeField literally contains nothing. Here is the code for my curve classes: ```cs public interface ICurve...

FirstOrDefault and other methods are not working in LINQ

```C# using System.Diagnostics; using Microsoft.AspNetCore.Mvc; using practical.Models;...

scope of a for loop

what is the scope of i in for (int i = 0; i < Length; i++) { }? does it only exist within the for loop? if i want i to be used outside, i need this right?
i = x
for (int i = 0; i < Length; i++) { }
i = x
for (int i = 0; i < Length; i++) { }
...

EFCore Discriminator Issue

Getting a very strange error on creation of my context. Ive been unable to figure out why this is popping. I was hoping that someone has experienced this prior and may be able to help.I can share any other info needed, just didnt want to overload the images. Thanks!...
No description

FluentUI Blazor rerender dropdown Items in ComboBox

<FluentCombobox ValueChanged="QueryChanged" Placeholder="Know it? Search for the title" Items="@_songOptions" Style="width: 100%"/>
<FluentCombobox ValueChanged="QueryChanged" Placeholder="Know it? Search for the title" Items="@_songOptions" Style="width: 100%"/>
With this element I hoped to update _songOptions on QueryChanged, but it doesnt get reflected in the dropdown options. To trigger refresh I have to click outside of the element, and then click back on it....
No description

blazor authentication service (WEB Api server)

i'm back end dev and i got no idea how i need to do Client side auth, any tips (or link on guide)? This is my Back End Controller i think to do AuthService in client side ```cs using Application.Users; using MediatR; using Microsoft.AspNetCore.Mvc;...

✅ Problem updating rider

Hello guys, I tried to update to the latest version of rider but the thing is I didn't have enough disc space and so the update was cancelled. Now that I made enough space, when I try to update it again, it seems that nothing is happening, I had the "update" button but when it finish updating, the IDE remains as it is and it seems that when I click on certain buttons, like settings or plugins, nothing happens. Is there any solution to tackle this issue please... I even try to invalidate caches b...

How to integrate RabbitMQ on a Microservice architecture

Hi guys, I have an app with a .NET back end made in multiple services, and those services are communicating with http requests, but some of them I'm waiting for a response when I do not need, I could just send to a messenger service like RabbitMQ, but there are some cases where I want to wait for a response to get data, from the videos that I watched about RabbitMQ, there wasn't one that showed how to wait for the other api's response, can someone send me some content or explain how can I implem...

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)