TS,
Ok, I kind of understand what you are doing now.
In order to load the assembly, you don't have to check the assemblies
in the current domain. Rather, you should just call one of the Load
methods in the Assembly class. If the assembly is loaded already, then it
will return that. If not, it will load the assembly.
To get the type, call the GetType method on the Assembly instance that
you loaded.
Then, you call CreateInstance on the Activator class to create the
instance.
From there, you can call GetProperty on the Type to get the property,
and then call the SetValue method on the PropertyInfo returned from the
call to GetProperty to set the value (passing in your instance returned
from CreateInstance).
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
TS said:
controlAssemblyTypeName="XXX.XXXXX.Web"
controlTypeName="XXX.XXXXX.Web.Controls.StandardCriteria"
And then there are xml sub elements listing all the properties to set on
the standard criteria class
I am using the following method to find the assembly based on the name
declared in xml file and using it to instantiate the class declared in
controlTypeName:
private Assembly GetAssembly(string assemblyTypeName){
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()){
if(assembly.GetName().Name == assemblyTypeName)
return assembly;
}
return null;
}
This could let them find a System assembly
Later to create the class instance i do the following:
// Use reflection to create control
control = (Control) assembly.CreateInstance(controlTypeName);
Nicholas Paldino said:
TS,
Can you be more specific with what you mean by validating? How are
these things declared in the XML file?
If you are creating an assembly, then you are using the reflection
api's, or you are generating C# code and compiling on the fly. Either,
way, you should get an error if the code is not valid.
Can you provide more information?
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
i have code that creates assemblies and classes from the assemlby and
methods from the classes to set properties of dynamically created
controls.
How i should go about validating the assemblies, classes, & properties
declared in the xml file?
Thanks