SharePoint error: “Cannot import Web Part”

前端 未结 11 1427
青春惊慌失措
青春惊慌失措 2021-02-08 02:33

I have a web part that I\'ve developed, and if I manually install the web part it is fine.

However when I have packaged the web part following the instructions on this w

相关标签:
11条回答
  • 2021-02-08 03:01

    Solved mine.

    i was getting this error:

    ===========================================================================
    Error importing WebPart. Cannot import ........ Web Part.
    Failed to add webpart 
    Exception Microsoft.SharePoint.WebPartPages.WebPartPageUserException: Cannot import ... Web Part.     at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean clearConnections)     at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean clearConnections, Uri webPartPageUri, SPWeb spWeb)     at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean clearConnections, SPWeb spWeb)     at Microsoft.SharePoint.WebPartPages.WebPartQuickAdd.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)   
    ===========================================================================
    

    "Cannot import webpart..."

    The problem was: Non-matching GUIDS

    Check if the guid on webpart class , and in the .xml and in .webpart class are same.

    I was copy-pasting code from other webparts sources. ( Mutliple Document Upload Wepart on Codeplex) and forgot to fix guids.

    0 讨论(0)
  • 2021-02-08 03:03

    I have also experienced this error when the assemblies in the GAC that my web part referenced, was signed by a different strong name key file to what I was expecting. I found this out when deciding to update these DLLs. When inserting it into the GAC I noticed that there were 2 entries for the same DLL but they had different Public Key Tokens

    0 讨论(0)
  • 2021-02-08 03:03

    All great suggestions. My problem was unique and silly: I had deployed the solution to the first Web Application but not to the second. SharePoint however still allowed me to activate the feature on the second Web App's Site Collection (not sure why). This meant the second Web App didn't have a safe control entry in this Web.config file (and I was stupidly checking the first Web.config).

    So, double-check you're looking at the correct web application/web.config.

    0 讨论(0)
  • 2021-02-08 03:04

    I found that mine did not import the first time, but if I clicked 'New' and added it, it would work.

    From there I grabbed a copy of the XML and saved it to my project. The web part worked great after that.

    It only took me DAYS to get to this point. A lot of wasted time.

    0 讨论(0)
  • 2021-02-08 03:13

    We had this same problem and found that the constructor of our web part was being called by the WebPartImporter and within the constructor we were doing SPSecurity.RunWithElevatedPrivileges.

    For some reason the WebPartImporter cannot handle this. So, we simply moved our code out of the constructor to OnInit (where it really belonged) and all is well.

    0 讨论(0)
提交回复
热议问题