C#

C

C#

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

Join

✅ OnParametersSetAsync() in a blazor component being called before clicking a button in Blazor app

I created a component in Blazor, a CourseList which has a Parameter of TermId its added to the Terms.razor page as such ```cs <button class="btn btn-primary" onClick="@(() => ShowCourses(term.Id))">Show Course List</button> <CourseList TermId="termId" />...

Whats the difference between Workspace and AdhocWorkspace?

Im currently trying to learn roslyn api. In Microsoft.CodeAnalysis namespace, there is two classes named AdhocWorkspace and Workspace. Whats the difference between these two? Which one i should use?

✅ Discord Authentication Redirection Issue

Hi. I am new to C#/ASP.NET and just want this Discord OAuth "Challenge" to work properly. Current Routes:...
No description

✅ Mystery errors that appear in build output but not the editor

I'm rather puzzled why the C# compiler reports these issues. They all appear to be bogus. No errors are listed in the C# editor. Some of the identifiers the compilers failed to find were classes that the C# editor not only found, but marked as classes with syntax highlighting. It doesn't report any errors there. Does anyone have any ideas what's going on? I just checked code into https://github.com/ChatZilla-Replacement-Project/BestChat/tree/AvaloniaBrokenAXAML....

MySqlException: Column 'Age' cannot be null

So this error occured in the following scenario: I have created a simple ASP.NET Core web app with some simple db configurations. On running dotnet run from Rider, the browser displayed my web app (a login form). I have click "register a new user". Then I was redirected to a register form page with three textfields , email, password and repeat password. I filled in all of them and hit register. Now I was bugged with this bunch of exception texts https://pastebin.com/7DqbUai5 I don't understand this error Column 'Age' cannot be null. I made extra sure that my DB has the column Age with non-null values like this: ```mysql> SELECT * FROM PortalUsers;...

✅ Visual Studio Projects

Hello! I want to start over with programming my first application and I already run in some troubles. Basically every Tutorial on YouTube, which shows me how to create a project, is so different in terms of the visual studio version they use. I just can't figure out how to start. Hopefully someone can show me the basics, which are necassary to create a project. 😄...

Accessing configuration inside CreateDefaultBuilder chain

I'm trying to override the configuration implementation of IHostBuilder via the CreateDefaultBuilder method with my own using the below. Then, later in the IHostBuilder chain, I'm trying to read a value from configuration, like shown. My appsettings.json file clearly contains WebService.BindUrls, and I can see when debugging at runtime that configRoot contains WebService:BindUrls. Now I'm really confused. Can anyone shed some light on why bindUrls is coming back null? appsettings.json ```json {...

✅ Passing a potential NULL value, is it allowed?

```cs namespace Calculator.Controller { internal class CalculatorController {...

Sharing the custom marshalled type across libraries

I followed the guide thoroughly https://learn.microsoft.com/en-us/dotnet/standard/native-interop/tutorial-custom-marshaller and source code is in here https://github.com/dotnet/samples/blob/main/core/interop/source-generation/custom-marshalling/src/custommarshalling/NativeLib.cs so far it works, but things goes south when i try to use the ErrorData outside of host library code used to test it out: ```C#...

EF-Core unable to create migration

I'm trying to crate migration, but every single time I get this error. Startup project is set and in package manager project with DbContext is selected too. Haven't changed anything significant that I could think of since last migration. DbContext https://codeshare.io/k0zVX3...
No description

Using code generation to replace reflection, and Roslyn+Visual Studio performance.

Hey everyone, To better support trimming and AOT I'm shifting over some reflection code to code generation, which involves going over namespaces and types and generating functions to replace my usages of reflection. The generated code works and everything is fine, however it seems to me like Visual Studio's performance is way down and stuff like Ctrl+Click/F12 randomly stop working. Additionally hot reload randomly stops working and sometimes even watching values. I am observing this behavior across multiple computers and VS installations. ...

✅ C# homework help (german)

I need help for my C# homework. If someone can help me to do my homework with me it would be pretty nice.
No description

Does structs generate inaccessible copies?

Consider the following large structure for the asked questions ```cs [InlineArray(128)] public struct x1024BitBuffer {...

How to disable Microsoft Identity Web generated endpoints and redirection

So, in my project, I am trying to use microsoft identity for azure ad b2c configuration. But the problem is, it created its own endpoints, and now whenever I go to a non existing endpoint, it just chooses to redirect to the azure ad b2c provided remote url. It is weird what is going on. I only have it here in my asp.net webapi project: ``` builder.Services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options => { builder.Configuration.GetSection("AzureAdB2C").Bind(options);...

✅ RPN calculator

I am coding a RPN calculator and I am supposed to do the calculator.view part and I just want to make sure I am doing it right. This is the code I have written so far and I attached the instructions. //Calculator.view// using System; using System.IO;...

Entity Framework Core Migration to Supabase Hangs Indefinitely

I'm trying to apply an Entity Framework Core migration to a Supabase PostgreSQL database, but the process hangs indefinitely. Here are the key details: - Using .NET 8 and EF Core 8.0.8 - Initial database connection succeeds (confirmed by console output) - dotnet ef database update command never completes...
No description

✅ Help with Tooltip content binding

I have created a UserControl with dependency Property to accept the string for the TextBlock within my ToolTip XAML: ```xml...