System.ComponentModel.TypeDescriptor.Refresh C# (CSharp) Method

Refresh() public static method

Clears the properties and events for the specified assembly from the cache.
public static Refresh ( Assembly assembly ) : void
assembly System.Reflection.Assembly
return void
        public static void Refresh(Assembly assembly)
        {
            if (assembly == null)
            {
                Debug.Fail("COMPAT:  Returning, but you should not pass null here");
                return;
            }

            foreach (Module mod in assembly.GetModules())
            {
                Refresh(mod);
            }
        }

Same methods

TypeDescriptor::Refresh ( Module module ) : void
TypeDescriptor::Refresh ( Type type ) : void
TypeDescriptor::Refresh ( object component ) : void
TypeDescriptor::Refresh ( object component, bool refreshReflectionProvider ) : void

Usage Example

        public static void ClearCache(Type[]?types)
        {
            // ReflectTypeDescriptionProvider maintains global caches on top of reflection.
            // Clear those.
            ReflectTypeDescriptionProvider.ClearReflectionCaches();

            // Each type descriptor may also cache reflection-based state that it gathered
            // from ReflectTypeDescriptionProvider.  Clear those as well.
            if (types is not null)
            {
                foreach (Type type in types)
                {
                    TypeDescriptor.Refresh(type);
                }
            }
            else
            {
                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    TypeDescriptor.Refresh(assembly);
                }
            }
        }