Today, one of the websites that I developed started throwing an error message saying:
Server Error in '/' Application.
The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))
This kind of error usually comes when the COM object your InterOp is accessing is throwing an exception. It is quite hard to give a straight forward answer without knowing that which COM your InterOp is calling.
So, there are 2 possible solutions that will fix this problem:
1st Solution) Under you IIS > Virtual Directory Properties > Execution Permissions might be marked as “Scripts and Executables” the dll is not being loaded so you are getting “System.Runtime.InteropServices.COMException”
Try changing the Execution Permissions to “Scripts Only” and applying it - It should work now!
I am not sure about the exact different between the two so all I know is:
Scripts only -> Run only scripts,such as ASP applications and
Scripts and Executables -> Run both scripts, such as ASP applications, and executables
2nd Solution) On your server where you're website sits, open the command prompt and run the following command:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i - It should work now!
I hope it helps someone...