I'm currently using Micorsoft.SharePoint.Client version 14.0.4762.1000. Unfortunately, this package does not contain the necessary tools to upload an image to a Picture Library. In order to do so, I have to download Microsoft.SharePoint version 15.0.0 (only available) from NuGet. But upon calling dependency to this package, my application goes into:

Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code)

problem. Any solution?


The comment of Rustam Ismagilov pointing to this link is the correct answer. Here was my approach:

public async void UploadFileToSpDocLibAsync(string listTitle, string atchmtFilePath, Action<bool, string> callback = null) {

    if (!File.Exists(atchmtFilePath)) {
        callback?.Invoke(false, "File not found");

    try {

        await Task.Run(() => {

            // spsite is absolute uri of the SpSite
            using (var clientContext = new SPC.ClientContext(spsite)) {

                var web = clientContext.Web;

                var newFile = new SPC.FileCreationInformation {

                        Content = File.ReadAllBytes(atchmtFilePath),

                        Url = Path.GetFileName(atchmtFilePath)


                SPC.List docs = web.Lists.GetByTitle(listTitle);

                SPC.File uploadFile = docs.RootFolder.Files.Add(newFile);





        callback?.Invoke(true, string.Empty);

    } catch (Exception ex) {
        callback?.Invoke(false, ex.Message);


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.