2

I've found the following link on msdn and I've been struggeling to get it running. I had to use Microsoft.SharePoint.Client.dll from 16 hive (I'm using SharePoint 2013 server) inside Visual Studio to get no compile error. After running the following code, I got a "Method not found" exception:

    var clientContext = new ClientContext("http://myserver");

    var fileGuid = new Guid("D51C440B-4F52-4005-90BE-BDC42E850975");
    var file = clientContext.Web.GetFileById(fileGuid);

    clientContext.Load(file);
    clientContext.ExecuteQuery();

Please help me on what I'm doing wrong.

  • For newcomers: See stackoverflow.com/questions/32631944/how-to-use-web-getfilebyid When you install SP SDK, two version of the client are available. 15 for SP 2010 and 16 for SP online or something like that. – Santhos Jul 18 '16 at 14:52
  • 15 is for SP2013 and not for SP2010! – Andreas Jul 19 '16 at 7:17
  • It depends what SDK you have, if you have SDK for SP 2010 then 15 is for SP 2010 I believe. – Santhos Jul 19 '16 at 9:58
1

I do not thing you are having problem in Web.GetFileByID as I also used it in my project

var file = ctx.Web.GetFileById(id);
ctx.Load(file, f=>f.Name);
ctx.ExecuteQuery();
  • Can you please tell me the CU build of your enviroment? I came to the conclusion that I might miss some updates. – Andreas Sep 18 '15 at 7:59
  • It is 15.0.4737.1001(July 2015 I guess).I do not think that should be a problem – Amit Kotha Sep 18 '15 at 8:57
  • I'm using April 2015 and it's available there, so I think that's the solution. Unfortunately there is no date on the website when they added this method. – Andreas Sep 18 '15 at 11:04
  • 1
    I've upgraded my VM to July 2015 CU and still can't get it running. Where are the SharePoint.Client files located you're using in your solution? Thanks for helping. – Andreas Sep 21 '15 at 8:12
  • I've uploaded the screenshot of the errormessage here: link – Andreas Sep 21 '15 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.