0

Is there a way to provision service applications using c# ? Can anyone code to provision any one of the following service applications in a single standalone setup.

  1. Search Service Application
  2. Managed MetaData Application
  3. UserProfile Application.

There are ways doing with PowerShell, but what if it comes to the native SharePoint API?

  • Should we delete your previous, very similar question, and focus on this one? – Robert Lindgren May 30 '14 at 6:56
  • If someone could Answer this question,yes,you can delete the previous questions. – kranthi May 30 '14 at 7:23
0

While it is possible, I wouldn't recommend it. The issue is that there are no public-facing methods to call from C# to do this. You would need to use a reflection tool (i.e. dotPeek or .NET Reflector) to get the internal methods to create the service applications. For instance, you could reflect the Microsoft.SharePoint.PowerShell assembly to view how the Cmdlet does the work. Once you have the code, you would have to use reflection to get and invoke the methods from your code. The bad thing here is that the code can change from update to update (cumulative updates often change internal methods, etc.).

I would recommend a different approach: run the Cmdlets from your C# code. There are a number of examples on the web, this one should be enough to get you started: http://www.codeproject.com/Articles/18229/How-to-run-PowerShell-scripts-from-C.

  • Thank you @John , but while i was running the script from the link you mentioned got the error "Cannot index into null array" at Collection<psobject /> results = pipeline.Invoke(); – kranthi Jun 3 '14 at 9:40
  • Looks like that is a typo, just change it to: var results = pipeline.Invoke(); – John Chapman Jun 3 '14 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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