Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-04-20 10:58 PM
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
------------------------------
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
------------------------------
Answered! Go to Answer.
1 BEST ANSWER
Helpful Answers
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-07-20 02:14 AM
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
------------------------------
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
------------------------------
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-07-20 02:14 AM
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
------------------------------
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
------------------------------
