What I can't understand, is why e.pDisp exists if we can't cast it ?
the IE namespace you use once you have imported the IE web control ocx (drag&drop, add reference, ...) is actually the result of an automated type-library import which simply creates a thin wrapper around the idl interfaces. Because the IDispatch *pDisp appears in some members of some of the interfaces, it thus appears in the resulting wrapper.
But as I have said already, this is a case where it's not useful : IDispatch* is seen as a raw untyped
object. Furthermore, the namespace already provides interfaces from which you can invoke the methods you would with a C++ ptr on the web control. So, you don't lose power by using C# or other .NET languages.
The thing you lose is that the marshaller (at the heart of all the interop stuff) is not able to comply with all kind of variant subtypes (limitation known by MS people). As long as MS doesn't fix it, whevener we import a type-library, we may or may not for any reason be able to call certain methods depending on the parameter types. That's it. We'll have to live with it. And by the way, the article I have suggested bypasses the standard tlbimp.
She's so dirty, she threw a boomerang and it wouldn't even come back.