Search This Blog

Monday 23 July 2012

Error occurred in deployment step ‘Activate Features’: Object reference not set to an instance of an object.


Do you get this error while deploying solution with a Feature Event Receiver through Visual Studio 2010. Well, I did while deploying a custom timer job solution which has a feature receiver to activate and deactivate the timer job feature.






Somewhere I got to know this error occurs if we have used SPContext class in our feature activate event receiver. But, when I checked my event receiver I did not use this class at all.
Then, I attached the solution to OWSTimer.exe and started debugging to trace the error. I then found that I have accessed the SPSite of the feature as its parent as shown below.


And the scope of the feature was “Web” as shown below




The Parent property of a feature represents the object that represents the scope of the feature. So, in my case I have assigned the Parent property of the feature (Which is  SPWeb object) to the SPSite object instead and thus the mismatch caused the error while deploying.


No comments:

Post a Comment