Skip to content

Need to flesh out Office/VS integration scenarios #1763

Open

Description

@JeremyKuhne

#1565 cleans up the IMsoComponent OLE related code, but we don't have a clear understanding of the expected interop scenarios with Office and VS with WinForms on .NET Core.

We need to clearly answer:

  1. How hosting is expected (or not expected) to work
  2. What basic scenarios we want to validate/enable, if any
  3. Level of Office support for OLE plugins (understood to be deprecated?)

Activity

  1. added this to the 5.0 milestone on Sep 4, 2019
  2. weltkante commented on Sep 5, 2019

    @weltkante
    Contributor

    1. We have two scenarios we are implementing in our products in Desktop Framework and which we expect to be supported in .NET Core (or be offered an equivalent replacement). Both are based on native COM APIs and C# / .NET Core just happens to be the choice of implementing them.

    a) Implement IDTExtensibility2 and register as a COM Office addin. On startup Office loads the addin through COM interop, this will implicitely load and activate the .NET Core runtime.

    b) Make a COM visible class available for import into Office macros. The class will be created through COM interop and implicitely load and activate the .NET Core runtime. VBA macros then will call into the class and pass Office COM objects with which your class is supposed to work (for example to fill in an excel sheet with data)

    Note that for both we do not need support from WinForms, .NET Core supports that by itself after having brought COM interop back in 3.0. Only if we want to show WinForms UI from our code (which you usually want to do for anything interactive) then WinForms needs to coordinate with Office.

    2. WinForms interacts with Office by
    a) integrating into the Office message loop so WinForms can peek into messages early when Office is running the message loop
    b) sharing the message loop when WinForms pushes a modal loop, so Office can peek into messages early when WinForms is showing a modal form
    c) communicating the intention of the message loop so e.g. modal forms can behave properly

    What exactly needs to be validated is best communicated with the Office team. Basically WinForms doesn't want to break Office by implementing the interfaces incorrectly. The intention of the interfaces is to coordinate modality and sharing the message loop when 3rd parties show WinForms UI in the Office process. Before #1565 trying to show WinForms UI failed reliably so it is clear to any developer that its not a supported scenario yet. Merging it for 5.0 means you need to make sure that you either disable interop with Office or make sure it works reliably.

    3. You'll have to ask the Office team what they want to support going forward, but as of now COM addins and COM interaction from macros are both working reliably over all supported generations of Office. I don't see VBA macros going away anytime soon and they are basically using the same API as COM addins (which is why they can pass Office objects for processing to COM classes).

    I see two primary options to go for:
    a) get someone from Office and coordinate how to use and test the ComponentManager API
    b) get rid of the Office integration and let them handle things without coordinating message loops and modality (I think WPF does it this way? At least I never found a trace of Office integration in the reference source) - this may lead to regressions but at least you can't break Office by using their underdocumented interop in the wrong way.

    The risk of not getting the Office team involved and still keeping the ComponentManager interop is that you may accidently break some contract during refactoring and if a 3rd party shows WinForms UI inside the Office process things misbehave. The Office end user may not have the technical knowledge to diagnose and report back when things go wrong, reducing the user experience of Office due to bugs in WinForms.

    If the effort of getting the Office team involved is too high I'd recommend getting rid of the IMsoComponentManager integration.

  3. merriemcgaw commented on Sep 11, 2019

    @merriemcgaw
    Contributor

    @OliaG let's sync and discuss what our options are and what we want for the longer term.

  4. JeremyKuhne commented on Sep 12, 2019

    @JeremyKuhne
    MemberAuthor

    @merriemcgaw Please pull me in and I can give you some technical context on the runtime code.

  5. added
    api-suggestion
    design-discussion
    on Sep 12, 2019
  6. merriemcgaw commented on Dec 4, 2019

    @merriemcgaw
    Contributor

    Assigning to @OliaG so we can talk through it and make some support decisions.

  7. weltkante commented on Feb 5, 2020

    @weltkante
    Contributor

    Any update on this? (Just asking because the labeling went from alpha to preview and it would be nice to have a resolution for 5.0 - either supporting ComponentManager/Office integration or removing it from the codebase if it is not required.)

  8. merriemcgaw commented on Feb 8, 2020

    @merriemcgaw
    Contributor

    Funny you should ask @weltkante 😃. @OliaG and I were just reaching out to the folks on the Office Team last night to start kicking off the conversations. We're going to have some management level discussions around what we want to do here as well. I'll keep you updated as we hear from folks.

  9. weltkante commented on Apr 1, 2020

    @weltkante
    Contributor

    Any progress on this yet? I still very much would like to resolve this, either by removing it or implementing it properly.

    (Let me remind you that the current codebase has a broken port of undocumented ComponentManager integration, see #247, fixing it is not possible to do reliable without feedback from the Office team since WinForms is using undocumented API here and Office is the only one with a working 64 bit version. Getting the implementation wrong in WinForms will break Office.)

  10. modified the milestones: 5.0 Previews 1-4, 5.0 on Apr 20, 2020
  11. merriemcgaw commented on Apr 29, 2020

    @merriemcgaw
    Contributor

    Hey @weltkante , just wanted to pop in and let you know that there are internal discussions going on about this issue. @OliaG and I will keep you posted as things develop. We don't have an ETA just yet, but I didn't want to leave you hanging.

  12. 4 remaining items

  13. weltkante commented on Jul 2, 2020

    @weltkante
  14. weltkante commented on Jul 3, 2020

    @weltkante
    Contributor

    Having reflected about the situation a bit more, I've opened #3536 to highlight alternatives. It would be appreciated if you'd reconsider the consensus if any of the options I'm presenting have not been considered yet.

    Since Office isn't interested it doesn't feel right to continue discussion in an issue which focuses on scenarios when the feedback is to not actively support those scenarios, so thats why I'm splitting off into a separate discussion. I want to concentrate the new issue on keeping WinForms as a framework reliable even when invoked in scenarios that aren't actively supported.

    Defaulting to going live in .NET Core 5 with an implementation that was broken before, has been refactored heavily, and is completely untested is not something I'm comfortable with. While we can work through porting some of our addins and that could discover obvious regressions, working through this by trial-and-error is likely not going to capture edge cases. It certainly won't make WinForms a reliable framework. (Also I repeat WPF doesn't seem to need ComponentManager integration, so I'm not convinced WinForms needs it either.)

    The consensus is to leave everything as is until we get a specific scenario from a customer. If we leave the interfaces in the codebase it will be much easier to work with a customer that comes to us with a specific scenario that isn't working.

    I'm sure you'll fix any obvious bugs like crashes, but most devs aren't really capable to rootcause subtile behavioral defects between WinForms and Office, both being Microsoft products, the defects happening without any interaction from their code. The end users will have to suffer the consequences, meaning it will fall back to Office in the first place and not the addin author. The devs you are referring to as customers may likely not be aware if WinForms is broken. Subtile bugs are likely going to take a long time to be brought to your attention.

  15. modified the milestones: 5.0, 6.0 on Sep 1, 2020
  16. added
    area-VSTO
    on Dec 16, 2020
  17. modified the milestones: 6.0, 7.0 on Aug 27, 2021
  18. modified the milestones: .NET 7.0, Future on Feb 28, 2022
  19. dreddy-work commented on Feb 28, 2022

    @dreddy-work
    Member

    Team went over it with initial review and keep it for future milestone with respect to current priorities.

  20. removed
    api-suggestion
    on Jan 24, 2024
  21. jozefizso commented on Mar 12, 2025

    @jozefizso

    Hi, we are developing Microsoft Office add-ins and having support for Task Panes extensibility is crucial to our products.

    The current limitation where we cannot create task panes using the ICTPFactory.CreateCTP() method is a showstopper for our products to adopt the .NET Core.

  22. robertmuehsig commented on Oct 4, 2025

    @robertmuehsig

    I know this is an old issue and from a management perspective not interesting, but we have a large code base with Office Addins that still need to use .NET Framework, because the Office.js APIs are nice, but still not "powerful" enough :-/

    We really would like to move all parts of the application to .NET 9/10/...

  23. jozefizso commented on Oct 4, 2025

    @jozefizso

    Having Microsoft Office to support .NET Core addins would be tremendous help to improve stability of the apps.

    .NET Framework addins are sharing single memory in default AppDomain which creates problems with library versions, etc.

    .NET Core has comhost which isolates addins. This will improve the Office addins ecosystem.

    Yet Office addins without user interface are useless and the best option is to be able to extend the Task Pane area.

  24. weltkante commented on Oct 5, 2025

    @weltkante
    Contributor

    .NET Core has comhost which isolates addins. This will improve the Office addins ecosystem.

    It does not provide isolation, you cannot load multiple .NET Core addins into the same process unless they happen to use the same (shared) runtime. Different runtime versions and private runtimes will conflict because the C++ part of the code use global state. (As far as I'm aware even AOT deployment doesn't fix this problem.) There's an issue somewhere in the dotnet repo that tracks loading multiple versions of .NET Core into a process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-COMarea-VSTOdesign-discussion

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions