1

I have created a sandbox solution in sharepoint 2013.I have added Custom action and Visual web part in to the solution.

Custom Action Code as following :

<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/">   <CustomAction
    Description="Search Title on Bing"
    Title="Bing IT!"
    Id="{E538E8C7-65DA-454E-AD87-4A603B6CC569}"
    Location="CommandUI.Ribbon"
    RegistrationId="101"
    RegistrationType="List"
    Sequence="0"
    Rights="ViewListItems"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Documents.Scaling._children">
          <MaxSize
            Id="Ribbon.Custom.MaxSize"
            GroupId="Ribbon.Documents.CustomGroup"
            Sequence="15"
            Size="LargeLarge" />
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Documents.Groups._children">
          <Group Id="Ribbon.Documents.CustomGroup"
                 Sequence="10"
                 Title="DMS Custom Actions"
                 Template="Ribbon.Templates.Flexible2">
            <Controls Id="Ribbon.Documents.CustomGroup.Controls">
              <Button Id="Ribbon.Documents.CustomGroup.PrintPreview"
                   Command="PrintPreview"
                   Sequence="10"
                   Image16by16="/_layouts/15/images/BI.Test.ContentTypes/Print-Preview-Icon-16x16.png"
                   Image32by32="/_layouts/15/images/BI.Test.ContentTypes/Print-Preview-Icon-32x32.png"
                   Description="This action prints the preview" LabelText="Print Preview"
                   TemplateAlias="o2"/>
            </Controls>
          </Group>
      </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
        Command="PrintPreview"
        CommandAction="javascript:alert('Test');
            function CloseDialogCallback() {    
                    }

                      function OpenDialog(pageUrl) {
                      var options = { url: pageUrl, width: 400, height: 250, allowMaximize: true, showClose: true };
                      SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
                    } 
                    var context = '';
                    var selectedItems = '';
                    var siteUrl = '';                    
                    var currentLibId = ''; 
                    this.context = SP.ClientContext.get_current();
                    alert(context);
                    this.siteUrl = _spPageContextInfo.webAbsoluteUrl;
                    this.currentLibId = SP.ListOperation.Selection.getSelectedList();
                    this.selectedItems = SP.ListOperation.Selection.getSelectedItems(context);
                    this.currentLibId = this.currentLibId.replace('{', '').replace('}', '');
                    var pageUrl = _spPageContextInfo.siteAbsoluteUrl + '/Pages/CustomAction.aspx?itemId=' + this.selectedItems[0].id + '&amp;listId='+this.currentLibId + '&amp;url=' + window.location.href;
                    alert(pageUrl);
                    OpenDialog(pageUrl); 


"/>
      </CommandUIHandlers>
    </CommandUIExtension>   </CustomAction> </Elements>

I have added visual Web part with one button control and the Label control on it.

I have deployed solution in to the farm solution.i am able to do feature activation in farm solution. All the functionality is properly configured which is in feature.

Issue facing Scenario :

Solution is deployed in SharePoint Online but when i am going to do feature Activation that time SharePoint online environment gives me exception which is defined below.

Error :

Sorry, something went wrong Error validating assembly 'CustomActionDemo.dll'.

This solution references prohibited type 'System.Threading.SendOrPostCallback' and cannot be used on this site collection.

I don't know, why this exception is occurred only in SharePoint Online ? How can i over come this issue ? I want to Create a single solution for SharePoint online and SharePoint server both. What is other way to create a functionality which is running in both the environment(online and onPrem)?

Help me out from this!

  • Any code in Feature Event Receiver? Did you check by simply adding custom action only and no webpart then try activating the feature. – Pradip R. Jul 20 '16 at 12:24

Your Answer

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

Browse other questions tagged or ask your own question.