Attach event to dynamic object

前端 未结 3 474
情深已故
情深已故 2021-01-12 08:41

I create a c# dynamic object of a COM-Object on the fallowing way:

dynamic pdfCreator = Activator.CreateInstance(
                       Type.GetTypeFromProg         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-12 09:39

    Since the delegate type is not known at compile time, you have to specify it. The Action delegate matches methods with no parameters or return value:

    pdfCreator.eReady += new Action(_PDFCreator_eReady);
    

提交回复
热议问题