IndexOutOfRangeException but error occurs only for "release x64 and .NET 7"

Joseph Stateson 46 Reputation points
2023-08-01T16:56:49.73+00:00

Unaccountably, I get the following event viewer error running a build for release x64 and dotnet 7 target os8. All builds compile correctly just that x64 release fails to run. My app works fine if I build it for AnyCPU or x86 both debug and release. It also runs fine in debug mode x64. Just fails immediately in Release 64. Switching to dotnet 6 solves all the problems.

Error message

Exception Info: System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at PDF_PhraseFinder.PhraseFinderForm.FillPhrases() in C:\Users\josep\source\repos\PDF-PhraseFinder\PhraseFinderForm.cs:line 508

The line of code that triggered the problem simply clears out a list. Any out of bound indexing seems to be in the dotnet module that handles the list "clear()"

User's image

In Application "General" I can select .dotnet 5,6,7 or cores 3 or 3.1 and also the OS target.

To make my app work I need to select NET6. I changed the OS to 8 as trying any OS 10 or above gives me a Win 10 SDK missing error. AFAICT all my SDKs were downloaded by the VS 2022 community installer.

I have the following questions as I am not familiar with dotnet differences and OS targeting.

I am targeting OS 10 and 11. What dotnet should I used?

Why is the SDK for 10 missing? No matter if I pick the first release of 10 or the latest I get the SDK missing error. All build for OS 8 run fine on windows 11 and I can use that.

Thank you for looking.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,010 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Joseph Stateson 46 Reputation points
    2023-08-05T00:51:21.7533333+00:00

    closing the indexing problem as I cannot reproduce it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.