Accessing C# libraries from Office Web Add-Ins
Asked Answered
A

2

6

Is there a standard way to access a C# (or VB.NET) library from an Office 365 Web Add-In? I have a very large VSTO Word Add-In with a substantial amount of code written in C#, so I need to know if I can re-use this functionality without having to rewrite it all.

Ass answered 27/3, 2019 at 12:12 Comment(5)
Pretty unlikely I’m afraid, particularly if you’re relying a lot on the object model. They’re very different paradigms, vsto and the office web addinsOringas
it's not possible for an Office Web Add-in to talk to a VSTOMorgun
I understand that perfectly. I don't want to do that. What I want to do is to access the supporting libraries that I currently consume within my VSTO add-in in my Web Add-In.Ass
How about exposing the supported library code via a web API that your OfficeJS add-in can use? There are drawbacks, mostly related to the latency introduced by having to use HTTP. Another option is using a custom XML part to communicate between the VSTO add-in and OfficeJS add-in. Basically delegating requests from the OfficeJS add-in to the VSTO add-in, until your OfficeJS add-in is able to perform those requests itself.Richardo
That sounds interesting. We make extensive use of custom xml parts alreadyAss
S
2

Yes -- see this Microsoft tutorial on this:

Tutorial: Share code between both a VSTO Add-in and an Office Add-in with a shared code library

In a nutshell, you use REST APIs to call your libraries written in C# from your new Web add-in written in JavaScript or TypeScript. This allows you to use those libraries for both your VSTO and Web add-in, or while transitioning from one to the other, etc.

Slavey answered 14/1, 2023 at 19:2 Comment(0)
K
4

I'm afraid that it's not possible for an Office Web Add-in to talk to a VSTO add-in and call the code of the VSTO add-in. Among other reasons, Office Web Add-ins are intended to work cross-platform. They should run in Office for Mac, for example. That would not be possible if they have a dependency on a VSTO add-in. (See this SO question for more about that: Does VSTO Add-In support to Mac(iOS) Operating system?.)

Kirby answered 27/3, 2019 at 16:0 Comment(2)
It's not t so much the VSTO interop that I'm interested in. I have some C# libraries that deal with some pretty esoteric data structures, and it's these that I need to be able to access. So it's mainly vanilla C#. Just a lot of it!Ass
@Ass As per my answer that I just posted, there is now a MS tutorial on how you can access your C# libraries from Web add-ins -- which may not have been available when you first asked this question back in 2019.Slavey
S
2

Yes -- see this Microsoft tutorial on this:

Tutorial: Share code between both a VSTO Add-in and an Office Add-in with a shared code library

In a nutshell, you use REST APIs to call your libraries written in C# from your new Web add-in written in JavaScript or TypeScript. This allows you to use those libraries for both your VSTO and Web add-in, or while transitioning from one to the other, etc.

Slavey answered 14/1, 2023 at 19:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.