Thursday, January 6, 2011

SharePoint 2010 - custom web part not show on the list.

Today, my workmate asked me a question:

Q: "I created a new custom web part on my PC by using Visual Studio 2010. I putted the WSP and all other files on the SharePoint 2010 server. I added and installed my new custom web part successfully but I can't find my custom web part from the web part gallery. What did I do wrong?"

After I heard about that, I was thinking the same thing, what was wrong on the server?

Before we troubleshoot the issue, let us review how to add and install a custom web part on the server.

Assume you have a custom web part called "HeloWorld" built by Visual Studio 2010 and it does thing like this:



In order to add and install the custom web part to the SharePoint server, I usually save the WSP file and all other files from the source directory and copy them to the SharePoint server. Once it is done, we can use the tool SharePoint 2010 Management Shell and run the SPSolution commands to add and install the custom web part.

The command to add the custom web part is:
Add-SPSolution C:\WSP_FILE_PATH\HeloWorld.wsp

The command to install the custom web part is:
Install-SPSolution –Identity HeloWorld.wsp –WebApplication http://localhost -GACDeployment

If everything goes well, run a command SPSolution and it should return a list like the following:


By looking at the list, everyone assume the custom web part should be installed properly and it should shows up under the Web Part Gallery or under the Document Editor


However, this is not the case and this is why my workmate came to me with his question. After I played around on the server, I found out even the custom web part is installed properly, I need to go to the Library Tools -> Library -> New Document -> select the new custom web part from the pop-up window and click the Populate Gallery button. By doing so, the new custom web part shows up on the previous list and from now on it should be selectable from the Document Editor.



No comments:

Post a Comment