0

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?

1 Answer 1

1

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();
2
  • 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
    Commented Feb 23, 2012 at 7:30
  • check out the update to my answer. Commented Feb 23, 2012 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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