简体   繁体   English

在以4.6为目标的应用程序中进行链接时,3.5程序集中的DTD验证失败

[英]DTD validation in a 3.5 assembly fails when linked in an application targeting 4.6

I have an assembly written in c# that does DTD validation on an input string. 我有一个用c#编写的程序集,它对输入字符串进行DTD验证。 It uses XMLReaderSettings.ValidationTpe = ValidationType.DTD and XMLReaderSettings.ProhibitDtd = false. 它使用XMLReaderSettings.ValidationTpe = ValidationType.DTD和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). 在目标为2.0、3.5、4.0、4.5的应用程序中链接此程序集时,XML验证可以正常工作,但是在目标为4.6的应用程序中,XML验证不再起作用(禁止进行DDT处理)。 I know that ProhibitDtd is deprecated in 4.0 in favor of DtdProcessing = DtdProcessing.Parse. 我知道ProhibitDtd在4.0中已弃用,而推荐使用DtdProcessing = DtdProcessing.Parse。

I can't use DtdProcessing.Parse unless I target 4.0 for my assembly. 除非我将程序集目标为4.0,否则不能使用DtdProcessing.Parse。 My questions are: 1. How can I continue to target 3.5 and get it to work in applications targeting 4.6 and higher? 我的问题是:1.如何继续以3.5为目标并使其在以4.6及更高版本为目标的应用程序中工作? 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? 2.如果必须以4.0为目标,那么它将如何影响使用4.0程序集针对2.0的应用程序?

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. 现在,我可以继续以我的程序集为目标3.5,并将其链接到目标为4.6及更高版本的应用程序时,它仍然能够使用DTD验证XML。

I had to explicitly set the XmlReaderSettings.XmlResolver to a new XmlUrlResolver() to get it to work. 我必须将XmlReaderSettings.XmlResolver显式设置为新的XmlUrlResolver()才能使其正常工作。 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. 我想如果不将其设置为新的XmlUrlResolver(),4.6框架会在运行时使用不允许DTD验证的解析器对其进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UWP-使用面向.NET Framework 4.6的程序集 - UWP - Use assembly targeting .NET Framework 4.6 PowerShell未定位到4.6 - PowerShell not targeting 4.6 由于引用了针对.Net Framework 3.5的程序集,因此无法加载文件或程序集版本为2.0.5.0的系统 - Could not load file or assembly System, Version=2.0.5.0 due to the referenced assembly targeting .Net Framework 3.5 这是为 .NET 3.5 和 .NET 4.6 维护和分发一个汇编代码库的最佳实践 - Which is the best practice for maintaining and distributing one assembly code base for both .NET 3.5 and .NET 4.6 引用.NET Framework 4.6程序集的ASP.Net 5应用程序 - ASP.Net 5 Application referencing .NET Framework 4.6 assembly 缺少程序集时.NET应用程序无提示启动失败 - .NET application silently fails to start when assembly missing C#中的DTD验证 - DTD validation in C# 创建针对.net 3.5和4的VSPackage - Creating VSPackage targeting .net 3.5 and 4 链接到asp.net c#应用程序时C ++ dll无法写入文件 - C++ dll fails to write to file when linked to asp.net c# application 当项目升级到 .Net Framework 4.7.2 时,从面向项目的 .Net Framework 4.6 引用的 DLL 不再出现在 bin 中 - Referenced DLL From Project Targeting .Net Framework 4.6 is no longer appearing in bin When Project Upgraded to .Net Framework 4.7.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM