I have a console application in which I declared a class which is defined under a namespace. I want to create an instance of that class at runtime using assemblyname and class name. I tried the below code
var objAssembly = Assembly.Load(assemblyName);
var objType = objAssembly.GetType(className);
var obj = Activator.CreateInstance(objType);
But it is not working. Below is the class structure
namespace ReportService.ReportWriters
{
class ExcelWriter : IReportWriter
{
}
}
I passed assembly name = ExcelWriter class name = ReportService.ReportWriters
ExcelWriter.dllsigned? Is it in the directory from which your program is started? Does it have dependencies?