// Create an object of the given type. Throw an exception if this fails. private static object CreateInstanceOfType(Type type) { object instancedObject = null; Exception instanceException = null; try { instancedObject = SecurityUtils.SecureCreateInstance(type); } catch (TargetInvocationException ex) { instanceException = ex; // Default ctor threw an exception } catch (MethodAccessException ex) { instanceException = ex; // Default ctor was not public } catch (MissingMethodException ex) { instanceException = ex; // No default ctor defined } if (instanceException != null) { throw new NotSupportedException(SR.GetString(SR.BindingSourceInstanceError), instanceException); } return(instancedObject); }
/// <include file='doc\FeatureSupport.uex' path='docs/doc[@for="FeatureSupport.GetVersionPresent"]/*' /> /// <devdoc> /// <para>Gets the version of the specified feature that is available on the system.</para> /// </devdoc> public static Version GetVersionPresent(string featureClassName, string featureConstName) { object featureId = null; IFeatureSupport featureSupport = null; //APPCOMPAT: If Type.GetType() throws, we want to return //null to preserve Everett behavior. Type c = null; try { c = Type.GetType(featureClassName); } catch (ArgumentException) {} if (c != null) { FieldInfo fi = c.GetField(featureConstName); if (fi != null) { featureId = fi.GetValue(null); } } if (featureId != null) { featureSupport = (IFeatureSupport)SecurityUtils.SecureCreateInstance(c); if (featureSupport != null) { return(featureSupport.GetVersionPresent(featureId)); } } return(null); }