大约一周前用于将文件上载到我们的Sharepoint网站的代码正在工作。突然它不是,当我运行ClientContext ExecuteQuery()方法时,我得到以下错误:ExecuteQuery停止为Sharepoint ClientContext工作
'='是一个意外的标记。预期的标记是';'。
这里是我的代码:
using (var context = new ClientContext(siteUrl))
{
context.Credentials = GetSharePointCredentials();
var web = context.Web;
Microsoft.SharePoint.Client.List list = context.Web.Lists.GetByTitle("Account");
context.ExecuteQuery();
没有什么花哨的事情。我真的不知道从哪里开始。什么也没有变。代码没有改变。我在Visual Studio中处于调试模式,但(a)它也不适用于那些在生产中使用该软件的人员,以及(b)在调试时我确实已经使其一次工作,所以这是一个间歇性的事情(如果失败99%时间可以称为间歇性的)。
如果有帮助,我们将在云中托管Sharepoint。
这里是堆栈跟踪:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(String expectedToken1, String expectedToken2)
at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(Int32 pos, String expectedToken1, String expectedToken2)
at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos)
at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
at System.Xml.XmlTextReaderImpl.FinishPartialValue()
at System.Xml.XmlTextReaderImpl.get_Value()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.DoGet(String url)
at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.RequestFederationProviderInfo(String domainname)
at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetFederationProviderInfo(String domainname)
at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.InitFederationProviderInfoForUser(String username)
at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetServiceToken(String username, String password, String serviceTarget, String servicePolicy)
at Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.GetAuthenticationCookie(Uri url, String username, SecureString password, Boolean alwaysThrowOnFailure, EventHandler`1 executingWebRequest)
at Microsoft.SharePoint.Client.SharePointOnlineCredentials.GetAuthenticationCookie(Uri url, Boolean refresh, Boolean alwaysThrowOnFailure)
at Microsoft.SharePoint.Client.ClientRuntimeContext.SetupRequestCredential(ClientRuntimeContext context, HttpWebRequest request)
at Microsoft.SharePoint.Client.SPWebRequestExecutor.GetRequestStream()
at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at vas.Dynamics.Crm.Library.CrmGateway.SaveFileToSharePoint(String siteUrl, String relativeUrl, String documentUrl, Byte[] documentData) in C:\Users\rmorgan\Source\Repos\backoffice\VAS.Dynamics.Crm.Library\VAS.Dynamics.Crm.Library\CrmGateway.cs:line 430
at vas.Dynamics.Crm.Library.CrmGateway.SaveDocument(Guid accountId, String documentName, Byte[] documentData) in C:\Users\rmorgan\Source\Repos\backoffice\VAS.Dynamics.Crm.Library\VAS.Dynamics.Crm.Library\CrmGateway.cs:line 233
at PrintEmailContractRenewal.Form1.CreatePdfDocuments(EntityCollection contractRenewals) in C:\Users\rmorgan\Source\Repos\backoffice\PrintEmailContractRenewal\PrintEmailContractRenewal\Form1.cs:line 190
请提供一个堆栈跟踪? – 12seconds
在上面添加了它。这是一些XML错误,第1行107.但是,XML是什么? – gareth99
如何将文件保存到SharePoint?该错误指出XML中存在非法字符,最有可能是&并且需要编码为&s; – 12seconds