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 invalidly hooked feature reciever. Feature has two configuration files The first, SharePoint looks like this:

< feature xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" Id="94bb0bbe-ba87-4ff4-accd-6cd429b337ad" featureId="94bb0bbe-ba87-4ff4-accd-6cd429b337ad" imageUrl="" solutionId="00000000-0000-0000-0000-000000000000" title="Alokacie" version="" deploymentPath="$SharePoint.Project.FileNameWithoutExtension$_$SharePoint.Feature.FileNameWithoutExtension$" xmlns="http://schemas.microsoft.com/VisualStudio/2008/SharePointTools/FeatureModel">
  < projectItems>
    < projectItemReference itemId="84752a89-37b6-401d-9353-034b10f3671c" />
    < projectItemReference itemId="c829a4dc-2469-4ab5-a3e1-4a3bfce1c552" />
  < /projectItems>
< /feature>

and the second one, feature template:

< Feature ReceiverAssembly="FeatureBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cf0c34879675fa15" ReceiverClass="FeatureBuilder.FeatureReciever" xmlns="http://schemas.microsoft.com/sharepoint/">
< /Feature>

When I try to register eventhandler in the first one (feature file) nothing happend. Even in SharePointManager are empty properties: ReceiverAssembly, ReceiverClass. Now I'm able to deploy without problems. When I register eventhandler in the second one, as you can see above, SharePointManager after failed deployment shows that ReceiverAssembly and Class is what I expect. But deployment fails due to error:

"Error occurred in deployment step 'Activate Features': Expression must evaluate to a node-set."

Receiver method:

        System.Diagnostics.Debugger.Launch();
        var service = SPWebService.ContentService;
        var myModification = new SPWebConfigModification();
        myModification.Path = "configuration/AplikaceRoly";
        myModification.Name = "add[@name=Name]";
        myModification.Sequence = 0;
        myModification.Owner = "NESS";
        myModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
        myModification.Value = "<add key='sth' value='Sth'/>";
        service.WebConfigModifications.Add(myModification);

        service.ApplyWebConfigModifications();
        service.Update();

When I remove ReceiverClass nad ReceiverAssembly attributes I can deploy without problems again.

Have somebody idea what's wrong? I can't find simmilar problems on google.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Does configuration/AplikaceRoly exist?

Otherwise you need to create if before your child node:

var myModification1 = new SPWebConfigModification("AplikaceRoly", "configuration");
myModification1.Value = "AplikaceRoly";
myModification1.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureSection;
myModification1.Sequence = 0;
webApp.WebConfigModifications.Add(myModification1);
share|improve this answer
    
yes, it exists. Even when I let this method empty, I'm still getting this error => I guess it has nothing with receiver. Just when I add attribute ReceiverClass , ReceiverAssembly , deployment fails with this error. –  Peter P May 16 '12 at 15:55
    
How do you deploy? If from PowerShell/VS remember to exit/relaunch it whenever you change a FeatureReceiver dll. –  Per Jakobsen May 16 '12 at 16:36
    
Oh yeah, bless you man. So that means, this part of code "myModification.Path = "configuration/AplikaceRoly";" is problem. But I'm sure that this node exists there. I've tried with XPath online tester , and it found that node. On the other side, I was testing web config in target server in %RootDrive%\inetpub\wwwroot\wss\VirtualDirectories\80\web.config ... Application uses this web.config but I'm pretty not sure whether code above is changing this config... –  Peter P May 17 '12 at 6:51

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.