cancel
Showing results for 
Search instead for 
Did you mean: 

SharePoint Client Runtime DLL error even after referencing it in Object Studio

Faraz_Ahmed_Hus
Level 2
Hello,

I am writing C# code to get all list names from SharePoint Online site. I have referenced the below given DLL's with respective namespaces. But still it is throwing error on Code Check. Can someone please assist?

Type: Error
Description: Compiler error at top section line 5: The type or namespace name 'Runtime' does not exist in the namespace 'Microsoft.SharePoint.Client' (are you missing an assembly reference?)

(All DLLs are in local Blue Prism Automate folder)
System.dll
System.Data.dll
System.Xml.dll
System.Drawing.dll
Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll
System.Linq.dll

Here is my code:
public string GetSPOnlineListItems(string siteurl, string username, string password)
{
string result = "";
try
{
using(var ctx = new ClientContext(siteurl))
{
var passWord = new SecureString();
foreach (char c in password.ToCharArray()) 
{
passWord.AppendChar(c);
}
ctx.Credentials = new SharePointOnlineCredentials(username, passWord);
Web web = ctx.Web;
ctx.Load(web.Lists, lists => lists.Include(list => list.Title, list => list.Id));
ctx.ExecuteQuery();
foreach(List list in web.Lists)  
{  
result = result + list.Title;
   }
}
}
catch (Exception ex)   {   result = result + "Error is: " + ex.Message;   } 
return result;
}

------------------------------
Thanks,
Faraz
------------------------------
1 BEST ANSWER

Helpful Answers

SamAssaf
Level 3
Hi Faraz,

Even if you're importing Microsoft.SharePoint.Client.Runtime.dll the namespace associated to it is still Microsoft.SharePoint.Client. It's confusing, I know, but while you need to import the DLL in external references, there's no Microsoft.SharePoint.Client.Runtime namespace to import.

Remove the nonexistent namespace and everything should be fine.

You can learn more about the Microsoft.SharePoint.Client namespace here.

Cheers!

------------------------------
Sam Assaf
Senior
EY
Montreal QC
------------------------------

View answer in original post

1 REPLY 1

SamAssaf
Level 3
Hi Faraz,

Even if you're importing Microsoft.SharePoint.Client.Runtime.dll the namespace associated to it is still Microsoft.SharePoint.Client. It's confusing, I know, but while you need to import the DLL in external references, there's no Microsoft.SharePoint.Client.Runtime namespace to import.

Remove the nonexistent namespace and everything should be fine.

You can learn more about the Microsoft.SharePoint.Client namespace here.

Cheers!

------------------------------
Sam Assaf
Senior
EY
Montreal QC
------------------------------