0

I have a List of strings which contains UserControl classes. I wish to pass that List to a foreach() loop and create an object of each class in the List

 List<string> MyUserControlList= new List<string>();
            Permissions.Add("Profile_UC");
            Permissions.Add("Bio_UC");

foreach(var Information in MyUserControlList)
            {

                //Getting Usercontrol class name
                Type uc1 = Type.GetType(Information); 

               // Type uc1 = Type.GetType("Tab_Control_and_User_Control_test."+Permission,Assembly.GetEntryAssembly().GetName().Name);

                //Creating instance of relative user control class
                Object MyUserControlObject = Activator.CreateInstance(uc1);                
                //rest of my logic

            }

I searched and find that its kind of an assembly issue, but I didn't find any good resource to point out it in a dynamic way.

Muhammad Arslan Jamshaid
  • 1,077
  • 8
  • 27
  • 48

1 Answers1

7

Please Provide full path of your object means with namespace Like

      String p = "ConsoleApplication1.Profile_UC";
 Type uc1 = Type.GetType(p); 
Syed Qasim Ahmed
  • 1,352
  • 13
  • 24