locked
How to convert SandBox Solution to Farm Solution? RRS feed

  • Question

  • Hi All,

            I was converting sandbox solution to farm solution by changing webpart property "Sandboxed Solution" to False in visual studio 2012. Few webparts were working fine after conversion but few were generating error at the time of adding webpart to a page i.e. "object reference not set to an instance" and few were showing partial data. I have already tried many links but no success yet.

    Monday, January 19, 2015 6:02 AM

Answers

  • Hi,

    This happen when you changing the solution type in Visual studio, 

    That means your webpart has been uninstalled successfully on your site which you used to deploy as sandbox solution earlier.

    To reattach the webpart as Farm solution follow these steps.

    To resolve this problem, open the "feature" in design mode and ensure the web part been part of the webapplication scope. If not add the webpart from left hand side to right hand side to ensure its part of the "Package".

    To double check this,You can also open the Package designer in code mode to see the your webpart is part of the "manifest.xml".


    Murugesa Pandian. | MCPD | MCTS - Configure |SharePoint 2010

    Monday, January 19, 2015 8:17 AM
  • With Sandbox solution, it might be the case that the CAS policy allowing the code to run to fetch data from user profile service.

    As we are converting it to farm solution, we do require to put such code routine with SPSecurity.RunWithElevatedPReveledge routine and confirm that your pool user do have access on these service application. 

    It;s just an opinion which can be try out.


    Regards, Dharnendra Shah, MCTS,MCPD - Sharepoint 2010 Application Development Blog: http://ds-sharepoint2010blogs.blogspot.in/ Email: shahdg2003@gmail.com

    • Marked as answer by Patrick_Liang Saturday, January 31, 2015 5:51 AM
    Monday, January 19, 2015 11:19 AM
  • Hi,

    If you want to convert Sandboxed Solution to Farm Solution in SharePoint. Please try to do as follows:

    1. Delete your Sandboxed solution using PowerShell.

    $url = "http://spdev"
    Uninstall-SPUserSolution -Identity MySolution.wsp -Site $url
    Remove-SPUserSolution -Identity MySolution.wsp -Site $url
    
    

    2. Delete WebParts from site. Go to Web Parts collection list.http://spdev/mysite/_catalogs/wp/Forms/AllItems.aspx and delete all the webparts which your solution contains. If you don’t do it, you won’t be able to use your webparts because they won’t be updated.

    3. Add and deploy your farm solution.

    Add-SPSolution -LiteralPath D:\Solutions\MySolution\MySolution.wsp
    Install-SPSolution –Identity MySolution.wsp –GACDeployment –force
    
    

    More information is here:

    http://markimarta.com/sharepoint/convert-sandboxed-solution-to-farm-solution-in-sharepoint/

    Best Regards


    Dennis Guo
    TechNet Community Support

    • Proposed as answer by Patrick_Liang Wednesday, January 28, 2015 1:52 AM
    • Marked as answer by Patrick_Liang Saturday, January 31, 2015 5:51 AM
    Tuesday, January 20, 2015 7:05 AM

All replies

  • Hi,

    Can you please check ULS log entries at the time of adding webpart to page?If might give more details to solve the issue.

    Thanks,

    Avni Bhatt


    If this helped you resolve your issue, please mark it Answered

    Monday, January 19, 2015 6:32 AM
  • I was going trough the logs, I found following information:

    01/19/2015 12:06:01.02  OWSTIMER.EXE (0x5335C)                   0x5565C SharePoint Portal Server       User Profiles                  b3w8 High     User Profile Application: SynchronizeMIIS encounters an exception: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.Office.Server.UserProfiles.UserProfileImportJob.<>c__DisplayClass2.<IsTimerJobRunning>b__1()     at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.<RunWithElevatedPrivileges>b__3()     at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)     at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)     at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)     at Microsoft.Office.Server.UserProfiles.UserProfileImportJob.IsTimerJobRunning(UserProfileApplicationJob timerJob)     at Microsoft.Office.Server.... 4931e19c-1007-d0f4-9e9f-8a81f4dc77c7
    01/19/2015 12:06:01.02* OWSTIMER.EXE (0x5335C)                   0x5565C SharePoint Portal Server       User Profiles                  b3w8 High     ...Administration.UserProfileApplication.SynchronizeMIIS()     at Microsoft.Office.Server.Administration.ILMProfileSynchronizationJob.Execute() 4931e19c-1007-d0f4-9e9f-8a81f4dc77c7               


    • Edited by _ShashanK_ Monday, January 19, 2015 6:50 AM
    Monday, January 19, 2015 6:49 AM
  • H,

    Can you please confirm if user profile synchronization service started?

    Make sure the UserProfileService and UserProfileServiceSynchronization services are started on the server running the sync (Central Admin -> Application Management -> Manage Services on Server)

    Thanks, 

    Avni Bhatt


    If this helped you resolve your issue, please mark it Answered

    Monday, January 19, 2015 6:59 AM
  • Yes...Both services are in "Started" status.

    User Profile Service Started Stop
    User Profile Synchronization Service Started Stop

    Monday, January 19, 2015 7:16 AM
  • Hi,

    This happen when you changing the solution type in Visual studio, 

    That means your webpart has been uninstalled successfully on your site which you used to deploy as sandbox solution earlier.

    To reattach the webpart as Farm solution follow these steps.

    To resolve this problem, open the "feature" in design mode and ensure the web part been part of the webapplication scope. If not add the webpart from left hand side to right hand side to ensure its part of the "Package".

    To double check this,You can also open the Package designer in code mode to see the your webpart is part of the "manifest.xml".


    Murugesa Pandian. | MCPD | MCTS - Configure |SharePoint 2010

    Monday, January 19, 2015 8:17 AM
  • check whtehter youa re using object without creating refernce of it object a=new object()

    check uls logs

    Monday, January 19, 2015 9:55 AM
  • With Sandbox solution, it might be the case that the CAS policy allowing the code to run to fetch data from user profile service.

    As we are converting it to farm solution, we do require to put such code routine with SPSecurity.RunWithElevatedPReveledge routine and confirm that your pool user do have access on these service application. 

    It;s just an opinion which can be try out.


    Regards, Dharnendra Shah, MCTS,MCPD - Sharepoint 2010 Application Development Blog: http://ds-sharepoint2010blogs.blogspot.in/ Email: shahdg2003@gmail.com

    • Marked as answer by Patrick_Liang Saturday, January 31, 2015 5:51 AM
    Monday, January 19, 2015 11:19 AM
  • Hi,

    If you want to convert Sandboxed Solution to Farm Solution in SharePoint. Please try to do as follows:

    1. Delete your Sandboxed solution using PowerShell.

    $url = "http://spdev"
    Uninstall-SPUserSolution -Identity MySolution.wsp -Site $url
    Remove-SPUserSolution -Identity MySolution.wsp -Site $url
    
    

    2. Delete WebParts from site. Go to Web Parts collection list.http://spdev/mysite/_catalogs/wp/Forms/AllItems.aspx and delete all the webparts which your solution contains. If you don’t do it, you won’t be able to use your webparts because they won’t be updated.

    3. Add and deploy your farm solution.

    Add-SPSolution -LiteralPath D:\Solutions\MySolution\MySolution.wsp
    Install-SPSolution –Identity MySolution.wsp –GACDeployment –force
    
    

    More information is here:

    http://markimarta.com/sharepoint/convert-sandboxed-solution-to-farm-solution-in-sharepoint/

    Best Regards


    Dennis Guo
    TechNet Community Support

    • Proposed as answer by Patrick_Liang Wednesday, January 28, 2015 1:52 AM
    • Marked as answer by Patrick_Liang Saturday, January 31, 2015 5:51 AM
    Tuesday, January 20, 2015 7:05 AM