-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[NativeAOT] Runtime Directives (rd.xml) file not applied? #72989
Description
Description
Using VS 2022 Community 17.3.0 Preview 5.0 + .net sdk 7.0.100-preview.6.22352.1.
I am unable to fix a MissingInteropDataException via a Default.rd.xml.
Not sure if the runtime directive is processed or not. I don't see any difference in build output or build warnings/errors regardless of whatever I put inside the rd.xml. Even invalid xml has same build output.
I've tried setting the default.rd.xml as Embedded resource and still getting the same error.
How can I debug/verify what metadata is published?
Reproduction Steps
git clone https://github.com/gerardog/NativeAotRepro.git
cd NativeAotRepro\NativeAotRepro
dotnet publish -r win-x64 -c Debug
.\bin\Debug\net7.0\win-x64\publish\NativeAotRepro.exe
Hello, World!
Unhandled Exception: EETypeRva:0x004E71B0(System.Runtime.InteropServices.MissingInteropDataException): System.IO.Pipes.SECURITY_ATTRIBUTES is missing structure marshalling data. To enable structure marshalling data, add a MarshalStructure directive to the application rd.xml file. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=393965
at Internal.Runtime.CompilerHelpers.RuntimeInteropData.GetStructUnsafeStructSize(RuntimeTypeHandle) + 0xc4
at System.Runtime.InteropServices.Marshal.SizeOfHelper(Type, Boolean) + 0x36
at System.Runtime.InteropServices.Marshal.SizeOf(Object) + 0x42
at System.IO.Pipes.NamedPipeServerStreamConstructors.GetSecAttrs(HandleInheritability, PipeSecurity, Object&) + 0x8a
at System.IO.Pipes.NamedPipeServerStreamConstructors.New(String, PipeDirection, Int32, PipeTransmissionMode, PipeOptions, Int32, Int32, PipeSecurity, HandleInheritability, PipeAccessRights) + 0x3e2
at Program.<Main>$(String[]) + 0x91
at NativeAotRepro!<BaseAddress>+0x3a5167
at NativeAotRepro!<BaseAddress>+0x3a51f0
Alternative repro:
- Create dotnet 7.0 console app
- Add
<PublishAot>true</PublishAot>to.csprojfile - Add reference to nuget package
NamedPipeServerStream.NetFrameworkVersion(it is .NetStandard 2.0) - Add code:
using System.IO.Pipes;
var ps = new PipeSecurity();
using (var dataPipe = NamedPipeServerStreamConstructors.New("test", PipeDirection.InOut, 10,
PipeTransmissionMode.Message, PipeOptions.Asynchronous, 1024, 1024, ps))
{
Console.WriteLine("Named pipe created");
}
- Add proper
.rd.xmlfile - run
dotnet publish -r win-x64 -c Debug - run generated
.exefile
Expected behavior
The default.rd.xml should add type metadata to the build
Actual behavior
I don't see any difference regardless of the content of the rd.xml file.
Regression?
No response
Known Workarounds
No response
Configuration
Win11 21H2 + VS 2022 Community 17.3.0 Preview 5.0 + .net sdk 7.0.100-preview.6.22352.1.
Other information
No response