C#

C

C#

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

Join

MVVM Toolkit Messenger - RequestMessage

I have no idea why one of the methods is never executed... take a look at this vs Messenger
C#
public class AsyncRLoginMsgReq : AsyncRequestMessage<bool>{};
C#
public class AsyncRLoginMsgReq : AsyncRequestMessage<bool>{};
```C#...

I'm having a weird null reference issue with a Razor Pages view component.

I have a shared layout where I'm trying to pass either a student or teacher ID (or 0 if none) to a view component. Even though I'm explicitly handling null cases I keep getting a NullReferenceException. Here's my layout code: ```csharp @if (!ViewContext.RouteData.Values["page"].ToString().Contains("/Account"))...

Integration Test for 3rd party API

Guys, I would like to ask opinions regarding integration test related to 3rd party API. My Opinion for Integration Test - Do actual API request to the 3rd party API so that we can get the actual value and verify the application work flow in general. ( We don't pay per request) Reason : The purpose of integration is to check the current application can communicate with other applications without any issues. If Anything has been changed from the 3rd party, we can verify just by running the test all. No require to figure out where it came from....

Ubuntu 24.01 WSL build Package Microsoft.NET.ILLink.Tasks, version 8.0.10 not found

When building C# .NET 8 library extension on Ubuntu 24.01 WSL I get the following error even though the build finishes: Severity Code Description Project File Line Suppression State Details Error (active) NETSDK1064 Package Microsoft.NET.ILLink.Tasks, version 8.0.10 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. ArmaDragonflyClient C:\Program Files\dotnet\sdk\8.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 266...

problem with Rpc code

hello guys i tried to create bot with c# to send messege inside the discord bot depend on packet recived from app so its working and connection succed and get all info about channel but its not sent the messege so how can fix something like this its first time try to create something fo discord i don't know the good logic to set it its alread read data but not sent it C# project
No description

[Unity] Is there a way to have a ContextMenu give an arguement to a method?

I'm working on a real simple save function in Unity that I can call from the context menu, and everything works wonderfully without an input (of where to save) so far, but I'd like to be able to test it with different save locations. That's all context though, my question is can I pass an input into the method being called through the Context Menu? https://discussions.unity.com/t/can-contextmenu-pass-arguments-into-a-method/248683 I found this discussion thread, but it's a few years old and just amounts to "Probably not", so I'm curious if anything has changed....

can u help me make the mouse not move the slider when colliding with the slide bar?

https://paste.mod.gg/ypaygrlzizyf/0 full class otherwise the method i added is i think the only one in my class for controlling the slider...should be anyways ...

WPF RichTextBox is very slow

I want to make a syntax highlighter with WPF. I chose to use RichTextBox but when trying to paste about 50,000 lines into WPF richtextbox, it takes about 10 minutes to complete as in this video. I compared with textbox on winform and wpf, and compared richtextbox on winform is faster. I also did syntax highlighter with update onscroll (not in rich text box) as at the end of the video and it can display faster. But when scrolling, over time the grid becomes have many objects (TextBlock) and becomes slow. How can I do syntax highlighter in WPF efficiently and quickly?...

What is the use of Interface

I'm wondering what is the difference between referencing "void" directly from another file and calling it with "Interface"? I'm a newbie to C#, and a lot of cross-file code calls are used directly with a new definition of that file name, such as "public Player_Data PD"

WPF Design patterns

Hey! I was wondering, how is the WPF solution structured? How detailed should it be separeted in multiple projects? Is it similar to APIs or something? So "WPF project" (views, viewmodels), "application project" (services, models), "Data project" (working with db), etc?...

✅ link A project's file to B project which references A project

how can i link file, so it will appear when you reference project A i tried <Content Include="CustomNativeConfig.props" Pack="true" Link="%(Filename)%(Extension)"/>, but it didn't work...

Attempt to run a program with dll

I'm running this from vscode. The full error is: ``` c:\Users\Admin\.vscode\extensions\ms-dotnettools.csharp-2.50.25-win32-x64\.debugger\x86_64\vsdbg.exe --interpreter=vscode --connection=e8ed18252661403681b3640aca80dbff Unhandled exception. System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B) at Naquadic.Miniaudio.Windows.avx2.ma_engine_init(ma_engine_config* pConfig, ma_engine* pEngine)...

how do stacks, lists, arrays, etc have a collection expression?

is it part of the compiler or is there a special function or attribute you can give code in order for it to work that way?

Why is the antiforgery token in MS example appending the token only on "/" or "/index/html"

I'm working on an angular SPA front end and C# web api backend. I want to use antiforgery cookies. The front end and backend live on the same server on different ports (not sure if any of this is relevant to the question). I've got the antiforgery cookie correctly working - if I visit my page directly, www.mywebsite.com, then the token is appended and everything works fine.. However, if I visit my angular SPA starting at a URL that is not "/" or "/index.html" then the cookie is not appended and I get exceptions in my backend when trying to make calls. I think this is because I am implementing it as suggested here: https://learn.microsoft.com/en-us/aspnet/core/security/anti-request-forgery?view=aspnetcore-8.0#generate-antiforgery-tokens-with-iantiforgery ...

Utf8Json or Jil for Net3.5

Hey there! I'm trying to improve the performance of a game made in an older version of Unity that uses Net 3.5, and want to find a better JSON serializer and deserializer (current is JsonFx). I read about Utf8Json and Jil, but there don't seem to be any 3.5 versions available, even though I have read several articles and StackOverflow posts that mention them. Any help is much appreciated!

Questions/concerns about memory usage in my project

Apologies for the messy formatting, I created this post because of multiple concerns and/or observations while profiling it. The first part is that I'm not very familiar with how GC works or is expected to work. Clearly in the first screenshot the drops are caused by garbage collection, but I'm unsure what's causing the gradual rises in memory. Is this just normal behavior since it seems to always drop to around the same level each time GC runs? Second question: What could cause total memory usage to vary wildly over the duration of a project running? In my case, this is a Discord bot profiled by dotMemory over the course of >24 hours (second screenshot). It reached a peak of 4.91GB used, and now we're currently using 2GB and the lowest total memory used was about 1.3GB. Snapshots have not shown me anything extremely out of the ordinary, it's expected data to be in memory. The only confusing part is that there are large quantities of CancellationTokenSources (third screenshot), despite every instance of one wrapped within a using statement to ensure it was disposed of. I'm very new to disgnosing memory leaks and/or usage issues so if I'm expressing incorrect assumptions or missing anything extremely obvious, let me know. I can post screenshots of my snapshots or anything else that might be relevant if needed....
No description

User built queries on objects

I'm looking at an old app that allows users to build queries to retrieve objects in a list that match that query. It is only querying off a single property on the objects: a Dictionary<string, string> . Each object's dictionary property will always have the same keys. In the current code, it is a massive mess of nested if/else statements. The flow goes like this: 1. User selects key from the dictionary's keys...

Force Clickonce to use a specific port?

How can I force a clickonce setup and the update mechanism to use a specific port? including the initial connection