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
376 views
in SharePoint Server by 3 6

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

1 like 0 dislike
by 54 119 241
selected by
 
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
by 3 6
edited by
0 0
It was so wired, and Step 4 solved my problem, thank you
If you don’t ask, the answer is always NO!
...