M
Mark Olbert
I think I'm running into a problem caused by the strong-typing system in dotnet.
I have a custom control which can be configured, at design time, to work with one of a number of
DataTables in a DataSet. The custom control has a method which puts up a modal form at runtime; the
type of modal form created depends on the specific DataTable selected at designtime. All of the
specific modal forms are descendants of GenericModalForm.
The way I'm trying to handle this is to require the user, at designtime, to select a particular type
of modal form. I've written a routine that scans, at designtime, the project assembly and extracts
every type that is descended from GenericModalForm. Selecting the one to use then becomes a simple
matter of writing a UITypeEditor for the modal form property.
All of that works fine. However, at runtime, when I try to create an instance of the specific modal
form, Type.GetType() fails, claiming it can't find the type in the assembly. This is odd, since the
string I pass Type.GetType() is qualified with the assembly name (e.g.,
TestProject.SpecificModalForm), so the type ought to be findable.
I'm wondering if the fact that the project is recompiled before it runs is causing the type string
to be "one version behind" the type actually in the running assembly. I think that would cause the
problem I'm seeing, but I'm not sure.
Does anyone have some references on how to retrieve types from a project assembly at designtime, and
then use that information to create instances of the type at runtime?
- Mark
I have a custom control which can be configured, at design time, to work with one of a number of
DataTables in a DataSet. The custom control has a method which puts up a modal form at runtime; the
type of modal form created depends on the specific DataTable selected at designtime. All of the
specific modal forms are descendants of GenericModalForm.
The way I'm trying to handle this is to require the user, at designtime, to select a particular type
of modal form. I've written a routine that scans, at designtime, the project assembly and extracts
every type that is descended from GenericModalForm. Selecting the one to use then becomes a simple
matter of writing a UITypeEditor for the modal form property.
All of that works fine. However, at runtime, when I try to create an instance of the specific modal
form, Type.GetType() fails, claiming it can't find the type in the assembly. This is odd, since the
string I pass Type.GetType() is qualified with the assembly name (e.g.,
TestProject.SpecificModalForm), so the type ought to be findable.
I'm wondering if the fact that the project is recompiled before it runs is causing the type string
to be "one version behind" the type actually in the running assembly. I think that would cause the
problem I'm seeing, but I'm not sure.
Does anyone have some references on how to retrieve types from a project assembly at designtime, and
then use that information to create instances of the type at runtime?
- Mark