How does sharepoint resolve feature.xml file? - sharepoint

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.

Related

Custom master page not refreshing upon deployment in Sharepoint 2010 Foundation

I use VS2010 on Server 2008 R2 with Sharepoint 2010 Foundation.
I have created a custom master page following instructions from here: http://msdn.microsoft.com/en-us/library/gg447066.aspx (activating my custom page as feature), and was delighted with the results. But as soon as I changed the images and attempted to deploy them through VS2010, I noticed that my changes were not showing in the page (which was still showing the old images).
Useful observations:
It's a Sandboxed solution.
I checked that wsp is built with the new images, and so it was.
When I retract my solution, I also go to Master Page Gallery, and
delete my custom master page from there to make sure I start from
scratch. No difference.
My SP Designer does not give me an option to "revert to site
definition".
My "Look and Feel" section in central admin does not offer a
"reset to site definition" option.
Checking "CustomizedPageStatus" property of the SPFile for my master page shows that it's set to "none", and indeed, calling RevertContentStream throws an exception. This indicates it may not necessarily be the unghosting issue.
Does anybody know where my images get deployed to, and what the cause of this problem may be? The "Deployment Location" property does not lead to the correct location (in fact, I can't even see my Feature's folder). Could it be something to do with the way variables in the path - {SharePointRoot}\Template\Features{FeatureName}\StyleLibrary\Branding101\Images\ - are parsed?
I am new to Sharepoint, so all and any help would be much appreciated.
Since this is a Sandboxed solution, everything gets stored in the content database, accessible through SharePoint Designer 2010. In SP Designer, open the site you are working on, then look under "All Files" in Site Objects: that's where I found my masterpages, images, etc.
Deployment paths (displayed in module properties in VS2010) are just red herring, as no deployment to the file system itself takes place. Hope this helps somebody else!

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

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.

Modifying a SharePoint Site Template's manifest.xml

I am trying to manually code some changes into my SharePoint Site Template. I can get the stp/cab file open and have added a new Element to the manifest.xml file, but when I repackage the stp and load it onto the server - the new site that I create using the updated .stp does not reflect the new link that I have added to the manifest.xml
I realize this isn't the proper way to add a link to the sidebar but am interested to make it work this way, for other reasons.
I've never been able to get modifications of STP files to work correctly. The combination of complexity in the STP file and that the solution is very unlikely to be supported by Microsoft means this is going to be a tough road.
You really should look at using a feature-based approach to do this (just web search 'sharepoint feature' for more info). This will give the benefit of not having to hack STP files and being 100% supported by MS and the rest of the SharePoint community.
Perhaps you could update your question with the other reasons you'd like to do this?

Deploying New Web Parts

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.

Resources