我正在尝试在我的 Dot Net 应用程序(C# 编程语言)中加载 iText7 的许可证文件。我已经使用下面提到的语法给出了 json 文件的正确路径。
LicenseKey.LoadLicenseFile(new FileStream(@"pathtofile\iTextKey.json", FileMode.Open));
我收到的错误消息是:
Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at iText.License.Util.XmlWorker..ctor(Stream stream)
at iText.License.LicenseKey.LoadLicenseFileInternal(Stream licenseIs)
at iText.License.LicenseKey.LoadLicenseFile(Stream licenseIs)
我验证了 JSON 文件,它看起来没问题。
任何解决此问题的帮助都会有很大帮助。
最佳答案
尽管通过 nuget 包安装了 iText v7.2.4 和 iText.Licensing.Base v4.0.4,但我还是遇到了同样的错误。结果我的解决方案也有旧版本的 iText(通过导入的库),并且使用的 LoadLicenseFile 方法来自该旧库。
换句话说,请确保您调用的完全限定方法是iText.Licensing.Base.LicenseKey.LoadLicenseFile
关于c# - iText7:无法读取许可证 key json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73731062/