95 questions from the last 30 days
12
votes
4
answers
3k
views
installing dotnet-ef dotnet tool throws error
I’m trying to install the Entity Framework Core CLI tools globally using the .NET CLI command:
dotnet tool install --global dotnet-ef
However, the installation fails with the following error message:
...
0
votes
1
answer
208
views
What’s the most efficient way to map large entity models to DTOs in ASP.NET Core without using AutoMapper? [closed]
I'm working on a high-performance ASP.NET Core Web API where each request can return hundreds of entity records. Each entity includes multiple navigation properties and nested objects.
Currently, I’m ...
Best practices
3
votes
3
replies
87
views
C# CancellationToken across chain of api calls
I have the following application architecture:
FrontEnd → ApiServer 1 → ApiServer 2 → Database
So, the frontend calls a web server, which calls multiple API which make query on database.
What is the ...
0
votes
1
answer
127
views
SQL CLR function bad performance comparing to .NET App
In our system we are hashing passwords with the following method.
public static string HashPassword(string password, byte[] salt)
{
if (salt == null)
{
throw new ArgumentNullException($...
Best practices
2
votes
2
replies
65
views
Should using TransactionScope be inside a try..catch or the other way around?
I am pondering whether the using TransactionScope should be within a try..catch or the other way around.
Within try..catch
try
{
using (var scope = new TransactionScope())
{
...
Best practices
0
votes
3
replies
64
views
Can a Composite Component class inherit from another abstract base class without breaking the Composite pattern?
I’m studying and implementing the Composite design pattern in C# for a university project.
In most textbook examples (GoF, Refactoring.Guru, etc.) the class hierarchy looks like this:
Component
├── ...
2
votes
1
answer
146
views
How do I use .NET reflection to emit generic interfaces and a class which implements them
I am trying to use .NET reflection to emit a class and some interfaces which the class implements. However, I cannot seem to correctly implement the interfaces that are generic, as that results in ...
4
votes
1
answer
92
views
Deserialization of XML with multiple namespaces
I'm attempting to deserialize an XML response from an API. The data is as follows (I have only included a small chunk for the sake of a small post):
<ns1:alerts xmlns:ns1="http://gov.fema....
Best practices
1
vote
5
replies
82
views
Handling mutable models in MVVM
In an MVVM architecture, models should be kept free of UI-related logic. They represent pure data that is retrieved from memory via a service. I see a challenge when the user interface needs to ...
0
votes
1
answer
126
views
Deserializing array of objects to concrete .NET types using Newtonsoft
I have a couple of classes (simplified):
internal class OrderItem
{
public string Name { get; set; }
public Order Order { get; set; }
}
internal class Order
{
public IReadOnlyList<...
2
votes
0
answers
139
views
C# .net cannot run in VS code
I use VS code (not VS cause i have linux) and have been trying to run my c# template from run and debug in VS code but it does not works and returns this error in output.
-----------------------------...
0
votes
1
answer
164
views
How to set window position on different monitor from main window
It's no problem to set the position of the new WinForm inside the monitor where the main window is displayed. For example:
Form1 form = new Form1();
form.Show();
form.StartPosition = FormStartPosition....
0
votes
1
answer
70
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 ...
1
vote
2
answers
87
views
Problem with Content-Type in a (.net) StringContent
I have a request (going to an APIM endpoint.) From Postman the test runs just fine, but from my code it fails with a 400. I looked at the requests in fiddler and the only difference is this:
// This ...
2
votes
0
answers
108
views
How can I create and use a custom shared framework with <FrameworkReference> in .NET?
I’m exploring how .NET shared frameworks work (for example, Microsoft.NETCore.App and Microsoft.AspNetCore.App) and I’m wondering if it’s possible to define and use a custom shared framework that can ...
-1
votes
0
answers
84
views
How does the CLR implement static fields in generic types? [duplicate]
This question has been bouncing around my head for a few years and I wanted to finally ask it.
The question is: how does the CLR implement static fields in generic types? Under the hood, where are ...
0
votes
2
answers
60
views
C# project with a package reference to a nuget with an exe assembly
I know that in the early times of .NET Framework, you could build an assembly into EXE and then use that "EXE assembly" as a dependency of another .NET Framework assembly which, too, could ...
0
votes
1
answer
41
views
VSPackage fibers stack tracing
I am trying to display the stack traces of RTOS fibers running in a C++ solution in VS2022. Since upgrading to Windows 11 there seems to be a problem in the implementation. The existing approach, ...
0
votes
0
answers
67
views
Finding a variable based on attribute value [duplicate]
Hi Ive run into an issue i have an object in c# and in that attribute i have added a number field ( something that should in the code be unique for each value such as )
public class ...
Best practices
0
votes
3
replies
64
views
Is there anyway to get physical disk Idle time without 1 second wait needed for PerformanceCounter.NextValue function?
I trying to develop user-friendly program that do not block physical disk with 100% usage (so even entering My Computer takes around 10 seconds).
My program calculate hash for many (180k) small files ...
-1
votes
0
answers
87
views
How to detect the current user session in Intune deployment?
I have a C# installer app that needs to identify which user session to target. The application fails to identify the correct user when deployed via Microsoft Intune.
For example, when deployed via ...
1
vote
1
answer
32
views
Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken throws exception
I'm trying to get a hardware id with a .net console app (target framewotk is net8.0-windows10.0.17763.0).
The code is rather trivial, just
var token = Windows.System.Profile.HardwareIdentification....
-1
votes
0
answers
56
views
VS Code fails to run .NET, even if I installed it
When I open a workspace in VS Code, I get this error message notification on the bottom right corner :
Failed to run .NET runtime. You may be missing key Linux libraries. Install them now?
Source: ....
1
vote
1
answer
80
views
Preventing timeout when debugging (stepping through the code) in .NET Azure Function apps
I have a number of HTTP triggered Azure Function apps that do not time out when in production. However, when I want to debug them by stepping through the code (in Visual Studio 2022), slowly and ...
2
votes
2
answers
84
views
How to globally override the default value of a property in Avalonia?
I'm trying to override the default value of ToolTip.ShowOnDisabledProperty to be true for all controls.
I've tried the following:
static App()
{
ToolTip.ShowOnDisabledProperty.OverrideDefaultValue&...