C++/CLI __declspec(appdomain) static variables cause a C++/CLI binary to fail to load. #110365
Labels
area-AssemblyLoader-coreclr
in-pr
There is an active PR which will close this issue when it is merged
Milestone
Description
If a C++/CLI dll has a global variable that is marked with __declspec(appdomain) the binary will fail to load. It will produce an error like the following:
Reproduction Steps
The bug report was provided privately to the CoreCLR team, and a repro will be provided as part of the fix.
Expected behavior
Assembly should be loadable.
Actual behavior
Regression?
This is a regression in .NET 9 from .NET 8 related to the work to rebuild how static variables are handled.
Known Workarounds
Remove
__declspec(appdomain)
from the definition of the global variable. On .NET 9 this has very little semantic effect (it can change initialization order relative to other global variables), causes a minor slowdown when using the variable, and triggers this bug.Configuration
This only reproduces for C++/CLI binaries as they have a unique startup path which causes the
<module>
type to be loaded before it would normally be permitted.Other information
No response
The text was updated successfully, but these errors were encountered: