internal static ComTypes.TYPELIBATTR GetTypeAttrForTypeLib(ComTypes.ITypeLib typeLib) { IntPtr pAttrs = IntPtr.Zero; typeLib.GetLibAttr(out pAttrs); // GetTypeAttr should never return null, this is just to be safe if (pAttrs == IntPtr.Zero) { throw Error.CannotRetrieveTypeInformation(); } try { return (ComTypes.TYPELIBATTR)Marshal.PtrToStructure(pAttrs, typeof(ComTypes.TYPELIBATTR)); } finally { typeLib.ReleaseTLibAttr(pAttrs); } }