Deploying New Web Parts - sharepoint

I've been trying to follow the information from:
Long URL clipped to stop breaking the page
and
http://msdn.microsoft.com/en-us/library/ms415817.aspx
Which more or less have the same instructions. I've been copying the .dll file from the build over to the BIN directory of the Sharepoint site.
When I click the Web Part Gallery and hit new, both articles say that the web part should show up in the list.
I have tried every possible way that I can think, but my web part will not show up in that list. Is there a step that I missed somewhere? Are there permissions that I should be thinking about? How exactly does Sharepoint recognize that there is a new web part. Is it simply from having the assembly placed in the BIN directory, or is it from adding the control in the safe list of web.config?
I've added it to the safe controls list. I've tried every different combination that I could think of, but nothing has worked.
Do I need to rename the .DLL assembly to something else?
For the life of me I cannot figure this out.

I believe the minimum you need to have a WP show up in the "New" Part of the webPart Catalog, you need the dll in the "bin" folder (bin in the web dir, not the 12 hive :)) or in the GAC and a safe control entry. I would verify the Safe control entry:
Assembly = name of dll
NameSpace = well... The NameSpace where your WebPart class resides
TypeName = the name of your webPart class
You can wildcard the NameSpace and TypeName just to be sure you are getting there:
... Namespace="*" TypeName="*" ...
I would also recommend signing the assembly and putting in a PublicKeyToken=...
Also, try setting the trust level to WSS_Medium or Full.
If this doesn't work, you can try adding a .webpart file to the wpCatalog folder in your web dir.
Edit: Clarification

This has to be a mismatch between your assembly and what has been entered into web.config for the safecontrol entry.
The safecontrol entry is case sensitive - and the smallest of errors will stop is from showing on the 'New' listing of the web part gallery.
Also make sure you are editing the correct web.config! :-) Another common gotcha is that your web part class has to be public.
Hope this helps
Nick Swan

Have you tried using the WPPackager tool from Microsoft? I haven't touched SharePoint since v2003, and I know there was a handy tool for WP deployment for that platform. I'd offer a link to it, but 1) I can't remember its name, and 2) I'm not sure if it is a valid installation route for your version of SharePoint.

Wow, you have me stumped ... I would try deploying some other 3rd party "free" web parts manually and see if you can get those to show up. This site has a few:
http://www.sharepointblogs.com/mkruger/archive/2007/06/26/free-sharepoint-web-parts-3rd-party.aspx
Have you made sure that you set: [assembly: AllowPartiallyTrustedCallers]
in your AssemblyInfo file?
I am amazed no one else has chimed in on this. I guess next step would be to try to deploy it as a feature/solution.
Is this a simple hello world wp or are you doing something more?
To be honest, I am beginning to believe that it is your wss/moss configuration/settings that is hampering your efforts at the moment. Have you ever successfully deployed a WP to your farm? ... Is this a VPC dev farm or production?

I've been creating a few web parts over the past 2 weeks, but I have not used the "New Web Parts" section of the Web Part Gallery. Instead, I create a .dwp file (e.g. MyWebPart.dwp), which is more or less an XML file describing the web part, and I manually import it into the gallery.
The format for my .dwp files generally looks like this:
<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" >
<Title>My Sample Web Part</Title>
<Description>This web part displays "Hello World" on the page.</Description>
<Assembly>My.Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3ed03eac7f647a61</Assembly>
<TypeName>My.Assembly.MyWebPartClassName</TypeName>
<!-- Specify initial values for any additional base class or custom properties here. -->
</WebPart>
This of course assumes that you've added this assembly as a "Safe Control". After you compile your assembly and move it into the bin/GAC for your SharePoint machine, go back to the web part gallery, click "Upload", and upload your .dwp file. You'll have to specify a few properties after uploading it.
Assuming your web part exists in your .dll, then you should see it added to the gallery list, and you can preview it or add it to a page at that point.

Related

Issue related to layout of custom webpart

According to requirement of application, I have developed a custom web part in Kentico 9. This web part is using with same functionality at various places but we have to use with different layout structure.
As per my understanding, we can create custom layouts for a single web part from "Layout Tab" in web part configuration. As I used same things with various Kentio built in web part like Logon form, Logon-Mini form, etc.
But while trying to create new layout for my custom web part, I am getting web part loading error and when I checked into event log it is showing following error:
The file
'/CMSVirtualFiles/WebPartLayouts/=vg=87a868ce-926c-4cb3-a441-b4f1d4310afc/TDNForgottenPassword/ForgottenPassword.ascx.cs'
does not exist.
Here, internally system looking for ".CS" file under "CMSVirtualFiles" folder, which has actually under the "CMSWebParts" directory in which I have created my user control.
Is there any specific configuration required in custom web part to implement multiple layout of it? Please help me and guide me, what am I missing or doing wrong?
Check your webpart code file property in the ascx file. You need to specifically declare the full relative path to the .cs file and not just the filename. For example:
Correct
CodeFile="~/CMSWebParts/Community/GroupRegistration.ascx.cs"
Incorrect
CodeFile="GroupRegistration.ascx.cs"
Please make sure you don't have the store virtual files in the file system setting enabled.

How does sharepoint resolve feature.xml file?

I'm getting a DirectoryNotFound exception when attempting to add my custom web part to a page. It seems pretty straight forward since it's complaining about not being able to find the "feature.xml" file for the web part. What is odd is that the Directory that is showing up in the error message is completely different from the one that the Web Part is installed in. So the file it should be looking in is \12\Template\Features\WebPart1\feature.xml but it is looking in \12\Template\Features\WebPart2\feature.xml.
Can someone explain to me how Sharepoint performs feature activation or point me to a link that is helpful?
Thanks,
Jason
--Edit more information --
I'm using WSPBuilder to create and build the Sharepoint feature. My understanding of how this should work is that WSPBuilder will copy my feature.xml file to the Sharepoint site and my .webpart to the wp folder. When I activate a feature it will look into the feature xml file and reference the .webpart file that will contain the configuration for which webpart class to load. The webpart2 folder that it is currently referencing is an old feature that I uninstalled so it must somehow be confused as far as where the feature folder is but without knowledge on how it determines where to look I'm at a bit of a loss on how to correct it. Does it save the guid in the SP database somewhere? Any information on how this feature activation process works would be helpful.
I'd vote myself down if I could... that error message had nothing to do with the problem. It was an exception that was being thrown but being caught in Sharepoint.

How to find missing web part?

Does anybody know how to find offending web part which causes this error ?
“A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe.”
I have inherited an old SharePoint 2003 portal site which uses custom web parts.
I know what this error means. I also know that each web part must be installed and registred as safe in web.config. The problem is that I don't know which one is missing.
I get same error when I'm trying to open the page in FrontPage as well.
Use contents=1 in QueryString to disable/remove WebParts from page that causes errors.
stsadm.exe -o enumallwebs -includewebparts
http://sharepointreporter.wordpress.com/
Requires updating to Sp2 I believe, for this command to be available. Problematic web parts will appear as 'Missing' in the resultant list.
Go to Event Viewer of the machine and you shall be able to see Error entries. Out of tons of entries you have to find out the entries related to you and you shall be able to see the names of the webparts that the sharepoint site is trying to load but fails. If you shall read the complete description of the error entry in the Event Viewer, it will give you version and even PublicKey Token of the webpart as well.
I hope this helps!!!
Try reading this:
http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=189
It should give you some clues to solving the problem. Essentially you have a control that is not marked as safe and it is failing. You can most likely config it to work, but the link above has other possible solutions.
in your url just append content=1. This will give you the all the webparts that are deployed. Now, you can keep deleting each of the webpart to find which one is causing issue ( ensure that you know to add the web parts back).
For example: if Url is http://localhost:9000/default.aspx, try with http://localhost:9000?contents=1
Alternatively, try to create a new webpart page,add web parts that are there on your actual page and check which one is causing issue. This will avoid changes to the actual page.
Hope this helps.
I've just suggested this same answer on MSDN:
This stsadm helped me in finding where the webpart was referenced in any way:
stsadm -o enumallwebs -includewebparts > C:\temp\somelog.txt
Then you can see the web part is listed under some <Web Id=... Url=...> XML node, i.e. you know the "culprit" web site.
At that point, some reasons I've found for those forgotten references:
the webpart is used in some sub-site of the culprit website, and the sub site is hidden from the quick list or top bar
the webpart has been deleted from the culprit website, but it still is in the "site collection recycle bin". You can reach that by going to the normal website recycle bin, then look for its link on the top bar description ("Use this page to restore items that..."). By the way, this site collection recycle bin has two views itself: be sure to check them both.
In both cases, I got some help by browsing the culprit website with SharePoint Manager. With that I could easily spot the existence of a forgotten subsite, as well as the existence of this "second level recycle bin".
HTH

Set the Category/group for webpart on deployment using WSPBuilder

I have developed an event handler,called TaskListEventHandler, for the Task list ((ItemAdding, ItemDeleting, ItemUpdating) as feasture using the WSP Builder project template, and I have also added a web part, called RegisterEventHandler, which will be used to bind(register) the events to a list. The webpart is WSP Builder template "Webpart without feature".
Currently, on deployment, my feature and the webpart is getting deployed sucessfully. The web part is also available in the web part gallery.
Now i need to make the web part available in a particular category/group in the gallery using the WSP Builder?
I tried setting the group in the RegisterEventHandler.webpart file (which is automatically created by WSP builder on adding the webpart template inot the project), but still it doesn't show up :(
Cannot import RegisterEventHandler Web Part.
RegisterEventHandler
This webpart is used to register or unregister the event handler to the task list - By Biju (09 Sep 2009)
Biju Webparts
Could anyone please help or suggest me some solution or sample code?
Like Per says.. if you add a webpart feature with wspbuilder it will give you an elements.xml file. This contains an entry like this:
<File Url="WPName.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="MyGroup" />
<Property Name="QuickAddGroups" Value="QuickGroup" />
</File>
Where the properties determine what group is used in the library. Mind you if this web part is already activated in your site re-activating it again wil often not overwrite the existing registration; you'll have to delete the .webpart file from the web part library first.
The category/group of a web part is specified in the elements.xml file (Groups property).
But as Janis comments it seems a little odd to add a web part to add a EventHandler.
If you just want to add the eventhandler to all tasklists on the site where you activate the feature then you can do the add in elements.xml directly.
If you want to add it to a special task list then you can do it in an FeatureReceiver.
If you want to give the enduser the option of selecting which list to add it to then a the web part might be ok, but an application page would probably be a more "SharePoint" way of doing it, or use SPEvent Handler Manager from codeplex

Using WSPBuilder to build a solution for a web part I developed

I have only ever deployed web parts from development by clicking F5. Now, I know I have to have a manifest file, feature file, etc and it all goes into a wsp file. I understand the wsp file is what gets added to Central Admin.
So my problem is this. I have found lots of sites that show how to use WSP Builder, but they don't seem to show how/where I add my web part to the WSP Builder project. My understanding is that somehow I should be able to use WSP Builder to create a wsp file containing my already-developed web part.
There are only two approaches that I see would work.
I create a WSPBuilder project (like all the how-tos on WSPBuilder show), then I assume I would somehow add my web part to that project - although I don't know how.
In my web part project, create WSPBuilder -> Build WSP. I have done this, and when I run stsadm on the resulting wsp file, I get it in Central Admin, but its not added to my Site Collection Features or my Web Part Gallery.
Can someone please explain this to me like I am a 6 year old? If you point me to another site, there is a good chance I have already seen it, so then I would ask you point me to the specific lines that tell me how to get my already existing web part packaged into the wsp.
To create a new web part feature with WSPBuilder:
Right-click on the name of your WSPBuilder project in Visual Studioand click Add, New Item.
Select WSPBuilder from the tree on the left and choose Web Part Feature from the list on the right of the dialog.
Enter the title of the web part feature and click OK.
In the dialog that appears enter the title, description and scope and click OK.
Your feature will now be created. You will then need to merge your existing web part code into this feature and configure its XML files.
Read this walkthrough by Tobias Zimmergren for more information. There is another walkthrough here.
Alex, got the right path to solve it. I think the small exception here is that wrongly spelt Add New Item instead of New Project.

Resources