103 questions from the last 7 days
0
votes
0
answers
20
views
MAUI - Access XAML element from a different class code behind
I'm working on my first MAUI app. It consists of two screens, switchable via a tab control.
Now to my issue - I have page MainPage.xaml with MainPage.xaml.cs and also AboutPage.xaml with AboutPage....
0
votes
1
answer
46
views
C# Remove Both Duplicate Values from Custom Object Based On Multiple Positive/Negative Values
Working in C# with a custom object that has multiple rows and columns.
I need to remove duplicate records where some (but not all) of the column values match, including positive and negative values of ...
Best practices
1
vote
4
replies
47
views
How do I parse multipart content from an HttpResponseMessage?
I am using HttpClient in .NET 9 to get content that has a JSON part along with a base-64 encoded file. Reading the content as a string, I don't see a clear format that would ensure consistent parsing ...
0
votes
0
answers
13
views
AutoFixture Customization to Link Foreign Key Relationships
I'm writing some AutoFixture customization to make standing up our test database objects less verbose. It's been easy enough to omit included objects if they are referenced by a ForeignKeyAttribute. ...
-1
votes
0
answers
18
views
WPF Flyout Positioning Issue with FlowDirection="RightToLeft"
Problem Description
I'm developing a custom WPF Flyout component that uses Popup with CustomPopupPlacementCallback. The Flyout positions correctly when the Window has FlowDirection="LeftToRight&...
2
votes
1
answer
54
views
Casting Func<T1, T2> to Func<T1, object> doesn't work with double but works with classes [duplicate]
I have a simple question about covariance/contravariance here.
Below, I have a Func<T1, T2> that I need to be casted to Func<T1, object>.
In theory, this should be possible, but in ...
4
votes
0
answers
36
views
Word.Document Close ComException
We have some legacy code that late binds to Microsoft.Office.Interop.Word to do various things with documents.
This code has worked fine for years.
The Solution is written in VB.NET and consists of ...
Advice
0
votes
2
replies
34
views
How to obtain HTML DOM from markdown?
I have some markdown text.
I use MarkDig to parse the markdown text and obtain a markdown-document-object-model. (markdown-DOM.)
From that, I want to obtain an HTML-DOM.
As far as I can tell, the only ...
0
votes
2
answers
42
views
Why doesn't cookie authentication work in my Blazor .NET 8 app?
I've been having trouble trying to set up simple authentication/authorization for my web app. Currently I have auth page
@page "/auth"
@rendermode InteractiveServer
@using System.Text....
-1
votes
0
answers
34
views
FlowLayoutPanel not resizing according to content with Autosize set to true and FlowDirection to Topdown
I am using a FlowLayoutPanel in a Form in Microsoft Visual Studio Professional 2022. I have created the panel so its just last enough to show a single line. I have set the AutoSize property to True ...
0
votes
3
answers
62
views
Deserialization backward compatibility when type of property has changed
I used to have simple classes like below:
public class Product {
public Money Price {get; set;}
}
public class Money {
public decimal Amount {get; set;}
public CurrencyEnum Currency {get;set;...
0
votes
0
answers
28
views
Set dotnet version to use for debugging
Is there a way I can set the dotnet version to use for the debugger. I am using the one (debugger) that comes with C# Dev Kit. I currently have dotnet 8 and dotnet 2.2 installed but the debugger ...
0
votes
1
answer
39
views
Firebase version 3.4.0 not support GoogleCredential.FromFile("")
I’m using Firebase Admin .NET SDK v3.4.0 with .NET 8.
The methods GoogleCredential.FromFile(), FromJson(), and FromStream() are not available anymore in this version.
I need to load my Firebase ...
0
votes
1
answer
40
views
ASP.NET Core site can't find Default route on startup
I add a route named default with the pattern
{controller=Assets}/{action=Index}/{id?}
but I get an http 404 "Not Found" error.
If I type in /Assets in the browser, it finds the view, it's ...
3
votes
1
answer
70
views
Configure Visual Studio to decompile obfuscated code like Rider?
When navigating to the definition of something (e.g. with f12) of an obfuscated library in Rider, it will do its best to decompile the library. However, if I navigate to the same thing in Visual ...
2
votes
1
answer
35
views
Can't get TextBlock to fill the ComboBoxItem in Avalonia
The ItemTemplate for my ComboBox is like this:
new FuncDataTemplate(
typeof(object),
(item, _) => new TextBlock
{
HorizontalAlignment = HorizontalAlignment.Stretch,
Text ...
4
votes
3
answers
156
views
How to force the Application.Run to wait for all async void handlers?
I have a Windows Forms application and a Form with many async void event handlers. This form can be closed by the user at any moment. After closing the form I want to delete a temporary file, and my ...
0
votes
2
answers
66
views
Defining many-to-many with join table foreign key names without concrete c# domain table (shadow join)
I am trying to link a many-to-many relationship without any intermediary class in my domain.
The link is SoundProfiles <-> Switches. They're both not required. The error I get is
One or more ...
-3
votes
0
answers
40
views
Why the picturebox1 has tiled to 4 after changing the size and sizemode?
the size of the pictureBox1 was original size 512x512 but the images i display in the pictureBox1 size now is 940x940 so i changed two things.
the pictureBox1 size to 940x940 and the sizemode to zoom ...
-1
votes
0
answers
71
views
Implementing platform specific override method of custom client
I'm creating a custom API client to be used by my web (Blazor WebAssembly Standalone) and mobile (.NET MAUI) apps for connecting to my API. I have two questions below but first, here's an abbreviated ...
5
votes
2
answers
156
views
Is there a difference between the C# Volatile.ReadBarrier vs Volatile.Read?
In the released .NET 10 there is a new method added to the Volatile class with the name ReadBarrier().
And I don't know whether from the compilers perspective there is a difference if I do a read with ...
1
vote
0
answers
30
views
appsettings.json not read after deploying to Minikube (values become empty, DB connection fails)
I'm running an ASP.NET Core application.
Everything works correctly when using Docker Compose — all values from appsettings.json load normally, and my services connect to Postgres and RabbitMQ.
But ...
-1
votes
0
answers
61
views
Datagridview does not show any data
I have a datagridview in my Winforms app. I set the columns manually in designer and then try to fill it by a function. I check the function step by step and in the last line of code datasource dt has ...
0
votes
0
answers
21
views
Conflicting assets with the same target path in ASP.NET Core 10 static web asset compression
The error occurs between two projects (PortalAdmin and Portal) that both contain the same static web asset. This appears to be related to the new static web asset compression feature in .NET 10.
What'...
0
votes
0
answers
26
views
Class resets to null after login in MudBlazor because page reloads – how can I persist the user until he logs out?
I have a MudBlazor application where I use a custom CurrentUserService to store the currently logged-in user so I can display the user's profile image in the layout.
This state is not part of the ...
-4
votes
0
answers
44
views
Make COM Server (Widget provider) ready for AOT [closed]
I have couple of windows 11 widgets. Implemented with the sample provided by microsoft which isn't AOT compatible. I found this question / awnser which looks very useful
How to rewrite the Windows App ...
Best practices
1
vote
3
replies
94
views
How to make C# code more readable and maintainable when using Dapper and raw SQL queries in C#?
When we are using Dapper, we should use raw SQL queries within our code, and if the query is complex with multiple joins and windowed query, it is very difficult to maintain such code.
Putting all ...
1
vote
1
answer
52
views
Could not load type 'Microsoft.AspNetCore.Http.Metadata.IApiEndpointMetadata'
After upgrading from .NET 9 to .NET 10 (.NET vesion and packages like OpenApi), I started getting this exception:
Application startup exception
System.TypeLoadException: Could not load type '...
0
votes
0
answers
28
views
Release mode for a NET9 MAUI failed to find entry classes.dex
I have my application written with NET9 MAUI. I use Visual Studio 2026. The application is working in debug. When I deploy in Release, the application crashes immediately. The error log is quite long, ...
0
votes
0
answers
36
views
Title: Fixing Shaking and Jumping in Custom LoopPanel with Inertia Scrolling and Snap-to-Item
I have a custom LoopPanel in WinUI, and I’m trying to implement inertia smooth scrolling and a snap-to-item feature.
I implemented both features, but I’m seeing some weird behavior: the panel shakes ...
-2
votes
1
answer
90
views
Why C# program (MySQL Connector/NET, .NET 8.0) compile on command prompt with csc, but not in Visual Studio 2022?
I am a novice programmer. I want to work in my 'Windows 10' with MySQL Community Server 8.4 from a C# program (platform .NET 8.0). I am using the Visual Studio Community 2022. I also use MySQL ...
2
votes
1
answer
39
views
Validator access to database
My question is how do I need to validate fields. I have this class (request dto):
public class CompleteGoogleRegistrationRequest
{
public string IdToken { get; set; } = string.Empty;
public ...
0
votes
0
answers
27
views
Deep linking in NET9 MAUI
In my NET9 MAUI application, I try to implement the deeplink following the Microsoft documentation. When I send a request, it gets to the OnCreate in the MainActivity.
[Activity(Theme = "@style/...
1
vote
0
answers
45
views
I start integration tests with `dotnet test`. They spawn IIS Express which fails ONLY on CI pipeline if I require code coverage
The test with coverage runs perfectly well locally:
C:\xyz\DevOps\xyz.DependencyInjection [master ≡]> dotnet test -c:Release --no-build -f net9.0 --filter "FullyQualifiedName~Tests....
1
vote
1
answer
72
views
Highlighting the datagridview rows
I have a datagridview in my Winforms app with .NET 8. I want to highlight some rows based on the current user role and the request nextlevel. I write this function and call it in form load.
But at the ...
0
votes
0
answers
29
views
DinkToPdf / wkhtmltopdf prints only 19 pages even with 64-bit DLL
I am generating a PDF in ASP.NET Core using DinkToPdf (wkhtmltopdf wrapper).
My HTML report is around 20+ pages, but the generated PDF always stops at 19 pages. It never prints the full content.
PDF ...
-1
votes
0
answers
27
views
How to detect if an executable is Chromium or Firefox based [closed]
I'm working on a desktop application that asks users to choose a browser executable to open websites. I want to launch the browser with different arguments based on whether it's Firefox or Chromium ...
0
votes
2
answers
47
views
How to enumerate MMDevice devices that are USB
There are well documentated ways to enumerate MMDevice audio devices such as:
How do you programatically get a list of a computer's recording devices?
Does anyone know a way to tell if a devce is USB ...
4
votes
1
answer
82
views
Cannot declare instance members in an extension block with an unnamed receiver parameter
I am trying to declare an extension property for the int type in C# 14:
extension(int)
{
public int MyProperty => 13;
}
I am getting this compilation error:
'MyProperty': cannot declare ...
1
vote
0
answers
59
views
C# Multithreading Issue with Simultaneous Smart Card Printing on Multiple Evolis Primacy 2 Printers
I'm developing a C# application that needs to handle simultaneous printing on 4 Evolis Primacy 2 printers with Elyctis encoders. Each printer must write to card chips and print on cards completely ...
-3
votes
0
answers
49
views
Does the Composite design pattern allow the Component class to inherit from another abstract base class? [closed]
Does the Composite pattern require the Component class to be the root of the inheritance hierarchy?
Or is it acceptable for Component to inherit from another abstract class (e.g., a base entity with ...
Advice
0
votes
1
replies
63
views
How to effectively use ASP.NET core Hybrid Cache with Result<T> type
Suppose a scenario where:
you need to execute an expensive operation which can fail or succeed.
the result of the operation is modeled by using a result object Result<T>. The result object ...
5
votes
1
answer
151
views
.NET 9 -> .NET 10: MongoDB query using array.Contains throws NotSupportedException
After upgrading from .NET 9 to .NET 10, a MongoDB query that used to work now throws a System.NotSupportedException during query execution. I'm looking for pointers whether this is a runtime change in ...
0
votes
0
answers
17
views
How to intercept keys not defined in VSStd2K, such as Shift+Tab?
I attempted to intercept key combinations using IOleCommandTarget for commands within VSConstants.VSStd2KCmdID.
I tried BACKTAB, but it doesn't work, even though TAB can be intercepted. I suspect that ...
0
votes
1
answer
33
views
How to configure multiple security schemes in ASP.NET Core Swagger with NSwag API spec
I have an ASP.NET Core 8 Web API with a Swagger page using Nswag + OpenAPI3. I also have an OAuth2 security implementation which is working great. Thanks to AspNetCoreOperationSecurityScopeProcessor ...
0
votes
0
answers
82
views
Entity Framework Core queries in an ASP.NET Core application targeting an Azure SQL database are running with wildly different runtimes
I have a web app using code-first EF Core.
One of the controllers needs to run what should be a simple query (basically SELECT TOP 1 * FROM companies WHERE id = @id; in EF terms,
var data = await ...
0
votes
0
answers
19
views
How do I get nested Hot Chocolate graphql data loaders to batch properly?
I have a graphQL query that looks like this:
query {
vehiclesByIds(ids: 1,2,3,4,5...) {
id
options {
optionId
name
adCopy {
copyType
copyText
}
}
...
1
vote
1
answer
77
views
Unable to create a 'DbContext' of type 'AppDbContext'. The exception 'Object reference not set to an instance of an object.' was thrown
I'm getting this error :
Unable to create a 'DbContext' of type 'AppDbContext'. The exception 'Object reference not set to an instance of an object.' was thrown while attempting to create an instance....
-2
votes
1
answer
79
views
Should one service call another service or use the repository directly? [closed]
I'm learning Clean Architecture and I can't figure this out.
Imagine this scenario: I have a ServiceA that calls its repository:
public class ServiceA : IServiceA
{
private readonly IRepositoryA ...
0
votes
0
answers
28
views
Fail to Run OnnxRuntime Session in C# with CUDA Device
I created a YOLO v11 DL model using a given dataset and both the train and prediction modules work fine in PyCharm.
However, after exporting the model file to ONNX format and running the prediction ...