At the beginning of your FeatureActivated method, put this line of code :
System.Diagnostics.Debugger.Break();
Then, try to activate the feature. This will popup an "exception" window that let you to attach the debugger of your choice.
After attaching, your code will be pause at this line, and you will be able to walk into your code to find the issue.
[Edit] concerning your comments
The event receivers run asynchronously (at least by default). They are not fired under the http request lifecycle, that's why the SPContext.Current property return null. SPContext.Current is wrapper around the HttpContext.Current value (which is null in this case).
Instead, you can use SPFeatureReceiverProperties.Feature.Parent Property to get the SPWeb, SPSite, SPWebApplicaiton or SPFarm object (depending on the scope of the feature).
I've written a small utility class that can help to extract the useful properties :
/// <summary>
/// Provides methods for faciliting feature manipulations / eventing
/// </summary>
public static class FeatureUtilities
{
/// <summary>
/// Build a context to be used from <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureActivated(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> and
/// <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureDeactivating(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> handler
/// of a <see cref="SPFeatureReceiver"/> object and run a code within this context.
/// </summary>
/// <param name="properties">The feature activated/deactivation properties.</param>
/// <param name="code">Code to run contextualized.</param>
/// <remarks>This method will explorer the properties object to populate the four objects : <see cref="SPWeb"/>,
/// <see cref="SPSite"/>, <see cref="SPWebApplication"/> and <see cref="SPFarm"/>. After the call to <c>code</c> delegate
/// the <c>site</c> and <c>web</c> objects are disposed</remarks>
/// <example>
/// <![CDATA[
/// public override void FeatureActivated(SPFeatureReceiverProperties properties)
/// {
/// properties.RunContextualized((web, site, app, farm) =>
/// {
/// DoSomething(web,site);
/// });
/// }
/// ]]>
/// </example>
/// <exception cref="ArgumentNullException"><c>properties</c> or <c>code</c> is null</exception>
/// <exception cref="ArgumentException"><c>properties.Feature</c> is null. This is often due to the call of this method
/// in the Installed or Uninstalled event of the <see cref="SPFeatureReceiver"/>.</exception>
public static void RunContextualized(SPFeatureReceiverProperties properties, Action<SPWeb, SPSite, SPWebApplication, SPFarm> code)
{
if (properties == null) throw new ArgumentNullException("properties");
if (code == null) throw new ArgumentNullException("code");
if (properties.Feature == null) throw new ArgumentException("properties.Feature is null. Maybe you are not in the FeatureActivated/FeatureDeactivating methods ?");
var web = properties.Feature.Parent as SPWeb;
var site = properties.Feature.Parent as SPSite;
var app = properties.Feature.Parent as SPWebApplication;
var farm = properties.Feature.Parent as SPFarm;
if (web != null)
{
site = web.Site;
app = site.WebApplication;
farm = app.Farm;
}
else if (site != null)
{
web = site.RootWeb;
app = site.WebApplication;
farm = app.Farm;
}
else if (app != null)
{
farm = app.Farm;
}
using (site)
{
using (web)
{
code(web, site, app, farm);
}
}
}
/// <summary>
/// Build a context to be used from <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureActivated(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> and
/// <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureDeactivating(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> handler
/// of a <see cref="SPFeatureReceiver"/> object and run a code within this context.
/// </summary>
/// <param name="properties">The feature activated/deactivation properties.</param>
/// <param name="code">Code to run contextualized.</param>
/// <remarks>This method will explorer the properties object to populate the three objects : <see cref="SPWeb"/>,
/// <see cref="SPSite"/> and <see cref="SPWebApplication"/>. After the call to <c>code</c> delegate
/// the <c>site</c> and <c>web</c> objects are disposed</remarks>
/// <example>
/// <![CDATA[
/// public override void FeatureActivated(SPFeatureReceiverProperties properties)
/// {
/// properties.RunContextualized((web, site, app, farm) =>
/// {
/// DoSomething(web,site);
/// });
/// }
/// ]]>
/// </example>
/// <exception cref="ArgumentNullException"><c>properties</c> or <c>code</c> is null</exception>
/// <exception cref="ArgumentException"><c>properties.Feature</c> is null. This is often due to the call of this method
/// in the Installed or Uninstalled event of the <see cref="SPFeatureReceiver"/>.</exception>
public static void RunContextualized(SPFeatureReceiverProperties properties, Action<SPWeb, SPSite, SPWebApplication> code)
{
RunContextualized(properties, (web, site, app, farm) => code(web, site, app));
}
/// <summary>
/// Build a context to be used from <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureActivated(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> and
/// <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureDeactivating(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> handler
/// of a <see cref="SPFeatureReceiver"/> object and run a code within this context.
/// </summary>
/// <param name="properties">The feature activated/deactivation properties.</param>
/// <param name="code">Code to run contextualized.</param>
/// <remarks>This method will explorer the properties object to populate both <see cref="SPWeb"/> and
/// <see cref="SPSite"/> objects. After the call to <c>code</c> delegate
/// the <c>site</c> and <c>web</c> objects are disposed</remarks>
/// <example>
/// <![CDATA[
/// public override void FeatureActivated(SPFeatureReceiverProperties properties)
/// {
/// properties.RunContextualized((web, site, app, farm) =>
/// {
/// DoSomething(web,site);
/// });
/// }
/// ]]>
/// </example>
/// <exception cref="ArgumentNullException"><c>properties</c> or <c>code</c> is null</exception>
/// <exception cref="ArgumentException"><c>properties.Feature</c> is null. This is often due to the call of this method
/// in the Installed or Uninstalled event of the <see cref="SPFeatureReceiver"/>.</exception>
public static void RunContextualized(SPFeatureReceiverProperties properties, Action<SPWeb, SPSite> code)
{
RunContextualized(properties, (web, site, app, farm) => code(web, site));
}
}
And the corresponding extension methods :
/// <summary>
/// Provides extentions methods for faciliting feature manipulations / eventing
/// </summary>
public static class SPFeatureReceiverPropertiesExtensions
{
/// <summary>
/// Build a context to be used from <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureActivated(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> and
/// <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureDeactivating(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> handler
/// of a <see cref="SPFeatureReceiver"/> object and run a code within this context.
/// </summary>
/// <param name="properties">The feature activated/deactivation properties.</param>
/// <param name="code">Code to run contextualized.</param>
/// <remarks>This method will explorer the properties object to populate the four objects : <see cref="SPWeb"/>,
/// <see cref="SPSite"/>, <see cref="SPWebApplication"/> and <see cref="SPFarm"/>. After the call to <c>code</c> delegate
/// the <c>site</c> and <c>web</c> objects are disposed</remarks>
/// <example>
/// <![CDATA[
/// public override void FeatureActivated(SPFeatureReceiverProperties properties)
/// {
/// properties.RunContextualized((web, site, app, farm) =>
/// {
/// DoSomething(web,site);
/// });
/// }
/// ]]>
/// </example>
/// <exception cref="ArgumentNullException"><c>properties</c> or <c>code</c> is null</exception>
/// <exception cref="ArgumentException"><c>properties.Feature</c> is null. This is often due to the call of this method
/// in the Installed or Uninstalled event of the <see cref="SPFeatureReceiver"/>.</exception>
public static void RunContextualized(this SPFeatureReceiverProperties properties, Action<SPWeb, SPSite, SPWebApplication, SPFarm> code)
{
FeatureUtilities.RunContextualized(properties, code);
}
/// <summary>
/// Build a context to be used from <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureActivated(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> and
/// <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureDeactivating(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> handler
/// of a <see cref="SPFeatureReceiver"/> object and run a code within this context.
/// </summary>
/// <param name="properties">The feature activated/deactivation properties.</param>
/// <param name="code">Code to run contextualized.</param>
/// <remarks>This method will explorer the properties object to populate the three objects : <see cref="SPWeb"/>,
/// <see cref="SPSite"/> and <see cref="SPWebApplication"/>. After the call to <c>code</c> delegate
/// the <c>site</c> and <c>web</c> objects are disposed</remarks>
/// <example>
/// <![CDATA[
/// public override void FeatureActivated(SPFeatureReceiverProperties properties)
/// {
/// properties.RunContextualized((web, site, app, farm) =>
/// {
/// DoSomething(web,site);
/// });
/// }
/// ]]>
/// </example>
/// <exception cref="ArgumentNullException"><c>properties</c> or <c>code</c> is null</exception>
/// <exception cref="ArgumentException"><c>properties.Feature</c> is null. This is often due to the call of this method
/// in the Installed or Uninstalled event of the <see cref="SPFeatureReceiver"/>.</exception>
public static void RunContextualized(this SPFeatureReceiverProperties properties, Action<SPWeb, SPSite, SPWebApplication> code)
{
FeatureUtilities.RunContextualized(properties, code);
}
/// <summary>
/// Build a context to be used from <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureActivated(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> and
/// <see cref="Microsoft.SharePoint.SPFeatureReceiver.FeatureDeactivating(Microsoft.SharePoint.SPFeatureReceiverProperties)"/> handler
/// of a <see cref="SPFeatureReceiver"/> object and run a code within this context.
/// </summary>
/// <param name="properties">The feature activated/deactivation properties.</param>
/// <param name="code">Code to run contextualized.</param>
/// <remarks>This method will explorer the properties object to populate both <see cref="SPWeb"/> and
/// <see cref="SPSite"/> objects. After the call to <c>code</c> delegate
/// the <c>site</c> and <c>web</c> objects are disposed</remarks>
/// <example>
/// <![CDATA[
/// public override void FeatureActivated(SPFeatureReceiverProperties properties)
/// {
/// properties.RunContextualized((web, site, app, farm) =>
/// {
/// DoSomething(web,site);
/// });
/// }
/// ]]>
/// </example>
/// <exception cref="ArgumentNullException"><c>properties</c> or <c>code</c> is null</exception>
/// <exception cref="ArgumentException"><c>properties.Feature</c> is null. This is often due to the call of this method
/// in the Installed or Uninstalled event of the <see cref="SPFeatureReceiver"/>.</exception>
public static void RunContextualized(this SPFeatureReceiverProperties properties, Action<SPWeb, SPSite> code)
{
FeatureUtilities.RunContextualized(properties, code);
}
The usage of this class is :
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
properties.RunContextualized((web, site) =>
{
DoSomething(web,site);
});
}
This simplifies the process of analyzing the feature context.