最近我试图创建一个提供商托管的应用程序来在线共享点。 我已经配置了Azure Web应用程序并创建了应用程序并将其发布到在线共享点。我现在可以在SharePoint在线appcataloge中看到该应用程序。但是当我试图运行应用程序时,它会抛出以下错误。
System.IO.FileNotFoundException: msoidcliL.dll at Microsoft.SharePoint.Client.Idcrl.IdcrlNativeMethodsSelector..ctor(String dllPath) at Microsoft.SharePoint.Client.Idcrl.ManagedIdcrl.get_IdcrlNativeMethods() at Microsoft.SharePoint.Client.Idcrl.ManagedIdcrl.EnsureInited() at Microsoft.SharePoint.Client.Idcrl.ManagedIdcrl.LogonIdentity(String username, SecureString password) at Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.Logon(String username, SecureString password) at Microsoft.SharePoint.Client.SharePointOnlineCredentials..ctor(String username, SecureString password) at SharePointApp5Web.Default.Page_Load(Object sender, EventArgs e)
代码
var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
try
{
string str;
using (ClientContext ctx = new ClientContext("https://mydomain.sharepoint.com/sites/General/Community%20Portal/HR/Acknowledgements"))
{
ctx.Credentials = new Microsoft.SharePoint.Client.SharePointOnlineCredentials("myname@domain.com", ConvertToSecureString("password"));
Web myweb = ctx.Web;
List myList = myweb.Lists.GetByTitle("Timesheet Administration Policy");
ListItemCreationInformation ItemCreationInfo = new ListItemCreationInformation();
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml =
@"<Query>
<Where>
<Neq>
<FieldRef Name='ID' />
<Value Type='Counter'>946</Value>
</Neq>
</Where>
</Query>";
Microsoft.SharePoint.Client.ListItemCollection listItems = myList.GetItems(camlQuery);
ctx.Load(listItems);
ctx.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem listItem in listItems.ToList())
{
try
{
Response.Write(listItem["Email_x0020_Address"].ToString().Trim());
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
答案 0 :(得分:1)
看起来像CSOM dll的问题。请安装最新的CSOM在线版本,然后部署/发布您的代码。
转到Visual Studio中的项目引用,右键打开Manage Nuget packages
,如下所示:
搜索CSOM并安装Microsoft.SharePointOnline.CSOM
或者,您也可以从下面提到的Microsoft下载链接下载它并手动添加引用:
SharePoint Online Client Components SDK
此外,确保.NET框架的目标是v4.5
,平台目标设置为Any CPU
。另外,请确保引用v16程序集。
另外,在ctx.Credentials
行下方添加以下代码:
ctx.AuthenticationMode = ClientAuthenticationMode.Default;