【问题标题】:error while trying to run the provider hosted app to SharePoint online尝试将提供程序托管的应用程序运行到 SharePoint Online 时出错
【发布时间】:2017-09-28 05:54:06
【问题描述】:

最近我试图创建一个提供商托管的应用程序来在线共享点。 我已经配置了 Azure Web 应用程序并创建了应用程序并将其发布到在线共享点。我现在可以在 SharePoint 在线应用程序目录中看到该应用程序。但是当我尝试运行应用程序时,它会抛出以下错误。

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());
        }

【问题讨论】:

    标签: azure sharepoint sharepoint-online


    【解决方案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;
    

    【讨论】:

    • 你也可以在ctx.Credentials 行下面添加这行ctx.AuthenticationMode = ClientAuthenticationMode.Default; 并检查吗?此外,确保您的项目以 .Net 框架 4.5 为目标,平台目标设置为 Any CPU。确保其 v16 程序集
    • 工作就像一个魅力! :)。你能更新答案吗?这样我就可以将其标记为答案。
    猜你喜欢
    • 1970-01-01
    • 2015-09-02
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    • 2016-02-07
    • 1970-01-01
    • 2015-04-24
    • 2016-07-10
    相关资源
    最近更新 更多