Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
2.9k views
in SharePoint Server by

I got this error "Error occurred in deployment step Add Solution: Operation is not valid due to the current state of the object." when deploying a SharePoint solution in SharePoint 2016.

Error occurred in deployment step 'Add Solution': Operation is not valid due to the current state of the object.

Error occurred in deployment step Add Solution Operation is not valid due to the current state of the object.


1 Answer

0 like 0 dislike
by 158 184 366
selected by anonymous
 
Best answer

To solve this error "Error occurred in deployment step Add Solution: Operation is not valid due to the current state of the object.", you have to do the following:

  1. Make sure that you have opened the Visual Studio as Administrator.
  2. The SharePoint Timer Service is running.
  3. If the above conditions are applied, try to do the following:
  4. If you are still facing this error, try to Clear the SharePoint Config cache.
  5. Again, if the issue still persists, so it means there is an issue in the Cache.ini file or one of the cache folders is completely deleted
    - So to ensure that all folders in the registry are already located in the SharePoint Config folder try to run the below cmdlets one by one

         $ConfigDbId = [Guid](Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0\Secure\ConfigDB' -Name Id).Id
         $CacheFolder = Join-Path -Path ([Environment]::GetFolderPath("CommonApplicationData")) -ChildPath "Microsoft\SharePoint\Config\$ConfigDbId"
    
    • If you get an error that refers to the path is not existing at 'C:\ProgramData\Microsoft\SharePoint\Config', so you have to manually create a new folder with the same GUID then create a new file for Cache.ini and set its content to 1.
    • Repeat the above cmdlet until making sure that all folders in the registry are already located at 'C:\ProgramData\Microsoft\SharePoint\Config' and contains Cache.ini and set its content to 1.
    • Finally, Clear the SharePoint Config cache from all SharePoint Servers using PowerShell as mentioned at Clear SharePoint Configuration Cache using PowerShell?
  6. Go back to deploy your solution that should be deployed successfully without getting this error "Error occurred in deployment step Add Solution: Operation is not valid due to the current state of the object."
    Sharepoint 2019 Error occurred in deployment step Add Solution Operation is not valid due to the current state of the object

Note: In case, you got this error in SharePoint Event Receiver, and you have followed this issue even after applying the above instructions, so the issue is mainly related to your code, but Initially, don't use configuration manage for connection string instead use "AppKey", and avoid having _ (underscore) in your event name.

by
edited by anonymous
0 0
It was so wired, and Step 4 solved my problem, thank you
If you don’t ask, the answer is always NO!
...