@@ -5,6 +5,7 @@ namespace AngleSharp.Xml
55 using AngleSharp . Svg . Dom ;
66 using AngleSharp . Xml . Dom ;
77 using AngleSharp . Xml . Parser ;
8+ using System ;
89 using System . Linq ;
910 using System . Threading ;
1011 using System . Threading . Tasks ;
@@ -38,7 +39,7 @@ public static IConfiguration WithXml(this IConfiguration configuration)
3839
3940 private static Task < IDocument > LoadXmlAsync ( IBrowsingContext context , CreateDocumentOptions options , CancellationToken cancellationToken )
4041 {
41- var parser = context . GetService < IXmlParser > ( ) ;
42+ var parser = context . GetService < IXmlParser > ( ) ?? throw new InvalidOperationException ( "The IXmlParser service has been removed. Cannot continue." ) ;
4243 var document = new XmlDocument ( context , options . Source ) ;
4344 document . Setup ( options . Response , options . ContentType , options . ImportAncestor ) ;
4445 context . NavigateTo ( document ) ;
@@ -47,7 +48,7 @@ private static Task<IDocument> LoadXmlAsync(IBrowsingContext context, CreateDocu
4748
4849 private static Task < IDocument > LoadSvgAsync ( IBrowsingContext context , CreateDocumentOptions options , CancellationToken cancellationToken )
4950 {
50- var parser = context . GetService < IXmlParser > ( ) ;
51+ var parser = context . GetService < IXmlParser > ( ) ?? throw new InvalidOperationException ( "The IXmlParser service has been removed. Cannot continue." ) ;
5152 var document = new SvgDocument ( context , options . Source ) ;
5253 document . Setup ( options . Response , options . ContentType , options . ImportAncestor ) ;
5354 context . NavigateTo ( document ) ;
0 commit comments