I have an assembly written in c# that does DTD validation on an input string. It uses XMLReaderSettings.ValidationTpe = ValidationType.DTD and XMLReaderSettings.ProhibitDtd = false. XML validation works fine when linking this assembly in applications that target 2.0, 3.5, 4.0, 4.5 but when the application targets 4.6 it no longer works (DTD processing becomes prohibited). I know that ProhibitDtd is deprecated in 4.0 in favor of DtdProcessing = DtdProcessing.Parse.
I can't use DtdProcessing.Parse unless I target 4.0 for my assembly. My questions are: 1. How can I continue to target 3.5 and get it to work in applications targeting 4.6 and higher? 2. If I have to target 4.0 to make it work, how will that affect an application that targets 2.0 using my 4.0 assembly?
I have solved this problem. I am now able to continue to target 3.5 with my assembly and when it is linked into an application targeting 4.6 and above it still is able to validate XML with DTDs.
I had to explicitly set the XmlReaderSettings.XmlResolver to a new XmlUrlResolver() to get it to work. I guess without setting this to a new XmlUrlResolver() the 4.6 framework sets it at runtime with a resolver that will not allow DTD validation.