FeatureUninstalling is called AFTER event receiver assembly has been uninstalled from GAC RRS feed

  • Question

  • Hello guys,

    There is an SP solution that contains a web application feature. When activating - this feature modifies web config of the target web application(registers an HTTPModule). 

    If user activates the feature and then retracts the solution while feature is active - the web application will crush because web config will still contain modifications when the DLL with HTTPModule definition is no longer available in GAC.

    So I've implemented the FeatureUninstalling method and want to remove my modifications, but this method is never called.

    After some research I've found from ULS Logs that the Timer Job is trying to call feature event handler AFTER it removes DLL from GAC.

    There are following lines in the log:

    • Solution Deployment : UpdateFiles - Processing file my_assembly of Type GlobalAssembly FileDir
    • Solution Deployment : Uninstalling from GAC - [my_assembly_full_name]
    • .....
    • Solution Deployment : Success : retraction for [my_solution].wsp Target global
    • ....
    • Solution Deployment : Removing feature for [my_solution].wsp Target global
    • ....
    • Feature receiver assembly '[my_assembly_full_name]', class '[my_event_receiver_class]', method 'FeatureUninstalling' for feature '...' threw an exception: System.ArgumentException: Failed to load receiver assembly "[my_assembly_full_name]" for feature ... System.IO.FileNotFoundException: Could not load file or assembly '[my_assembly_full_name]' or one of its dependencies. The system cannot find the file specified

    Is it a problem that it calls FeatureUninstalling when DLL is removed from GAC? Or there is some problem with loading an assembly? How can I investigate this issue?

    Thanks in advance.

    Friday, August 16, 2013 5:39 AM

All replies

  • Hi,

    SPFeatureReceiver.FeatureUninstalling method is raised when a feature is uninstalled.

    As to your scenario, please try to use SPFeatureReceiver.FeatureDeactivating method instead, check the result.


    Qiao Wei
    TechNet Community Support

    Monday, August 19, 2013 3:31 AM
  • Guys,

    I tried restarting the server for few times, tried IIS reset without any luck.

    The issue is fixed by renaming a project assembly to [my_assembly_name]111.dll and deploying the solution.

    After this I've renemed assembly back to [my_assembly_name].dll this time solution has been deployed succesfully. Then I redeployed solution for few times more. Each time all event receivers has been called withuot exception.

    There was no any problems with order of calls. The order is same now but there is no exception anymore.

    I have no idea what was the issue.


    We've figured out that issue is not fixed and appears from time to time. Any idea how to investigate or fix?
    • Marked as answer by Serhiy_Shekh Monday, August 19, 2013 11:56 AM
    • Unmarked as answer by Serhiy_Shekh Thursday, September 19, 2013 5:14 PM
    • Edited by Serhiy_Shekh Thursday, September 19, 2013 5:15 PM
    Monday, August 19, 2013 11:55 AM
  • As I've found the order of calls is OK. I have implemented event receivers for FeatureUninstalling, FeatureDeactivating, FeatureActivated events. All events just add a message to the log saying that the method is called. Some times the issue appears and some event receivers are not called during installing or uninstalling. The exception message is always same "Failed to load receiver assembly "[my_assembly_full_name]" for feature ... "
    Thursday, September 19, 2013 5:18 PM
  • I'm definitely seeing this problem too, and it's extremely frustrating.  I can't find any way to reliably detect when the solution is retracted, at which point I need to do quite a bit of clean-up.

    Monday, March 24, 2014 2:42 AM