C#

C

C#

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

Join

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>();...

βœ… 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

Generic IH Handlers?

I have a json polymorphic type and I depending on where I'm using it, I want to get a different result type. I have two implementations, the top one works but the bottom one seems cleaner but doesn't work. Are generic handlers possible or do I need to stick to method A here ``` // THIS ONE WORKS [Handler]...

Fluent API: defining one to many

Models classes : ```C# public class Customer { public int Id { get; set; }...

What is missing or what is the proper instructions I should follow?

I created a new project using dotnet new blazor -o MyWebApp and at basic level at a page called Alpha.razor inside Pages inside Components file when I create a simple function private void test(){Console.WriteLine("Hello World");} and call it with <button @onclick="test">Test</button> However in the debugging session or when I run the project in the localhost:5345/Alpha I can't see the message Hello World after I click the button unless I add in the first line of Alpha.razor **@r...

Debugging of visual studio assembly loading for template

Hi! Trying to create a multifile template, that uses a wizard to just calculate some names for replacement. However, when I try to use it, it errors out with an "Template attempted to load component assembly 'TangoGatewayTemplates.dll'. I am not getting what error it had. Tried launching visual studio with the log enabled, and it doesn't seem to show up in the log. Any tips on how to get more information about what went wrong? As is, I am not sure if it's that it's not finding the assembly, or if its having trouble loading it after it's found it....

Characters stuck to the ceiling

as the title suggests, my characters are stuck to the ceiling. this was only meant to be a quick exercise. it has consumed a good 2 days of my life. Any help? the folllowing shows the code; p.s. i am using the monogame extension(?), if that changes anything...

MessageBox.Shown() only pop up in debug mode.

I have published a WPF app and I have tested if the message box show up in release mode but on some PCs it's not popping up on mine it's working. What can cause the problem in this case? I tried to change the target runtime also but not worked....

Microsoft Graph – Handling DeleteAsync Response?

Hey everyone! I'm using the Microsoft Graph SDK for .NET to delete a calendar event like this: await _graphService .Users[_teamsUserId] .Calendars[obj.CalendarId]...

Problem with ToString on a float

I have C# code that calls ToString("0.000000") on a float variable (which according to the docs means that its going to be rounded to 6 digits of precision) I have a case where the value in the float is -14.6511173 and according to the documentation, it should be converted to either "-14.651117" or "-14.651118" (I can't tell from the docs which way negative numbers are supposed to be rounded) but the output I get is (for some reason) "-14.651120". I am on .NET 5.0. Can anyone tell me why I am seeing 20 instead of the expected 17 or 18? If I ask it for another digit in the ToString, I get "-14.6511200" instead of the expected "-14.6511173"...

ASP.NET Identity: Error when adding duplicate usernames in AspNetUsers table

Hey everyone, I’m using ASP.NET Identity with a custom user validator to ignore duplicate username errors: builder.Services.AddIdentity<ApplicationUser, IdentityRole>(options => { options.Password.RequireDigit = true; options.Password.RequireLowercase = true;...