Attach event to dynamic object

前端 未结 3 477
情深已故
情深已故 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:16

    How about this:

    public delegate void eReadyHandler();
    
    static void Main(string[] args)
    {
        var comType = Type.GetTypeFromProgID("PDFCreator.clsPDFCreator");
        dynamic pdfCreator = Activator.CreateInstance(comType);
        //dynamic pdfCreator = new PDFCreator.clsPDFCreator();
    
        //pdfCreator.eReady = null;
        pdfCreator.eReady += new eReadyHandler(_PDFCreator_eReady);
    }
    
    public static void _PDFCreator_eReady()
    {
    
    }
    

提交回复
热议问题