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 created a web template in visual studio, it includes the standard element file and onet file, it also has a feature which is scoped to site level.

All this works fine, i can deploy it and can create a subsite based of this template.

I now want to add some code that creates lists etc when the sub site is created (lists are for sub site only).

How would i do this? I have tried adding another feature to the project which is scoped to web and putting code in this but i get the following error:

"Error occurred in deployment step 'Activate Features': Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred."

share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted

It looks like you use a sandbox solution to solve you issue. But I don't undestand how can it be, because you can not creaate web template as sandbox. I think that you created another project that is contains a new feature. if it is ture, you should select this project and set sandboxed solution property to false in properties window.

share|improve this answer
add comment

Try the SPWebEventReceiver class. This event should fire when a web is created.

public class WebProvisionedEventReceiver : SPWebEventReceiver
{
    public override void WebProvisioned(SPWebEventProperties properties) 
    {
        try
        {
            using (SPWeb web = (SPWeb)properties.Web)
            {
share|improve this answer
add comment

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.