none
Unable to add web part in SharePoint online

    Question

  • Hi,

    I have created custom web part and added in SharePoint online. Using Setting->WebParts-> Upload file.

    But when I am trying to add that web part on page I am getting following error.

    The file you imported is not valid. Verify that the file is a Web Part description file (*.webpart or *.dwp) and that it contains well-formed XML.

    This is plain web part only some text is added.

    Please help.

    Thanks,

    Pramod

    Tuesday, July 30, 2013 4:26 AM

All replies

  • Hi Pramod,

      Please share your webpart file and cs file, so that we will try to figure it out. I think there is some xml format error in your file.

     


    Balaji -Please click mark as answer if my reply solves your problem.

    Tuesday, July 30, 2013 5:26 AM
  • Hi,

    My WebPart File is:

    <?xml version="1.0" encoding="utf-8"?>
    <webParts>
      <webPart <?xml version="1.0" encoding="utf-8"?>
    <webParts>
      <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
        <metaData>
          <type name="TestApp.HelloWord.HelloWord, $SharePoint.Project.AssemblyFullName$" />
          <importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
        </metaData>
        <data>
          <properties>
            <property name="Title" type="string">TestApp - HelloWord</property>
            <property name="Description" type="string">My Visual Web Part</property>
          </properties>
        </data>
      </webPart>
    </webParts>xmlns="http://schemas.microsoft.com/WebPart/v3">
        <metaData>
          <type name="TestApp.HelloWord.HelloWord, $SharePoint.Project.AssemblyFullName$" />
          <importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
        </metaData>
        <data>
          <properties>
            <property name="Title" type="string">TestApp - HelloWord</property>
            <property name="Description" type="string">My Visual Web Part</property>
          </properties>
        </data>
      </webPart>
    </webParts>

    And My CS file is:

    using System;
    using System.ComponentModel;
    using System.Web.UI.WebControls.WebParts;
    
    namespace TestApp.HelloWord
    {
        [ToolboxItemAttribute(false)]
        public partial class HelloWord : WebPart
        {
            // Uncomment the following SecurityPermission attribute only when doing Performance Profiling on a farm solution
            // using the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
            // for production. Because the SecurityPermission attribute bypasses the security check for callers of
            // your constructor, it's not recommended for production purposes.
            // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
            public HelloWord()
            {
            }
    
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                InitializeControl();
            }
    
            protected void Page_Load(object sender, EventArgs e)
            {
            }
        }
    }
    

    Please let me know if required more information

    Thanks,

    Pramod

    Tuesday, July 30, 2013 8:21 AM
  • Hi Pramod,

                       Is your web part is created using sandbox solution?

    Thanks,

    Ajeet


    If my post is helpful - please click on the green arrow to mark it as answer

    Tuesday, July 30, 2013 9:04 AM
  • Hi Ajeet,

    No I have created this webpart as farm solution. I have tried with sandbox solution also but same issue.

    Also, in the local copy of SharePoint I am able to add this webpart. Only when I upload it on SharePoint online and add it on page I am getting above error.

    Also I have observer that all the in build webpart on SharePoint online has extension *.dwp and *.weppart. And from visual studio 2012 I am able to create *.WSP webpart.

    Thanks,

    Pramod 


    Tuesday, July 30, 2013 9:25 AM
  • Hi Pramod,

                      SharePoint Online does not support farm solution, It has o be sandbox solution, Please follow the steps mentioned below to make it work in SharePoint online

    1) create a web part sing sandbox solution,

    2) upload the wsp in solution in root site collection,

    3) active the feature to get the web part.

    In VS 2012, the development for SharePoint has been upgraded to package everything in wsp.

    Thanks,

    Ajeet


    If my post is helpful - please click on the green arrow to mark it as answer

    • Proposed as answer by Ajeet Nigam Tuesday, July 30, 2013 10:48 AM
    Tuesday, July 30, 2013 10:06 AM
  • Hi Ajeet,

    I found the issue I was uploading WebPart in wrong place in root site. I was uploading it in webpart sectioninstead of Solution section.

    Everything works find now thank for your help.

    Thanks,

    Pramod

    Tuesday, July 30, 2013 10:45 AM