0

My application has 3 sharepoint parts:

  1. a Administration page to configure the application
  2. a timer job and
  3. a webpart to view data from the application

I built them all into the same feature. When I run the solution from VS 2010, it takes me to the Server settings page and everything works fine. I can access both the admin page and add the webpart to a page.

If I switch to the regular sharepoint page, I can see my webpart listed, but I can't add it to the page. I get an error saying it can't find it or something.

I'm guessing that's because I set the scope of my feature to be Site instead of farm.

So...here's the question. What is the best way to architect this?

I would like to webpart to be available to all the pages in the WebApplication since my product is deals with the web application.

Just mark my feature as Farm wide?
Pull the webpart out of the feature into it's own project?

I want to keep it easy to deploy if possible.

2
  • I tried changing the scope to either webapplication or farm. Got a error saying my project items couldn't be deployed through a feature with a 'farm' scope.
    – user2062
    Commented Jan 31, 2011 at 16:40
  • I tried activate the feature with Enable-SPFeature and got an error saying that it is already activated. "The error I get when I try to add the web part to the page is: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type is not registered as safe." Which is weird since I see the DLL in the GAC. <sign>
    – user2062
    Commented Jan 31, 2011 at 16:58

1 Answer 1

0

I would put them into separate features but within the same project. TimerJob at the WebApplication level, Admin page & Webpart at the site level.

Your problem regarding the GAC is that it hasn't been registered as a Safe Control. Go check your Package.package file (look at the Manifest tab). If the safecontrol entries aren't in your web.config, the solution isn't deploying correctly.

7
  • So basically, you suggest a feature for each 'Part' of the application...ok that makes sense. Thank you. The manifest is fine and my control is listed as a safe control in the web.config of the 'Administration' page (win2008x64:33314) but it's not in the safe control list of the non-admin page (win2008x64). When I try to do 'Enable-SPFeature MyFeature -URL Win2008x64' I get: 'Feature MyFeature is already activated at scope 'Win2008x64' I'm sure that I could modify the web.config directly, but certainly would rather not do that.
    – user2062
    Commented Jan 31, 2011 at 19:31
  • Definitely don't directly modify the web.config directly. It might work for a single-server farm, but it's not a scalable approach. I mistakenly thought your config page was deployed into the win2008x64:80 rather than CA. If you need the aspx deployed as farm feature (to go into central admin) and then the other to go in as a site collection feature you might consider to wsp files. Alternatively have you installed the solution in the target web app (Install-SPSolution)? Commented Jan 31, 2011 at 21:01
  • Thank you Neil, you've been very helpful. :) I was hoping for a way to install the solution once and have the webpart available to all the sites in the web application. I have a WSP file, I'll try using it.
    – user2062
    Commented Jan 31, 2011 at 22:53
  • You can still have it, its about where you want the package to run and then activate the features. If you dont do an "Install-SPSolution -webapplication win2008x64" then the web.config for that webapp won't register your safe control which is what you're seeing. Does the config page really need to be in CA or is it something that you can expose to Site Collection Admins. Commented Jan 31, 2011 at 23:49
  • Yeah, I think it does need to be there. The SharePoint admin is the only one what should be configuring it. The only way I could get the Install-SPSolution call to work was to do 'Install-SPSolution spsure.wsp -AllWebApplications -GACDeployment'. When I did that I ended with 2 timer jobs (sort of expected that) and no admin page on the CA.
    – user2062
    Commented Feb 1, 2011 at 1:08

Your Answer

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