C#

C

C#

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

Join

Migrate .NET Framework 4.8 / .NET Core 5 to .NET 9 (.NET 10)

Hello folks πŸ‘‹! I maintain a solution that contains over 400 projects. They are a mix between .NET Framework 4.8 / .NET Core 5 / .NET Standard 2.0. The majority of web projects are built on .NET Framework with Microsoft.Owin, and some of them still use the old non-SDK project format. There are also several WinForms back-office applications, which we are planning to migrate to web. I’m aware that not everything can be upgraded, i.e. legacy libraries that are already out of support. My current approach is to write wrappers around such dependencies, and then gradually replace those wrappers with modern equivalents....

Is there a way to unload a class from the ram?

After seach in the internet how could I unload a class, the only way I have found is to use AssemblyLoadContext. Is there another simpler way which saves me from compiling in different dlls?

βœ… C# help

I don’t understand how to do the steps collision with the coins and collision with the potions.
No description

ERROR MSB4025

Hello I'm using Visual studio Code with C# Dev kit extension. I'm trying to build MonoGames tutorial game. But when I attempt to run my code I receive, "Build Failures". My terminal states that /media/erobros/CodeProjects/DungeonSlime/DungeonSlime/Game1.cs(1,1): erro MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. This is reproduced anytime I attempt to run the code. I even deleted the entire project and remade it and still am receiving the same error. My CodeProjects partition is on my secondary NVME it has plenty of space I'm afraid I may have gummed something up. My OS is Linux....
No description

βœ… Calculating the amount of gallons needed to paint a room.

I am trying to create a program where I calculate the amount of gallons needed to paint a room in C#. My question is: the formula is outputting a square footage of 300 ft instead of 396 ft based on the example. So is my formula wrong? Also the instructions require the use of read only get methods and copilot is suggesting the use of _backingfield variables to hold accessed data. Is there a way to just use the get; set; method taught in the book? ...

error during deserialization of a yaml file

I'm building a system that add the config file in the yaml format feature in my program, the program will throw this exception:
YamlDotNet.Core.YamlException: Exception during deserialization
System.InvalidCastException: Invalid cast from 'System.String' to 'dinfo.core.Handlers.ConfigTools.YamlConfigStructure'.
YamlDotNet.Core.YamlException: Exception during deserialization
System.InvalidCastException: Invalid cast from 'System.String' to 'dinfo.core.Handlers.ConfigTools.YamlConfigStructure'.
...

Aspire KeyVault - How to configure secrets and map them to IOptions?

I’m using .NET Aspire Azure Key Vault integration with the Azure KeyVault emulator to define secrets for my Aspire app. In production I’ll use a real Key Vault. The problem: Aspire forbids resource names with consecutive hyphens (--), but the Key Vault IConfigurationProvider expects that format to represent nested config keys (e.g. clerk--webhook-secret β†’ Clerk:WebhookSecret). For example:...

Help with RestSharp and Flurl GET request

I dont understand the libraries of RestSharp and Flurl. I just need to do a simple get request that returns a string that then i convert into a json. I already managed to make a succesful get request with a regular HttpClient so i know that the api works and its these libraries that i fail to understand...
No description

MSBuild: Excluding objects if %(Filename) matches any in ItemGroup

Given a target: ```xml <Target Name="ExplicitRemoveFromFilesToBundle" BeforeTargets="GenerateSingleFileBundle" DependsOnTargets="PrepareForBundle"> <ItemGroup> <FilesToRemoveFromBundle Include="@(FilesToBundle)" Condition="$([System.String]::new('%(Filename)').Contains('TerraFX.Interop.Windows')) AND ('%(Extension)' == '.dll')" />...

Game Crash On Scene Load

Hey, so I'm kind of new to coding, and I need some help with my script- when ever the scene attempts to load, my game just flat out crashes, and I can't seem to figure out why? So if anyone has a solution, I would be glad to hear it. I've attached my script if anyone needs to look at it, as I've been trying to fix this for a month now....

βœ… Need coding ideas for practice

I'm new to coding. I only know how to print, read, math, typecasting, classes, constructors, functions. Where can I find ideas and questions on how to achieve something through code? I want practice questions so I can go over these topics and understand them better....

Blazor Web Assembly and Windows Authentication

According to this link, https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/?view=aspnetcore-7.0#windows-authentication, Windows Authentication is not recommended for use in Blazor Web Assmebly. However, at work I have a blazor WASM static web site that passes windows authentication credentials to a backend web API just fine. This is implemented by using the AddHttpMessageHandler to create a client (see code below). Neither the WASM nor the API are exposed on the internet; this is all internal. Browser client simply prompts user for windows authentication, and API authentication is satisfied ```// In Program.cs builder.Services.AddHttpClient<IClient, Client>() .AddHttpMessageHandler<CredentialsMessageHandler>();...

Unable to see uncaught exceptions from async relay command task in MAUI

I have an async relay command from the CommunityToolkit.Mvvm in my view model like this: ```cs [RelayCommand] private async Task MyMethodAsync() {...

βœ… Need help connecting to SQL Database on .NET

I have already installed the EF Core module.

Guidance on Teams AI v2 SDK vs M365 Agent SDK

Hello all. I am looking for guidance on when to use these SDKs. The docs basically say M365 is for multi-channel and Teams is for Teams, but why not just use M365 Agents then? Anyone have experience as to where these two may differ. Teams is my targeted channel but want to spend time using the correct SDK.

Single-file executable can't find dependency DLL in its folder

The intent is to publish a single-file executable which loads its runtime/native dependencies dynamically from the folder it is located in. I have ensured that those versions of the dependencies are placed in the same folder as the output. The project file is: ```xml...
No description

How to setup for GraphAPI Event Subscription.

I am creating teams meeting using GraphAPI in my .NET project I want real time notification if someone changes event (Create, Update, Delete) from Microsoft Teams app. How can I do this setup?

βœ… How do I build a standalone C# exe?

What do I need to set in Visual Studio so that VS will build me an exe with all my dependencies (but not the actual base .NET runtime files) linked in?

From 0

I want someone who can give me some help , teach me from 0 and tell me the meaning for every code
Next