Questions tagged [.net-7.0]

Use this tag for questions specifically related to version 7.0 of the .NET platform. For questions on .NET Framework generally, use the .net tag.

1169 questions
7
votes
1 answer

How to generate constant values with generic math

I have the following generic math function: private static T Fade(T t) where T : IFloatingPoint { return t * t * t * (t * (t * 6 - 15) + 10); } This doesn't compile however, since 6, 15 and 10 are not of type T. The best solution I…
Rick de Water
  • 2,388
  • 3
  • 19
  • 37
7
votes
2 answers

OutputCache attribute not working on .NET 7 API endpoint

I have an API REST .NET 7 and the attribute [OutputCache] is not caching even in a endpoint without authorization I added this: services.AddOutputCache(options => { options.AddBasePolicy(builder => builder.Cache()); //removing this line…
7
votes
2 answers

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Options'

I've been getting this error message when I try to run my Azure function v4. System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Extensions.Options, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The…
Thusitha
  • 165
  • 1
  • 12
7
votes
1 answer

Creating Azure Functions Targeting .NET 7

I don’t see .NET 7 Isolated as an option when I try to create a new Azure Functions app in Visual Studio 17.4 (Windows version). Any idea why?
Sam
  • 26,817
  • 58
  • 206
  • 383
6
votes
1 answer

Why does C# allow the usage of the + operator in generic classes with constrain INumber while VB.NET doesn't?

First up, I am currently working with VB.NET and therefore not really knowledgeable in C#. I wanted to create a custom generic Vector class with the constrain, that the type parameter must implement the interface INumber(Of T). However, when I tried…
6
votes
1 answer

Dictionary seems to keep inserted order

I’ve always assumed that a Dictionary does not preserve the order of which items are added. Then why does this always seem to be true? internal class Program { public static void Main() { var d = new Dictionary(); …
Magnus
  • 45,362
  • 8
  • 80
  • 118
6
votes
1 answer

dotnet run hangs / is stuck

A razor webapp can no longer be started on my machine. The build command dotnet build works as expected but dotnet run is stuck after the first warnings. C:\dev\mywebapp>dotnet…
surfmuggle
  • 5,527
  • 7
  • 48
  • 77
6
votes
1 answer

BackgroundService Await Task.Delay in infinite loop leaks SqlConnection objects hard

I have code similar to this running in multiple BackgroundServices (.NET 7). After just a few days of runtime (obviously, delay is in minutes (to hours) between loops) leads to a massive Memory Leak in tens of thousands of dangling SqlConnection…
CodeAngry
  • 12,760
  • 3
  • 50
  • 57
5
votes
3 answers

Ubuntu .Net 7 Install Can't Find SDK

I am running Ubuntu 22.04 and trying to install .NET 7.0.5 I have tried multiple different methods of installing .NET 7, none of them seem to allow me to use the dotnet build or dotnet publish command. It appears to be some kind of issue with Ubuntu…
Scottish Smile
  • 455
  • 7
  • 22
5
votes
3 answers

My legacy code on net core 3.1 is throwing exception when moving to .NET 7 with message "Nullable object must have a value"

My code is below, working fine in .NET Core 3.1: // dto is search criteria passing from outside var query = from p in dbContext.Products.Where(p => dto.Ids.Contains(p.Id)) from c in dbContext.Categorys.Where(c => c.Id ==…
Dan Van
  • 55
  • 4
5
votes
1 answer

Is it possible to auto-implement IEquatable and IComparable in C# 11?

When writing C#, I tend to write a lot of value type objects that implement IEquatable, IComparable, or both. For the sake of this proposal, let's assume that I'm writing a fictitious struct called Int256 with equatable and comparable value…
Matthew Layton
  • 39,871
  • 52
  • 185
  • 313
5
votes
1 answer

.NET Core Publish Task Slow after upgrading blazor project to .Net 7

Azure Pipeline '.Net Core Publish' task too slow after upgrading the project to Dot Net 7. It just took less than 8 min before, using Dot Net6. After the upgrade to dot net 7 it takes more than 50 min and most of the times it fails if it doesnt…
5
votes
1 answer

Generic math how to cast from INumber to a "concrete" type (int/double/etc)

Suppose we have a generic method which accepts INumber and returns int: // process val and return as int static int DoSomething(T val) where T : INumber => ... How can the T be casted to int.
Guru Stron
  • 102,774
  • 10
  • 95
  • 132
5
votes
1 answer

Can I force Entity Framework Core 7 to not make ICollections read-only?

Entity Framework Core 7 introduced a breaking change (although it is not listed in the breaking changes for EF Core 7): when defining model classes with scaffolding (Scaffold-DbContext), EF Core 7 now makes the ICollection properties read-only. EF 6…
5
votes
1 answer

How to detect globalization-invariant mode

.NET Core/6/7 supports a globalization-invariant mode which alters the behavior regarding globalization in many ways. How can a library detect if it is running in this mode and adjust its behaviour accordingly? The only solution I came up so far is…
Klaus Gütter
  • 11,151
  • 6
  • 31
  • 36
1
2
3
77 78