Skip to content

Application crash when using empty statement (semicolon) in Startup.cs #6409

Closed
@leonkleiboerstrukton

Description

@leonkleiboerstrukton

Description

I was trying to make an API in Visual Studio, using net 5.0.7 and the APS.NET Core Web API template.
My application keeps crashing, before even hitting the first line of code in Program.cs In the output window, the only information shown was:

'xxx.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.7\System.Runtime.dll'.
The program '[0x254C] xxx.exe: Program Trace' has exited with code 0 (0x0).
The program '[0x254C] xxx.exe' has exited with code 0 (0x0).

I couldn't figure out was wrong, so I started from scratch to pin point the issue. Turns out that I had a semicolon in Startup.cs after my usings like this:

using System;
using System.IO.Compression;
using System.Runtime.InteropServices;
;

When removing the semicolon on the last line, the application worked as expected.
I know I have a compiler warning, 'Remove this empty statement', and I know I should have solved it, but I didn't expect the application to crash like this. IMHO, the compiler should have raised an error, or the application should have raised a nice descriptive exception message.

Configuration

Tested in on Windows 10 and on Fedora Linux 33, in both cases with the same result.

Regression?

Do not know, tested it with net 5.0.5 as well on Windows, same result.

Other information

none

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions