System.Reflection.RuntimeConstructorInfo.CheckCanCreateInstance C# (CSharp) Method

CheckCanCreateInstance() static private method

static private CheckCanCreateInstance ( Type declaringType, bool isVarArg ) : void
declaringType System.Type
isVarArg bool
return void
        internal static void CheckCanCreateInstance(Type declaringType, bool isVarArg)
        {
            if (declaringType == null)
                throw new ArgumentNullException("declaringType");
            
            // ctor is ReflectOnly
            if (declaringType is ReflectionOnlyType)
                throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyInvoke"));
            
            // ctor is declared on interface class
            else if (declaringType.IsInterface)
                throw new MemberAccessException(
                    String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateInterfaceEx"), declaringType));
            
            // ctor is on an abstract class
            else if (declaringType.IsAbstract)
                throw new MemberAccessException(
                    String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateAbstEx"), declaringType));
            
            // ctor is on a class that contains stack pointers
            else if (declaringType.GetRootElementType() == typeof(ArgIterator))
                throw new NotSupportedException();
            
            // ctor is vararg
            else if (isVarArg)
                throw new NotSupportedException();
                        
            // ctor is generic or on a generic class
            else if (declaringType.ContainsGenericParameters)
                throw new MemberAccessException(
                    String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateGenericEx"), declaringType));
            
            // ctor is declared on System.Void
            else if (declaringType == typeof(void))
                throw new MemberAccessException(Environment.GetResourceString("Access_Void"));
        }

Usage Example

 // Token: 0x060043FD RID: 17405 RVA: 0x000F8F82 File Offset: 0x000F7182
 internal void ThrowNoInvokeException()
 {
     RuntimeConstructorInfo.CheckCanCreateInstance(this.DeclaringType, (this.CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs);
     if ((this.Attributes & MethodAttributes.Static) == MethodAttributes.Static)
     {
         throw new MemberAccessException(Environment.GetResourceString("Acc_NotClassInit"));
     }
     throw new TargetException();
 }
All Usage Examples Of System.Reflection.RuntimeConstructorInfo::CheckCanCreateInstance