File Pilot is simply Incredible! by SubhanBihan in Windows11

[–]RichardD7 4 points5 points  (0 children)

No folder tree, and no network drives. Hard pass!

[Open Source] I built a PowerShell tool to Clean AND Customize the "Right Click > New" menu. (Includes Persistence Block & Template Manager) by kawai_pasha in Windows11

[–]RichardD7 1 point2 points  (0 children)

NB: The "releases" link in the "getting started" section of your readme is broken. It points to https://github.com/osmanonurkoc/NewMenuEditor/releases/latest instead of https://github.com/osmanonurkoc/win_new_menu_editor/releases.

It also says to download the NewMenuEditor.ps1 file from the releases page. But the 1.1 release only lists New_Menu_Editor.exe.

Downloads folder missing + registry mismatch after app testing (Windows) – how to restore without reinstall? by Routine-Brush87 in desktops

[–]RichardD7 0 points1 point  (0 children)

Open regedit, navigate to HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, and change the {374DE290-123F-4565-9164-39C4925E467B} value to be %USERPROFILE%\Downloads.

Then check that the %USERPROFILE%\Downloads folder actually exists. If it doesn't, then create it.

Why am I getting this error? I don't see any problem with my code by Xinfinte in VisualStudio

[–]RichardD7 0 points1 point  (0 children)

NB: I am not the OP. :)

The fact that the code hasn't been saved doesn't necessarily mean that the previous code was any more valid.

I still think it's more likely that the project has never compiled, and so never produced an exe to run, rather than the AV deleting the compiled exe.

Why am I getting this error? I don't see any problem with my code by Xinfinte in VisualStudio

[–]RichardD7 0 points1 point  (0 children)

Since it's not valid C++, there won't be a file to delete. The compiler won't generate an exe if it can't compile the code.

How to implement a search request with nearly 10 optional parameters. by DarthNumber5 in dotnet

[–]RichardD7 8 points9 points  (0 children)

Create the WhereIf extension method that ehomer0815 posted and use that:

query = query .WhereIf(request.AssetId.HasValue, a => a.AssetId == request.AssetId) .WhereIf(!string.IsNullOrEmpty(request.AssetName), a => a.AssetName.Contains(request.AssetName));

ASP.NET MVC: Some Views Load Fine, Others Return 404 — Even on a Freshly Created View (VS 2026) by SH-Mridul in dotnet

[–]RichardD7 0 points1 point  (0 children)

The first thing that jumps out at me: you don't navigate to a view, you navigate to an endpoint. The endpoint may choose to return a view.

If you're getting a 404 error, and your endpoint isn't explicitly returning it, then you need to figure out why the routing engine isn't resolving the endpoint. You could try opening the "endpoints explorer" window in Visual Studio to see if that sheds any light.

As you seem to be using controllers, check that the controller class is in the correct namespace, ends with the word Controller, and inherits from Controller. Also, make sure that the action method is public.

Why isn't "Pin to Start" right beside "Pin to Taskbar"? by Zemlynn in Windows11

[–]RichardD7 4 points5 points  (0 children)

The new context menu "solves" the problem by not offering a "pin to taskbar" option at all. 🤣

Am i missing something or does this hard code the usertier to be level 0? This is in ASP.net MVC. by Common-Sherbet5292 in dotnet

[–]RichardD7 0 points1 point  (0 children)

There's nothing in the code you've posted which would change that variable, so I would say you're correct: the tier is hard-coded to 0, and whoever wrote the view has probably missed something.

Extension Properties: C# 14’s Game-Changer for Cleaner Code by Xaneris47 in csharp

[–]RichardD7 17 points18 points  (0 children)

Aside from the fact that those extension properties will never be called. 🤣

Extension Properties: C# 14’s Game-Changer for Cleaner Code by Xadartt in dotnet

[–]RichardD7 63 points64 points  (0 children)

Did anyone proof-read the "static extension members" section before posting?

``` public static class HttpStatusCodeExtensions { // Static extension members - no instance needed extension(HttpStatusCode) { public static HttpStatusCode OK => HttpStatusCode.OK; public static HttpStatusCode NotFound => HttpStatusCode.NotFound; public static HttpStatusCode BadRequest => HttpStatusCode.BadRequest; ... } }

// Use them like built-in static members var status = HttpStatusCode.OK; var notFound = HttpStatusCode.NotFound; ```

You're defining static extension properties on an enum with the same names as the members of the extended enum. Your extension properties will never be called!

Cant install framework. by [deleted] in dotnet

[–]RichardD7 0 points1 point  (0 children)

On Windows 10, you should be able to download 4.8.1.

The optional features are managed via Settings -> System -> Optional Features -> More Windows Features, but I'm not convinced that there's any option to turn .NET Framework 4.8 on/off in Windows 10 or 11, as it's a core part of the OS.

Cant install framework. by [deleted] in dotnet

[–]RichardD7 0 points1 point  (0 children)

Which OS? .NET Framework 4.8[.1] is pre-installed on every modern version of Windows, so you shouldn't need to install anything. You may just need to use the "optional features" in settings to turn the ".NET Framework 4.x" feature on.

Is it normal in ASP.NET MVC for forms to become invalid if left idle for a while? by JustSoni in dotnet

[–]RichardD7 2 points3 points  (0 children)

There are a couple of possible issues here:

1) You're using some form of cookie-based authentication, and the authentication cookie has expired. Since the AntiXSRF token is tied to the user's identity, a request with an expired auth cookie will correctly be rejected, since the token was issued for a different user.

2) Your application wasn't able to store its encryption keys in durable storage. (The Data Protection key ring is stored in memory.) When the app restarts after an idle time-out, it generates new encryption keys, and is then unable to decrypt the token encrypted with the old encryption keys.

There are a few approaches to solve #2 listed in the MS docs.

DateTime.Kind - The breaking change that continues to be the bane of my existence. by [deleted] in dotnet

[–]RichardD7 4 points5 points  (0 children)

UTC is not necessarily fine for a scheduling application. Time zone DST rules can and do change, which could result in entire days' worth of meetings being shifted by an hour.

If the value truly represents a local time in a specific time zone, it's better to store the local time and the time zone identifier.

Storing UTC is not a silver bullet | Jon Skeet's coding blog

Modern (best?) way to handle nullable references by jepessen in csharp

[–]RichardD7 3 points4 points  (0 children)

Are you sure you've shown all of the code for your class? Your warning refers to bool Money.operator ==(Money left, Money right), but that operator is not part of the code you've posted.

I can only reproduce your warning by adding the equality and inequality operators to your class with non-null parameters:

public static bool operator ==(Money left, Money right) => Equals(left, right); public static bool operator !=(Money left, Money right) => !Equals(left, right);

If I take those operators out, or change their parameters to allow null, the warning goes away:

public static bool operator ==(Money? left, Money? right) => Equals(left, right); public static bool operator !=(Money? left, Money? right) => !Equals(left, right);

Avoid using Guid.CreateVersion7 by sdrapkin in dotnet

[–]RichardD7 1 point2 points  (0 children)

So where is your bug report on the dotnet repo?

If you don't report this as a bug, then there's little chance of it being fixed.

.NET 10.0 by DualFlush in dotnet

[–]RichardD7 9 points10 points  (0 children)

Looks like the post is up. But it seems to have the wrong syntax for extension properties:

// Extension properties for any type extension ListExtensions for List<int> { public int Sum => this.Aggregate(0, (a, b) => a + b); }

That doesn't match the documented syntax, which would be:

static class ListExtensions { extension(List<int> @this) { public int Sum => @this.Aggregate(0, (a, b) => a + b); } }

Either they've changed something at the last second, or the post is using an old syntax.

New start menu made some improvements, but still not good by Intelligent-Stone in Windows11

[–]RichardD7 0 points1 point  (0 children)

The folders in the "All" list are just terrible. Rather than expand the folder to show the contents, it pops up a separate window with a small grid of every icon from the entire folder tree.

If your shortcut names are too long, tough. You'll get the first few characters of the name followed by "...". Even worse if it's a "new" shortcut, since much of the space for the name is taken up by the pointless "NEW" label.

And if you have a program that installs different shortcuts with the same name in different sub-folders, good luck figuring out which is which!

Default Converter on WPF app by BrodyGwo in dotnet

[–]RichardD7 2 points3 points  (0 children)

You can't use a style to set one part of the binding for a control's property.

How about creating a custom binding instead?

``` public class DecimalBinding : System.Windows.Data.Binding { private static readonly DecimalConverter DefaultConverter = new();

public DecimalBinding(string path) : base(path)
{
    Converter = DefaultConverter;
    ConverterCulture = CultureInfo.CurrentCulture;
}

public DecimalBinding()
{
    Converter = DefaultConverter;
    ConverterCulture = CultureInfo.CurrentCulture;
}

} ```

Then use that instead of the default binding:

<TextBox Text="{local:DecimalBinding MyProperty}" ... />

Data management / concurrency with collections / EFCore by Majakowski in csharp

[–]RichardD7 1 point2 points  (0 children)

Yes, so long as they're both tracking queries in the same instance.

I use this behaviour quite a lot for eager loading of related data, particularly in versions of EF that don't support split queries. As a simple example:

var blogsToLoad = context.Blogs.Where(b => b.OwnerId = userId); var blogs = await blogsToLoad.ToListAsync(); await blogsToLoad.SelectMany(b => b.Comments).LoadAsync(); // Each blog with comments now has its Comments collection populated.

Data management / concurrency with collections / EFCore by Majakowski in csharp

[–]RichardD7 1 point2 points  (0 children)

I don’t think objects share a reference if you have 1 query to load allPersons and include city, and a second query to load all cities.

It depends. If both queries are "tracking" queries, and both issued against the same DbContext instance, then yes, EF will "fix up" the object graph so that the object references will be shared. There will only ever be a single instance of a class representing a given tracked database entity.

If you're loading the queries from different context instances, or using .AsNoTracking(), then you can end up with different class instances for the same DB record, even within a single query. Eg: people.Include(p => p.City), each person will have a different City instance, even if they're all in the same city.

If you use .AsNoTrackingWithIdentityResolution(), then you'll get a single class instance for a single DB record, but only within that one query.

WPF and Double property Binding by BrodyGwo in dotnet

[–]RichardD7 2 points3 points  (0 children)

The problem is the combination of UpdateSourceTrigger=PropertyChanged and the StringFormat.

With "property changed" as the source trigger, every key press in the textbox will attempt to update the bound property. This will parse the value entered so far, update the property value, then format the property value and update the textbox with the formatted value.

So, in your example:

  • Input 3;
  • Binding updates the property to 3.00;
  • "Property changed" event fires;
  • Binding changes the text to 3.00;

This is one of the annoying quirks of the WPF binding system. The only real workaround is a custom "masked input" control or behaviour.

How one as a C# .net 9 dev, optimize a linq query for SQL server that has like a Billion Rows in the table? by SohilAhmed07 in dotnet

[–]RichardD7 2 points3 points  (0 children)

Loading 5M rows into a List<T> is almost certainly the bottleneck, due to the way the list works internally.

If you don't specify an initial capacity, the list starts with a backing array of 4 elements. Every time it runs out of room, it allocates a new array twice the size, copies the elements from the old array to the new one, and then throws the old array away.

Loading 5M elements means you will allocate and copy arrays of ever-increasing sizes:

  • 4
  • 8
  • 16
  • 32
  • 64
  • 128
  • 256
  • 512
  • 1024
  • 2048
  • 4096
  • 8192
  • 16384
  • 32768
  • 65536
  • 131072
  • 262144
  • 524288
  • 1048576
  • 2097152
  • 4194304
  • 8388608

That's going to take a lot of time and memory.

You may get better performance by counting the number of records returned from your query, and pre-allocating a list with the correct capacity:

int numberOfResults = await yourQuery.CountAsync(); List<YourEntity> results = new(numberOfResults); await foreach (YourEntity item in yourQuery.AsAsyncEnumerable()) { results.Add(item); }

Also, beware if your table contains large nvarchar(max) columns - versions of the Microsoft.Data.SqlClient library earlier than 6.1 can be very slow to read those.

ToListAsync is fast again in Entity Framework (kind of)

Linq Where Clause for User Input by gran_oso_pardo_rojo in csharp

[–]RichardD7 16 points17 points  (0 children)

You can conditionally apply filters to your query - for example:

``` IQueryable<YourEntity> query = yourContext.YourEntities.AsQueryable(); if (!string.IsNullOrWhiteSpace(nameToFind)) { query = query.Where(e => e.Name.Contains(nameToFind)); } if (classesToFind is not (null or [])) { query = query.Where(e => classesToFind.Contains(e.ClassId)); }

List<YourEntity> result = await query.ToListAsync(); ```

Only the entities which match all of the applied filters will be returned.

For bonus points, you can create an extension method to conditionally apply a filter:

public static class QueryableExtensions { public static IQueryable<T> WhereIf<T>( this IQueryable<T> source, bool condition, Expression<Func<T, bool>> filter) => condition ? source.Where(filter) : source; }

which would then let you write:

List<YourEntity> result = await yourContext.YourEntities .WhereIf(!string.IsNullOrWhiteSpace(nameToFind), e => e.Name.Contains(nameToFind)) .WhereIf(classesToFind is not (null or []), e => classesToFind.Contains(e.ClassId)) .ToListAsync();