none
Unable to add selected web part(s). Cannot import this web part.

    Question

  • Hello

    I've got a "Unable to add selected web part(s). Cannot import this web part." problem that I can't solve. I have looked at the information available on the web but it does not seem to apply to this case. I would greatly appreciate any help.

    Here are the facts:

    • Installing the web part is no problem, but adding it to a page produces the error.

    • The problem occurs with all web parts that we develop. We are now focussing on a very simple web part, just for testing.

    • The problem does not occur on two other separate (stand alone) SharePoint servers.

    • SharePoint version: 2007 with SP2.

    • OS: Windows 2008 64 bit.

    • The account I use is member of the local administrators group and a site collection administrator in SharePoint.

    • The web part can be activated.

    • The web part is visible in the Web Part Gallery.

    • The DLL is present in the bin folder of the site's virtual directory in inetpub\wwwroot\wss

    • The log file reports the following:
      05/21/2010 11:30:31.60 w3wp.exe (0x1004) 0x17C8 Windows SharePoint Services Web Parts 8l4f Monitorable Error importing WebPart. Assembly hoikevin,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null, TypeName. hoikevin.WebPart1, hoikevin,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null

      05/21/2010 11:30:31.60 w3wp.exe (0x1004) 0x17C8 Windows SharePoint Services Web Parts 89ku High Failed to add webpart http%253A%252F%252Fvcjd107%252Dib%252Fpersonal%252Ffrans%252F%255Fcatalogs%252Fwp%252Fhoikevin%252EWebPart1%252Ewebpart;WebPart%25201. Exception Microsoft.SharePoint.WebPartPages.WebPartPageUserException: Cannot import this 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...

    • The error in the log file seems to be always preceded by the following line: "Failed to determine definition for Feature with ID 'fe7034f2-88ef-4df6-9885-bd8265d390b8'.  Skipping this feature for element querying consideration.". I have tried to find and remove the feature with this GUID but so far I have failed. I wonder if the problems are related..

    I can provide more details but I am not sure which are relevant to this problem. I someone can help or point me in the right direction because I am really stuck.

    Thanks,

    Frans

    Friday, May 21, 2010 3:16 PM

Answers

  • If it is NOT the public key token problem (fully qualified assemby name) then try:

    got to site settings -> webparts -> (If your webpart is in the list delete it) click on NEW -> check the webpart in the list, check overwrite, click on add to catalog.

    i had a similar problem and could solve it like above.


    Best regards,
    Yavuz B.

    My Sharepoint Blog http://www.sharepointkb.net
    • Proposed as answer by Cpouwels Wednesday, May 26, 2010 1:21 PM
    • Marked as answer by Chengyi Wu Thursday, May 27, 2010 12:56 AM
    Wednesday, May 26, 2010 8:35 AM

All replies

  • can you make sure the type tag in your .webpart file points to the correct full type name? check this post:

    http://stackoverflow.com/questions/120928/sharepoint-error-cannot-import-web-part

    Friday, May 21, 2010 3:32 PM
  • Please sign your assembly and put it in GAC.

    You can download and deploy my sample web part:

    http://www.mediafire.com/?nlqmmmhml43


    Cogito, ergo sum.
    Monday, May 24, 2010 1:58 AM
  • He,

     

    This may be a stupid question but how do you add a webpart to a site.

     

    What i have done so far is created a batch file does the following.

     

    "stsadm" -o addsolution -filename TreeViewWebPart.wsp"

    "stsadm" -o deploysolution -immediate -allowgacdeployment -force -name "TreeViewWebPart.wsp" -url "http://vm-dad-arcgis10/sites/Leguaan/ILogger/i-Logger.aspx" <- site where the webparts is supposed to go

    "stsadm" -o execadmsvcjobs

    pause

     

    The Batch files runs ok and the DLL is copied into the GAC, and after restarten the IIS when checking the site collection features it doesn't show the webpart.

     

    So my question is when adding the webpart like that how does one add it to a site?

     

    Thanks in advanced,

     

     

    Tuesday, May 25, 2010 9:58 AM
  • It seems there is no publickeytoken, so try to  sign the assembly and deploy again. One more thing, have you added safecontrol tag in web.config? 

    The log file reports the following:
    05/21/2010 11:30:31.60 w3wp.exe (0x1004) 0x17C8 Windows SharePoint Services Web Parts 8l4f Monitorable Error importing WebPart. Assembly hoikevin,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null, TypeName. hoikevin.WebPart1, hoikevin,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null


    Thanks & Regards, Neerubee
    • Proposed as answer by Cpouwels Tuesday, May 25, 2010 10:19 AM
    • Unproposed as answer by Chengyi Wu Wednesday, May 26, 2010 2:30 AM
    Tuesday, May 25, 2010 10:06 AM
    1. On the page that you want to edit, click Edit Page in the Actions list.
    2. At the top of the page in the shared view, click Modify Shared Page to modify the shared view.

      To add Web Parts to your personal view without affecting the view of other users, click Modify My Page from the personal view.

      Note   The text for the link at the top of the page changes depending upon whether you are looking at the shared view or the personal view.

    3. Point to Add Web Parts .
    4. To add a Web Part from an existing Web Part library, click Browse .

      The page opens in design mode, and the Add Web Parts pane appears.

    5. In the Add Web Parts pane, click the library you want to browse.
    6. In the Web Part List , find the Web Part you want. Click Next to view more Web Parts.
    7. To find the Web Part you want without browsing through all of the Web Part libraries, click Search after pointing to Add Web Parts .
    8. In the Search text box that appears in the Add Web Parts pane, type a word describing the Web Part for which you are looking, and then click Go .

      A list of Web Parts matching the search appears in the Add Web Parts pane.

      Show Tips

      • If the Web Part you want is not in a library, you can import a Web Part by clicking Import after pointing to Add Web Parts .

        In the text box that appears, type or browse to the location of a .dwp file you want to import as a new Web Part, and then click Upload .

        The Web Part is added to the currently selected Web Part library.

      • To switch between Browse, Search, and Import views of the Add Web Parts pane, click the current view just under the title of the pane, and then click the view that you want.
    9. From the available Web Parts, click the one you want to add.
    10. Click the zone to which you want to add the Web Part, and then click Add .

      You can also drag the Web Part to the desired location on the page.

    11. To close the Add Web Parts pane, click the X in the upper-right corner of the pane.

    Cogito, ergo sum.
    Wednesday, May 26, 2010 2:31 AM
  • If it is NOT the public key token problem (fully qualified assemby name) then try:

    got to site settings -> webparts -> (If your webpart is in the list delete it) click on NEW -> check the webpart in the list, check overwrite, click on add to catalog.

    i had a similar problem and could solve it like above.


    Best regards,
    Yavuz B.

    My Sharepoint Blog http://www.sharepointkb.net
    • Proposed as answer by Cpouwels Wednesday, May 26, 2010 1:21 PM
    • Marked as answer by Chengyi Wu Thursday, May 27, 2010 12:56 AM
    Wednesday, May 26, 2010 8:35 AM
  • The issue might be you were not included 4 part assembly name within the .webpart file. Check weather it represents the correct assembly or not. And check in the webpart gallery. If it is not there click the new button and select ypur webpart to populate in webpart gallery. Then you would be able to add that webpart on the page.

    Best

    Wednesday, May 26, 2010 1:07 PM
  • If it is NOT the public key token problem (fully qualified assemby name) then try:

    got to site settings -> webparts -> (If your webpart is in the list delete it) click on NEW -> check the webpart in the list, check overwrite, click on add to catalog.

    i had a similar problem and could solve it like above.


    Best regards,
    Yavuz B.

    My Sharepoint Blog http://www.sharepointkb.net

    This was it, we have been stuck on this for quite some time. Although it was quite frustrating thanks Chengyi Wu (for his webpart) and SharepointKB it is solved.

    Also thanks to everyone else that replied.

     

    Gr Cpouwels

    Wednesday, May 26, 2010 1:56 PM
  • After spending days and none of the solutions working, I finally solved this issue by removing ServiceLocator calls within the constructor of my web part. The ServiceLocator is in a separate assembly installed in GAC.

    Apparently initialising anything in the constructor that is referenced in an external assembly causes web part to not import.

    Tuesday, September 27, 2016 3:14 PM
  • We had a similar problem to Manish. The offending code wasn't explicitly in the constructor method itself but it WAS being initialised when the class was instantiated.

    We were loading a class instance from an external assembly and initialising it as a public static object at the top of the class / code. The solution was to initialise it as null, and load that instance at the point we actually needed it. Probably a better use of resources actually.

    To be more specific - our web part was using a strongly named version of Tuespechkin to generate a PDF file. Tuespechkin is a .NET wrapper for the wkhtmltopdf library:

    https://github.com/tuespetre/TuesPechkin

    Tuespechkin, as per the github docs, uses a 'ThreadSafeConverter' class for applications that require thread safety - and they suggest using this for any IIS applications. They also say to use a singleton instance or a static object for it, hence why it was loaded in as static by our developer.

    public static IConverter converter =
        new ThreadSafeConverter(
            new PdfToolset(
                new Win32EmbeddedDeployment(
                    new TempFolderDeployment())));

    For some reason, this code executed fine and we could add the web-part without problems on our development server. Our production server, however, didn't like it.

    Instead of doing the above, we simply loaded an instance when we required it and then disposed of it manually:

    private void OurPDFMethod() {
    
        IConverter converter =
            new ThreadSafeConverter(
                new PdfToolset(
                    new Win32EmbeddedDeployment(
                        new TempFolderDeployment())));
    
        // Our generator code
        // ...
    
        converter = null;
    
    }

    The error ("Cannot import this web part") immediately went away.

    Hopefully this helps somebody.

    Tom

     
    Friday, November 9, 2018 11:46 AM