SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to find a way how to update a SharePoint solution programmatically with C#. (I already know how to do this with the powershell command Update-SPSolution).

I have tried using this code but it doesn't work:

SPSolution sol = SPFarm.Local.Solutions[name]; //name = mytest.wsp
sol.Upgrade(filePath); //C:\mytest.wsp

Can anyone provide some guidance?

share|improve this question
How is it not working? What is your Farm topology? (Number of front ends etc.) If it is a multi front-end farm try to use the Upgrade overload with a DateTime parameter to schedule a TimerJob, this will execute on all Web servicers.… – Robert Lindgren Jul 4 '13 at 10:25
what do you mean by "it doesn't work" you must get some kind of error, try using ULS Viewer to capture error if nothing comes up in event receiver – Muhammad Raja Jul 4 '13 at 13:29
At the moment it is a Dev-Server with all components (MSSQL, Front-End) on one system. – AHO Jul 8 '13 at 7:17
"It doesn't work" means that nothing happens :-( – AHO Jul 8 '13 at 7:19

You are using the correct code (see When I do this, I usually specify DateTime.Now for the second parameter. This code schedules a deployment job the same way the Update-SPSolution Cmdlet does.

What I would suggest is to run this code and then immediately refresh the Farm Solutions page to see if there is a change in status. Additionally you could use this PowerShell to see if a deployment job exists:

Get-SPTimerJob | Where-Object { $_.Name -Match "solution-deploy" }

Additionally you can check the solution itself for an existing job:

(Get-SPSolution solution.wsp).JobExists

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.