mardi 18 août 2015

Create type instance dynamically by using assembly name and class Name

I want to dyanmically create an instance of interface object by using Activator class . Below is the class which implements the interface

     namespace ReportService.ReportWriters
    {
        class ExcelWriter : IReportWriter
        {


        }

}

I tried below code

IReportWriter oIreportService = (IReportWriter)Activator.CreateInstanceFrom("ExcelWriter", "ReportService.ReportWriters");

The above code is not working.Can anyone help me on this..





Aucun commentaire:

Enregistrer un commentaire