tonylmiller
Programmer
Normally one would write:
Class myClass = new Class();
But I want "Class" to change. Can I make the name of the class a variable? How?
I used
Object o = Activator.CreateInstance("myAssembly","namespace" + myType);
but the object "o" has the type {System.Runtime.Remoting.ObjectHandle} with the wrapped object being myType. So I cannot access o's properties and methods. How do I make o of the type myType so that it can access myType's properties and methods?
Specifically what I want to do is instantiate an instance of a report, like this:
DefinedReport myReport = new DefinedReport();
But I want to pass in a variable for DefinedReport, instead of it being predefined.
Then I want to set its data souce and use it as the source for a report viewer.
myReport.SetDataSource(dataSet);
myReportViewer.ReportSource = myReport;
Any help would be greatly appreciated.
Tony
Class myClass = new Class();
But I want "Class" to change. Can I make the name of the class a variable? How?
I used
Object o = Activator.CreateInstance("myAssembly","namespace" + myType);
but the object "o" has the type {System.Runtime.Remoting.ObjectHandle} with the wrapped object being myType. So I cannot access o's properties and methods. How do I make o of the type myType so that it can access myType's properties and methods?
Specifically what I want to do is instantiate an instance of a report, like this:
DefinedReport myReport = new DefinedReport();
But I want to pass in a variable for DefinedReport, instead of it being predefined.
Then I want to set its data souce and use it as the source for a report viewer.
myReport.SetDataSource(dataSet);
myReportViewer.ReportSource = myReport;
Any help would be greatly appreciated.
Tony