System.Configuration.TypeUtil.CreateInstanceWithReflectionPermission C# (CSharp) Method

CreateInstanceWithReflectionPermission() private method

private CreateInstanceWithReflectionPermission ( Type type ) : object
type System.Type
return object
        static internal object CreateInstanceWithReflectionPermission(Type type) {
            object result = Activator.CreateInstance(type, true); // create non-public types
            return result;
        }

Same methods

TypeUtil::CreateInstanceWithReflectionPermission ( string typeString ) : object

Usage Example

            /// <devdoc>
            ///     We delegate this to the ClientConfigurationHost. The only thing we need to do here is to
            ///     build a configPath from the ConfigurationUserLevel we get passed in.
            /// </devdoc>
            public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath,
                                                      IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
            {
                ConfigurationUserLevel userLevel = (ConfigurationUserLevel)hostInitConfigurationParams[0];
                string desiredConfigPath         = null;

                Host = (IInternalConfigHost)TypeUtil.CreateInstanceWithReflectionPermission(ClientConfigurationHostTypeName);

                switch (userLevel)
                {
                case ConfigurationUserLevel.None:
                    desiredConfigPath = ClientHost.GetExeConfigPath();
                    break;

                case ConfigurationUserLevel.PerUserRoaming:
                    desiredConfigPath = ClientHost.GetRoamingUserConfigPath();
                    break;

                case ConfigurationUserLevel.PerUserRoamingAndLocal:
                    desiredConfigPath = ClientHost.GetLocalUserConfigPath();
                    break;

                default:
                    throw new ArgumentException(SR.GetString(SR.UnknownUserLevel));
                }


                Host.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot, null, null, desiredConfigPath);
            }
All Usage Examples Of System.Configuration.TypeUtil::CreateInstanceWithReflectionPermission