Hot answers tagged visual-web-part
No, there is no way to deploy a solution to a particular site collection. A solution is deployed either Globally to all web applications or a single web application. It is the feature inside the solution which can be deployed to a farm/webapplication/site collection/web.
Usually you deploy your farm solution to web application, but you activate solution's feature(s) only on desired site collection.
You should get the current site collection rootweb url as below String siteUrl = SPContext.Current.Site.RootWeb.Url;
Only top voted, non community-wiki answers of a minimum length are eligible