none
__COMObject vs. ApplicationClass RRS feed

  • Question

  • We have an issue with our VSTO outlook addin that I cant quite figure out. What happened was we switched DI frameworks, from ninject to autofac, and something in that change revealed a type discrepancy that only impacts certain users.

    What we see are errors from AutoFac saying that the object we expect to be a Microsoft.Office.Interop.Outlook.Application is not assignable to that inteface. It seems like the autofac framwork uses the IsAssignableTo method under the hood and that check fails.

    I can try to work around this, but I want to understand why these user's systems are in this state.

    On my machine, Globals.ThisAddin.Applicaiton is an ApplicationClass object, which implies .NET is able to convert the interface into a concrete class. On the client machines that are affected by this, the object is a __COMObject in memory, BUT I can cast it to a Microsoft.Office.Interop.Outlook.Application and call all the methods I need to. 

    Does anyone have any idea why this might be the case on certain user's systems?

    Friday, October 11, 2019 9:33 PM

All replies