CAB,泛型与typeof,编译出错,请高手指教!
使用Composit UI,有如下三段代码:
1、WorkItem类
public class EntityItem<TEntity> : WorkItem
2、View类
public class TView : UserControl
3、调用视图的方法
public void onshow()
{
通过一个类名反射取得类型
Type type = Type.GetType("ERP.Server.Order,ERP.Server");
使用泛型的workitem显示视图
EntityItem<type> workitem = WorkItem.Items.AddNew<EntityItem<type>>();
///////////////////////////////
///////////显示窗体////////////
///////////////////////////////
}
现在编译就提示错误:
The type or namespace name 'type' could not be found (are you missing a using directive or an assembly reference?)
请问:
1、是否因为泛型要求类型安全引起?
2、用这种方式是否可行?
3、是否有其他更好的方式?