Can't build in release mode, only debug mode

SpectraCoder 141 Reputation points
2021-06-16T18:26:31.05+00:00

I've got a weird issue with Visual Studio 2019.
For some reason building my app in Release mode doesn't work. It shortly shows the app's splash screen, and then Visual Studio gives this error:

Unhandled exception at 0x00007FF917E94B89 (KernelBase.dll) in [appname].exe: 0xE0434352 (parameters: 0xFFFFFFFF80070002, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x00007FF904910000).

Followed by this error dialog, if I press the continue button:

An issue in the [appname].exe process caused it to fail to activate. This process threw one or more exceptions.

Use Debug->Windows->Exception Settings to configure the debugger to stop when these exceptions are thrown. More information can be found in the Debug pane of the Output Window (Debug->Windows->Output).

The weird thing is, building in Debug mode works fine, and building and deploying to the Microsoft Store is also without problems.

I've cleaned the obj and bin folders, updated Visual Studio and all used nuget packages, reinstalled Visual Studio... Any clues?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,142 questions
{count} votes

2 answers

Sort by: Most helpful
  1. AddWebSolution 171 Reputation points
    2021-06-18T05:28:26.48+00:00

    From your error I can guess that you're using an external library, either through NuGet or locally.
    You have to set up the environment to use this library in both release and debug mode. That means installing it on either one through NuGet or setting up the correct include/library paths in the project settings.

    0 comments No comments

  2. Tianyu Sun-MSFT 30,821 Reputation points Microsoft Vendor
    2021-06-22T07:50:17.12+00:00

    Hello @SpectraCoder ,

    Thanks for your reply.

    “Compile with .NET Native tool chain” is unchecked for Debug, and checked for Release. If I uncheck it for Release, it builds fine.

    The “Compile with .NET Native tool chain” option will be checked by default, if you uncheck it, the build will be more like build under “Debug”.

    Is it okay to leave it unchecked? It’s an UWP app by the way.

    Actually this option/feature is related to UWP app, you provided the key information. Please refer to this document: Getting Started with .NET Native, I think the issue may be caused by one certain lib, or project doesn’t support Release mode and so on, but these are specific environment/project related, so you need to refer to the document and check your project to find out the real cause.

    Hope this helps.

    Best Regards,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    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.