Skip to content

.NET not properly shut down when using a mixed-mode assembly in a native process #72610

@IRebo

Description

@IRebo

Im trying to migrate a big native application which uses mixed-mode libraries. After the migration to .net6 im running into an issue that when closing the process the C++ global objects are not properly destroyed.

The main .exe is an older MFC native executable which loads and uses mixed-mode dlls.

In .net framework when process if ending it normally calls CorExitProcess which causes the app-domain to unload and all the mixed-mode modules get uninitialized which includes destroying any static/global objects in C++ mixed-mode library.

In .net6 i see that the module subscribes to the domain unload but the event never occurs.

Is this intentional behaviour for .net6 ? Is there some way I can unload the domain from native code when the process is finishing to simulate the old behaviour ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Interop-coreclrquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions