尝试在线运行提供程序托管应用程序时出错

时间:2017-09-28 05:54:07

标签: azure sharepoint sharepoint-online

最近我试图创建一个提供商托管的应用程序来在线共享点。 我已经配置了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());
        }

1 个答案:

答案 0 :(得分:1)

看起来像CSOM dll的问题。请安装最新的CSOM在线版本,然后部署/发布您的代码。

转到Visual Studio中的项目引用,右键打开Manage Nuget packages,如下所示:

enter image description here

搜索CSOM并安装Microsoft.SharePointOnline.CSOM

enter image description here

或者,您也可以从下面提到的Microsoft下载链接下载它并手动添加引用:

SharePoint Online Client Components SDK

此外,确保.NET框架的目标是v4.5,平台目标设置为Any CPU。另外,请确保引用v16程序集。

另外,在ctx.Credentials行下方添加以下代码:

ctx.AuthenticationMode = ClientAuthenticationMode.Default;