is there a better way to handle RPC_E_CALL_REJECTED exceptions when doing visual studio automation?

后端 未结 4 528
傲寒
傲寒 2021-01-01 03:48

this is what I\'m currently doing:

    protected void setupProject()
    {
        bool lbDone = false;
        int liCount = 0;
        while (!lbDone &         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-01-01 04:01

    I was getting the same error using C# to read/write to Excel. Oddly, it worked in debug mode but not on a deployed machine. I simply changed the Excel app to be Visible, and it works properly, albeit about twice as slow. It is annoying to have an Excel app open and close dynamically on your screen, but this seems to be the simplest work-around for Excel.

    Microsoft.Office.Interop.Excel.Application oApp = new ApplicationClass();
    oApp.Visible = true;
    oApp.DisplayAlerts = false;
    

提交回复
热议问题