Reflection

Dec 24 2004 4:10 AM
I am using reflection to get load an assembly. I donot know how to get the properties of the object using reflection. I want to know how to get the values of the properties in the object. I have attached my code, if any one could check what is missing I would be thankful. string strPath = GetInstalledPath(); asm = Assembly.LoadFrom (strPath); PublishType = asm.GetType("ControlLicenseService.LicenseInfoClient"); Object theObj = Activator.CreateInstance(PublishType); // Array with Two members for passing the Parameter for Initialize method. Type[] paramTypes = new Type[2]; paramTypes[0]= Type.GetType("System.String"); paramTypes[1]= Type.GetType("System.Int32"); // Get method info for Initialize( ) MethodInfo InitializeInfo = PublishType.GetMethod("Initialize",paramTypes); // Fill the array with the actual parameters Object[] parameters = new Object[2]; parameters[0] = "sk26901CODA904O"; parameters[1] = 10300; Object returnVal = InitializeInfo.Invoke(theObj,parameters); pi = PublishType.GetProperty("UsersCount"); string valu = pi.GetValue(theObj,null).ToString(); MessageBox.Show(valu);

Answers (6)