Interop effects by resolving and instantiating types with ArcObjects

Why Activator.CreateInstance fails when directly using an ArcObjects AppRefClass type but succeeds when obtaining the COM type through its CLSID, avoiding an invalid runtime cast.

Problem

this code does not work

Type t = typeof(ESRI.ArcGIS.Framework.AppRefClass);
System.Object obj = Activator.CreateInstance(t);

but yet this code

Type t = Type.GetTypeFromCLSID(typeof(ESRI.ArcGIS.Framework.AppRefClass).GUID);
System.Object obj = Activator.CreateInstance(t);

Reason

In the first variant the runtime tries to cast to AppRefClass. This is not possible.

And in the second one, the runtime does not knows anything about AppRefClass. So it leave it as IUnknown.

(originally communicated by my co-worker Ralf)