当前位置: 首页 > 编程语言 > C#

无效的URI:Uri字符串太长Share

时间:2023-04-10 13:11:26 C#

无效的URI:Uri字符串太长XmlReaderSettingsettings=newSystem.Xml.XmlReaderSettings();settings.Schemas.Add(null,"http://example.com/myschema.xsd");settings.ValidationEventHandler+=newSystem.Xml.Schema.ValidationEventHandler(settings_ValidationEventHandler);settings.ValidationType=ValidationType.Schema;settings.IgnoreWhitespace=false;XmlReader阅读器=XmlReader.Create(xml,settings);我明白了InvalidURI:TheUristringistoolongSystem.UriFormatExceptionwasunhandledMessage=InvalidURI:TheUristringistoolong.Source=SystemStackTrace:在System.Uri.CreateThis(Stringuri,BooleandontEscape,UriKinduriKind)在System.Uri..ctor(StringuriString,UriKinduriKind)在System.Xml.XmlResolver.ResolveUri(UribaseUri,StringrelativeUri)在System.Xml.XmlUrlResolver.ResolveUri(UribaseUri,字符串relativeUri)在System.Xml.XmlReaderSettings.CreateReader(字符串inputUri,XmlParserContextinputContext)erSettings设置,XmlParserContextinputContext)在System.Xml.XmlReader.Create(StringinputUri,XmlReaderSettings设置)在ConsoleApplication2.Program.Main(String[]args)在Program.cs:第42行在System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,String[]args)在System.AppDomain.ExecuteAssembly(StringassemblyFile,EvidenceassemblySecurity,String[]args)在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()在System.Threading.ThreadHelper.ThreadStart_Context(Objectstate)在System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallbackcallback,Objectstate,BooleanignoreSyncCtx)在System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallbackcallback,Objectstate)在System.Threading.ThreadHelper.ThreadStarttion()不告诉InnerException:我的最大长度是多少或其他任何人以前有过这个吗?问题在于,如果参数是字符串,则xmlreader.create函数中的xml应该是uri。例如。XmlReaderreader=XmlReader.Create("http://ServerName/data/books.xml",settings);在您的情况下,xml文件被解释为url,因此它抱怨限制。看看这个msdndocXmlReader.Createmethodfordifferentoverloadedmethods..我猜你应该使用TextReader。以上就是C#学习教程的全部内容:invalidURI:Uristringistoolong。如果对你有用,需要进一步了解C#学习教程,希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处: