I'm trying to add a new button in my sharepoint 2013 server via csom because in a few months I'll pass to project online and wsp aren't support anymore by project online So I found this guide on the net: https://www.c-sharpcorner.com/article/custom-actions-using-csom-for-sharepoint-online-part-2/

But when I have to add this line:

PublishRibbonaction.CommandUIExtension = @ 
"<CommandUIExtension><CommandUIDefinitions>" + 
"<CommandUIDefinition Location=\"Ribbon.Documents.Copies.Controls._children\">" + 
"<Button Id=\"InvokeAction.Button\" TemplateAlias=\"o1\" Command=\"EditFormButtonCommand\"
  CommandType=\"General\" LabelText=\"CustomListRibbonAction\"
  Image16by16=\"_layouts/15/images/placeholder16x16.png\" />" +
"</CommandUIDefinition>" + 
"</CommandUIDefinitions>" + 
"<CommandUIHandlers>" + 
"<CommandUIHandler Command =\"EditFormButtonCommand\" CommandAction =\
  RefreshOnDialogClose, 600, 400,'CustomList Ribbon');\" EnabledScript=\"javascript: 
  SP.ListOperation.Selection.getSelectedItems().length >= 1\" /> " + "

(I replaced the sharepoint URL by mine) I have the following error message:

Keyword, identifier, or string expected after verbatim specifier: @ Invalid expression term ''

Any idea of what I'm doing wrong?

1 Answer 1


Remove the @ sign. You are not using it anyway. If you want to use it, it should go with the string to which it is applied so @"<CommandUIExtension><CommandUIDefinitions>" (i.e. not on a different line), but that particular string doesn't have anything on it requiring the @ sign (i.e. all the @ sign does is cause \ not to be treated as an escape sequence, but you don't have any \ in that string so it's not needed, and removing the @ will fix the compiler error).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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