I have a WinForms project that acts as a Sharepoint 2013 Solution installer. It basically do some checking, create a sql database, adds and install a SP Solution and finally activates the feature.
The feature is scoped to "Site Collection" and the code to activate it is the following:
SPFeature feature = siteCollection.Features.Add(featureId.Value, true);
In some environments this works well. But in others this throws the following exception:
Feature with Id 'guid' is not installed in this farm, and cannot be added to this scope.
I've searched this exception and found some solutions that doesn't apply to my case.