Side note: Last year I blogged about how to build Office Add-ins with ASP.NET Core.
My daily work home is in the C# and .NET land, so it would be great to use Blazor for Office Addins, right? A Office Add-in is just a web application with a “communication tunnel” to the hosting Office application - not very different from the real web.
What (might) work: Serverside Blazor
My first try was with a “standard” serverside Blazor application and I just pointed the dummy Office Add-in manifest file to the site and it (obviously) worked:
I assume that serverside Blazor is for the client not very “complicated” and it would probably work.
After my initial tweet Manuel Sidler jumped in and made a simple demo project, which also invokes the Office.js APIs from C#!
Building an #Office Add-In based on #Blazor (Server) could be possible. Whether it's a good idea or not is another story ;) https://t.co/LdSPYl4SRh (thanks @robert0muehsig to get me jump up on this idea) pic.twitter.com/1w29212qdS— Manuel Sidler (@manuelsidler) April 24, 2020
Checkout his repository on GitHub for further information.
What won’t work: WebAssembly (if I don’t miss anything)
Serverside Blazor is cool, but has some problems (e.g. a server connection is needed and scaling is not that easy) - what about WebAssembly?
Well… Blazor WebAssembly is still in preview and I tried the same setup that worked for serverside blazor.
The desktop PowerPoint (I tried to build a PowerPoint addin) keeps crashing after I add the addin. On Office Online it seems to work, but not for a very long time:
Blazor WebAssembly seems not to work or at least the startup is super weird :-/ pic.twitter.com/IvnecQFMj2— Robert Muehsig (@robert0muehsig) April 27, 2020
The default Blazor WebAssembly installs a service worker. I removed that part, but I’m not 100% sure if I did it correctly. At least they are currently not supported from the Office Add-in Edge WebView. My experience with Office Online and the Blazor addin failed as well and I don’t think that service workers are the problem.
I’m not really sure why its not working, but its quite early for Blazor WebAssembly, so… time will tell.
What does the Office Dev Team think of Blazor?
Currently I just found one comment on this blogpost regarding Blazor:
Will Blazor be supported for Office Add-ins? No, it will be a React Office.js add-in. We don’t have any plans to support Blazor yet. For that, please put a note on our UserVoice channel: https://officespdev.uservoice.com. There are several UserVoice items already on this, so know that we are listening to your feedback and prioritizing based on customer requests. The more requests we get for particular features, the more we will consider moving forward with developing it.
Well… vote for it! ;)