Unable to add selected webpart after uninstall

May 15, 2012 at 12:40 AM


I created webpart using wspbuilder(x86, Win7, WSS3.0 - but same thing and in Win 2008 web developer and wss 3.0)

  • I build solution in debug
  • Created WSP
  • Deployed

Cool, it works.

  • Next I uninstalled via WSPBuilder-> Uninstall.
  • And deleted this webpart xml from Webpart Gallery.
  • made iisreset(think no need but I made)
  • Rebuilded solution in release, recreated WSP and redeployed.

In Site Features this Feature is already activated(why?). Deactivated it, and activated second time. When I add this webpart in edit mode I get error

Unable to add selected web part(s).
***my feature **: Cannot import ***my feature ** Web Part.

And now the only thing I can is to recreate feature wuth new name. But I don't think it will be deployable only first time..

How to redeploy correctly?

May 15, 2012 at 1:17 PM

It is strange, but I can't do nothing but rebuild project with another name.. I alreday tried to deactivate/retract/delete solution manually, and using STSADM with cmd like this:

SET stsadmDir=%commonprogramfiles%\Microsoft Shared\web server extensions\12\BIN
SET feature=MyFeature

REM Unistall solution
"%stsadmDir%\stsadm.exe" -o deactivatefeature -name %feature% -url http://localhost
"%stsadmDir%\stsadm.exe" -o uninstallfeature -name %feature% -force

SET solution=MyFeature.wsp
REM Undeploy solution on the local server
"%stsadmDir%\stsadm.exe" -o retractsolution -name %solution% -url http://localhost -immediate

"%stsadmDir%\stsadm.exe" -o execadmsvcjobs

"%stsadmDir%\stsadm.exe" -o deletesolution -name %solution%




But no result! It is like there remains some "garbage" that was not unistalled correctly. I can deploy feature only first time..(

Best regards

May 15, 2012 at 8:34 PM

We fight till the end! :-)

After 2 days of sex with sharepoint I resolved :) on stackoverflow one guy posted comment that become answer. 

All with permission levels, web.config and etc is right. The reason was that I had some code in my webpart constructor. Constructor is called by WebPartImporter during addition to page. In my case I get SPContext in constructor and it seems to be a problem. So like in post I moved code from my constructor to OnInit method of Page and webpart now could be succesfully added.

p.s.: sorry for bad english. :)