internal static Type GetType(string typeName, string propertyName, ConfigurationElement configElement, XmlNode node, bool checkAptcaBit, bool ignoreCase) { Type type; try { type = BuildManager.GetType(typeName, true, ignoreCase); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (node != null) { throw new ConfigurationErrorsException(exception.Message, exception, node); } if (configElement != null) { throw new ConfigurationErrorsException(exception.Message, exception, configElement.ElementInformation.Properties[propertyName].Source, configElement.ElementInformation.Properties[propertyName].LineNumber); } throw new ConfigurationErrorsException(exception.Message, exception); } if (checkAptcaBit) { if (node != null) { HttpRuntime.FailIfNoAPTCABit(type, node); return(type); } HttpRuntime.FailIfNoAPTCABit(type, (configElement != null) ? configElement.ElementInformation : null, propertyName); } return(type); }
internal static Type GetType(string typeName, string propertyName, ConfigurationElement configElement, XmlNode node, bool checkAptcaBit, bool ignoreCase) { // We should get either a propertyName/configElement or node, but not both. // They are used only for error reporting. Debug.Assert((propertyName != null) != (node != null)); Type val; try { val = BuildManager.GetType(typeName, true /*throwOnError*/, ignoreCase); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (node != null) { throw new ConfigurationErrorsException(e.Message, e, node); } else { if (configElement != null) { throw new ConfigurationErrorsException(e.Message, e, configElement.ElementInformation.Properties[propertyName].Source, configElement.ElementInformation.Properties[propertyName].LineNumber); } else { throw new ConfigurationErrorsException(e.Message, e); } } } // If we're not in full trust, only allow types that have the APTCA bit (ASURT 139687), // unless the checkAptcaBit flag is false if (checkAptcaBit) { if (node != null) { HttpRuntime.FailIfNoAPTCABit(val, node); } else { HttpRuntime.FailIfNoAPTCABit(val, configElement != null ? configElement.ElementInformation : null, propertyName); } } return(val); }
internal Type GetHandlerType(string type) { Type typeWithAssert = this.GetTypeWithAssert(type); HttpRuntime.FailIfNoAPTCABit(typeWithAssert, null, null); if (!ConfigUtil.IsTypeHandlerOrFactory(typeWithAssert)) { throw new ConfigurationErrorsException(System.Web.SR.GetString("Type_not_factory_or_handler", new object[] { type })); } return(typeWithAssert); }
internal Type GetHandlerType(string type) { // HACKHACK: for now, let uncreatable types through and error later (for .soap factory) // This design should change - developers will want to know immediately // when they misspell a type Type t = GetTypeWithAssert(type); HttpRuntime.FailIfNoAPTCABit(t, null, null); // throw for bad types in deferred case if (!ConfigUtil.IsTypeHandlerOrFactory(t)) { throw new ConfigurationErrorsException(SR.GetString(SR.Type_not_factory_or_handler, type)); } return(t); }