XmlCompiledTransform.Load throws a System.PlatformNotSupportedException on iOS with .NET 8 · Issue #96920 · dotnet/runtime (original) (raw)
Description
Calling XmlCompiledTransform.Load(XmlReader, XsltSettings, XmlResolver)
in a .NET 8 iOS MAUI app throws a PlatformNotSupportedException. This call worked previously when targeting .NET 7 iOS MAUI. From the stacktrace it's likely that all XmlCompiledTransform.Load
methods will throw this exception.
Reproduction Steps
- Create a .NET 8 iOS MAUI app.
- Initialize and call
XmlCompiledTransform.Load(XmlReader, XsltSettings, XmlResolver)
with a valid xsl file, xml resolver, andXsltSettings.EnableDocumentFunction = true
andXsltSettings.EnableScript = false
. - Call to
Load
throws an exception.
Expected behavior
XmlCompiledTransform.Load
loads the provided xsl transform.
Actual behavior
Calling XmlCompiledTransform.Load
throws an exception with the given stack trace.
---> System.TypeInitializationException: The type initializer for 'System.Xml.Xsl.IlGen.XmlILModule' threw an exception.
---> System.PlatformNotSupportedException: Dynamic code generation is not supported on this platform.
at System.Reflection.Emit.AssemblyBuilder.ThrowDynamicCodeNotSupported()
at System.Reflection.Emit.AssemblyBuilder.EnsureDynamicCodeSupported()
at System.Reflection.Emit.RuntimeAssemblyBuilder..ctor(AssemblyName , AssemblyBuilderAccess )
at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly(AssemblyName , AssemblyBuilderAccess )
at System.Xml.Xsl.IlGen.XmlILModule.CreateLREModule()
at System.Xml.Xsl.IlGen.XmlILModule..cctor()
--- End of inner exception stack trace ---
at System.Xml.Xsl.XmlILGenerator.Generate(QilExpression , TypeBuilder )
at System.Xml.Xsl.XslCompiledTransform.CompileQilToMsil()
at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object , XsltSettings , XmlResolver , XmlResolver )
at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader , XsltSettings , XmlResolver )
Regression?
XmlCompiledTransform.Load
worked previously with Xamarin.iOS as well as .NET 7 iOS MAUI. It stopped working with .NET 8 iOS MAUI.
Known Workarounds
Using the obsolete XmlTransform
class instead on iOS with .NET 8 works, but comes at the cost of XmlTransform.Transform
having worse performance than XmlCompiledTransform.Transform
.
Configuration
iOS
iOS 16.7.4
iPad Pro 12"
Xcode
Xcode 15.0
Build version 15A240d
Dotnet
.NET SDK:
Version: 8.0.101
Commit: 6eceda187b
Workload version: 8.0.100-manifests.8a1da915Runtime Environment:
OS Name: Mac OS X
OS Version: 13.5
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.101/.NET workloads installed:
Workload version: 8.0.100-manifests.8a1da915
[maui-ios]
Installation Source: SDK 8.0.100
Manifest Version: 8.0.3/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.3/WorkloadManifest.json
Install Type: FileBasedHost:
Version: 8.0.1
Architecture: arm64
Commit: bf5e279.NET SDKs installed:
6.0.418 [/usr/local/share/dotnet/sdk]
7.0.405 [/usr/local/share/dotnet/sdk]
8.0.101 [/usr/local/share/dotnet/sdk].NET runtimes installed:
Microsoft.AspNetCore.App 6.0.26 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.26 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]Other architectures found:
x64 [/usr/local/share/dotnet/x64]
registered at [/etc/dotnet/install_location_x64]
Other information
These are the build properties set for the debug iOS app that may be relevant.
15.0 Off SdkOnly all False False True True cjk,rare,west True False False True True False False False True ios-arm64