Question

I have a package with some Application Pages (in Layouts Folder) and a Feature which contains some WebParts. I tought the Layouts contents are copied first to SharePoint, then the WebParts from the Feature and then the Feature Receiver fires. At least it Looks like it in Visual Studio because the Layouts Folder is always at the topmost postition. But when I try to modify the Pages in the Feature Receiver it throws an file does not exist Exception. The Urls are correct and if I modify an existing Page it also works.

What do I have to do to have my Receiver firing after all the Layouts content is deployed?

Was it helpful?

Solution

The deployment/activation process contains a lot of steps (even though VS tries to make it look like one):

  1. When WSP is added to the farm it's stored in the configuration database
  2. When the solution is deployed a lot of things happen on each server in the Farm
    2.1 The server gets the WSP from the configuration database
    2.2 The files from mapped folders (like layout pages) are copied into the right location in the file system
    2.3 The DLLs are added to the GAC (or bin folder)
    2.4 SafeControl entries is added to the web.config of WebApplications
    2.5 The FeatureInstalled event is triggered
  3. When the Feature is activated
    3.1 Declarative elements like files from <Module> elements (like your .webpart files) are added
    3.2 The FeatureActivated event is triggered

All of this is happening when you choose deploy from VS (plus a lot of uninstalling) with the default deployment configuration. But the order is still as above.

So the files in _layouts or SharePointRoot/TEMPLATE/LAYOUTS are in place before your events fire.

But you mention that you try to modify the LAYOUTS files in the Feature Receiver. This is not something you should do. Files in SharePointRoot should not be modified.

OTHER TIPS

You can use the "No activation Deployment Configuration" which will assist you in debugging Feature Receivers. Using the No activation configuration you would deploy your Package to SharePoint, go to Features page, activate your Feature and debug the Feature Receiver.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top