Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have built a simple Silverlight control and a WebPart to go with it. This is my first SharePoint project and I was very confused most of the time (I.e. I am a Sharepoint noob) :-)

The Silverlight Control and the webPart live in a sandboxed solution. After deletion of this solution both are still available in Sharepoint. I gathered this is normal...

I found one how-to on removing files which were provisioned (can't remember the url) but this solution didn't work - I think that was due to the fact that the solution was intended for full-trust-solutions whereas I am using a sandboxed solution.

Any good hint on how I would remove the files of the solution upon deletion of the solution?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This should be pretty straight forward. You must be deploying the XAP file to a particular list or library and then the Silverlight Web Part must be accessing that XAP file from there correct?

You can add a Feature Receiver to your Feature and then put your deletion code in the FeatureDeactivating method of a Feature Receiver.

Just remember that after your XAP file is stored in a list or library, it is just another list item. So you can write code similar to this:

SPList list = currentWeb.Lists["Your List Name"];
foreach(SPListItem item in list.Items)
{
   if(item.Title == "Your XAP file Name")
   {
     item.Delete()
   }
}

(This code is not at all performance optimized. Just used for giving example.)

UPDATE: If you have deployed your XAP file to a folder, try this code in your Feature Deactivation method:

SPFile file = currentWeb.GetFile("MySilverlightWebPart/MyControl.xap");
file.Delete();
share|improve this answer
    
Did I mention I'm a Sharepoint-Noob ;-) I have an Elements.xml that deploys my xap into a folder like <File Path="MySilverlightControl\MyControl.xap" Url="MySilverlightWebPart/MyControl.xap" Type="GhostableInLibrary" />. Does this create a list (or is what I call folder actually a list?) –  Nils Feb 23 '12 at 7:30
    
check out the update to my answer. –  Vardhaman Deshpande Feb 23 '12 at 11:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.