Exception in page is holding onto assembly RRS feed

  • Question

  • User-212531434 posted

    I have written a IHttpHandlerFactory class that looks at the url and loads the correct assembly (etc). It all works :)

    However, one of the assemblies that gets loaded causes an InvalidProgramException (which is not the issue, I know how to fix it) and as soon as that exception is fired the assembly file is locked and cannot be updated. The only way to allow the loaded assembly to be overwritten is to kill the ASP worker process. The flow is:

    My IHttpHandlerFactory.GetHandler is called.

    Loads the assembly, gets a reference to the IHttpHandler interface and returns it

    The InvalidProgramException occurs

    The IHttpHandlerFactory.ReleaseHandler is never called

    Anybody any advice? 

    Thursday, December 21, 2006 11:24 AM

All replies

  • User922302870 posted


    Have you tried this:


    IHttpHandler myhandler = myfactory.GetHandler ();






    catch(Exception ex)






    Tuesday, December 26, 2006 12:55 AM
  • User-212531434 posted
    Hmm... interestingly that does not seem to help and the situation is a bit more subtle that I thought: When the browser is after http://localhost/myfile.xyz and I execute this line inside my handler: FAssembly = Thread.GetDomain().Load( FAssemblyName ); The assembly is loaded but it is first copied into "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files\\root....." (as shown by FAssembly.Location). As it is not loaded from the real location it can be overwritten. When the browser is after http://localhost/test/myfile.xyz and the assembly is in {approot}\test\bin then the DLL is not copied and runs from its original location ... causing a subsequent lock. Is there a way to force it to copy the assembly first (or is there another solution)?
    Saturday, December 30, 2006 11:54 AM
  • User403949901 posted

    I dont think ASP.NET runs the DLL from the root location, the framework makes a copy and runs the dll, this has two advantages,

    one, you can update your code/appication/webserver without going offline. and the other one is if your server is under attack, you can simply kill that process and which wouldn't crash your entire application.

    I see it more off a security feature.


    Sunday, January 14, 2007 9:39 PM
  • User1347187933 posted


    Can we catch it? Anyone? 

    Monday, January 15, 2007 4:04 AM