Ejemplo n.º 1
0
            /// <summary>
            /// <para>Walks through all AxHost derived classes in the given assembly,
            /// and returns the type that matches our control's CLSID.</para>
            /// </summary>
            private Type GetAxTypeFromAssembly(Assembly a)
            {
                Type[] types = a.GetTypes();
                int    len   = types.Length;

                for (int i = 0; i < len; ++i)
                {
                    Type t = types[i];
                    if (!(typeof(AxHost).IsAssignableFrom(t)))
                    {
                        continue;
                    }

                    object[] attrs = t.GetCustomAttributes(typeof(AxHost.ClsidAttribute), false);
                    Debug.Assert(attrs != null && attrs.Length == 1, "Invalid number of GuidAttributes found on: " + t.FullName);

                    AxHost.ClsidAttribute guid = (AxHost.ClsidAttribute)attrs[0];
                    if (string.Equals(guid.Value, clsid, StringComparison.OrdinalIgnoreCase))
                    {
                        return(t);
                    }
                }

                return(null);
            }
Ejemplo n.º 2
0
        /// <devdoc>
        /// <para>Walks through all AxHost derived classes in the given assembly,
        /// and returns the type that matches our control's CLSID.</para>
        /// </devdoc>
        private string GetAxTypeFromAssembly(string fileName, Guid clsid)
        {
            Assembly a = GetCopiedAssembly(fileName, true, false);

            Type[] types = a.GetTypes();
            foreach (Type t in types)
            {
                if (!(typeof(AxHost).IsAssignableFrom(t)))
                {
                    continue;
                }

                object[] attrs = t.GetCustomAttributes(typeof(AxHost.ClsidAttribute), false);
                Debug.Assert(attrs != null && attrs.Length == 1, "Invalid number of GuidAttributes found on: " + t.FullName);

                AxHost.ClsidAttribute clsidAttr = (AxHost.ClsidAttribute)attrs[0];
                if (clsidAttr.Value == "{" + clsid.ToString() + "}")
                {
                    return(t.FullName);
                }
            }

            return(null);
        }