manuelsidler / blazor-office-addin

A sample Office Add-In based on Blazor Server
10 stars 3 forks source link

Getting started instructions #6

Open LeonGorbaty1 opened 4 years ago

LeonGorbaty1 commented 4 years ago

Please add a readme or some text at the front of the repo with steps to test the add-in in Word?

manuelsidler commented 4 years ago

I've just added a short instruction (see commit above). Could you verify if it works for you @LeonGorbaty1 ?

LeonGorbaty1 commented 4 years ago

@manuelsidler it mostly worked THANK YOU !!! I had a few issues, consider adding the following:

I also got a JSException here var autoShowAddIn = await JSRuntime.InvokeAsync<bool?>("window.Office.context.document.settings.get", "Office.AutoShowTaskpaneWithDocument"); but that's ok, the add-in is running and I am able to hit breakpoints and debug in VS ... I can work from here...

THANKS AGAIN !!

kondzikwawa commented 4 years ago

Hi, I still experience problem with my Add-in. When I run Word I can't see both host and name - only "Not in Office.". It looks there is a problem with connection between Word and Add-in. When I put a break point in this line "await JSRuntime.InvokeVoidAsync("wordWrapper.saveDocumentMetadata", _documentMetadata);" in OnAfterRenderAsync and turn on Add-in in Word the debugging doesn't stop... I would be grateful for any idea or tip. Many thanks in advance.

manuelsidler commented 4 years ago

Which .NET Core version are you using?

kondzikwawa commented 4 years ago

Many thanks for reply. I'm using .Net Core 3.1 I've tried on two machines and unfortunately the same problem. Do you see anything wrong in attached screenshots and manifest? RegEdit DotNetVersion manifest.txt

kondzikwawa commented 4 years ago

Regarding to my previous comment. Any idea what can be wrong with my add-in? Thanks in advance for help.

manuelsidler commented 4 years ago

Sorry I haven't been able to take a look into your problem. I'll try to find some time this week.

Do you see any errors in the Edge DevTools console? https://docs.microsoft.com/en-us/office/dev/add-ins/testing/debug-add-ins-using-f12-developer-tools-on-windows-10#debug-using-microsoft-edge-devtools

kondzikwawa commented 3 years ago

Hi, apologize for delay. I've been extremely busy for last couple of weeks. So yes I can see an issue during the Office.Initialize and it breaks the app. If you can take a look and let me know if you have any idea I'd be grateful. Thanks in advance.

issue

And exception which I can see in Visual Studio: {"Could not find 'initialize' in 'window.Office'.\nError: Could not find 'initialize' in 'window.Office'.\n
at https://localhost:44385/_framework/blazor.server.js:8:30944\n
at Array.forEach ()\n
at p (https://localhost:44385/_framework/blazor.server.js:8:30904)\n
at https://localhost:44385/_framework/blazor.server.js:8:31614\n
at new Promise ()\n
at e.beginInvokeJSFromDotNet (https://localhost:44385/_framework/blazor.server.js:8:31587)\n
at https://localhost:44385/_framework/blazor.server.js:1:20052\n at Array.forEach ()\n
at e.invokeClientMethod (https://localhost:44385/_framework/blazor.server.js:1:20022)\n
at e.processIncomingData (https://localhost:44385/_framework/blazor.server.js:1:18006)"}

manuelsidler commented 3 years ago

Based on your screenshot, it seems like you try to run the add-in directly in a browser instead of the office application?

Could you try to sideload your add-in in Office based on the official documentation?

https://docs.microsoft.com/en-us/office/dev/add-ins/testing/create-a-network-shared-folder-catalog-for-task-pane-and-content-add-ins

kondzikwawa commented 3 years ago

Thanks for reply. Yes, in Visual Studio I click IIS Express and then I can see my add-in in browser, but when I open the Word and open my add-in I can see the proper taskpane...however is not working properly, host and platform are blank and buttons are not working. More over if I insert break points in VS, the code doesn't stop if I click e.g. buttons directly from add-in in Word...but when I click any button in browser breakpoints are working normally. image

Maybe I do something wrong...

manuelsidler commented 3 years ago

With Office add-ins, it's not possible to hit F5 and debug straight away. If you want to debug the client-side code, you have to attach the Edge developer tools to your add-in as described here: https://docs.microsoft.com/en-us/office/dev/add-ins/testing/debug-add-ins-using-f12-developer-tools-on-windows-10#debug-using-microsoft-edge-devtools

You can also try to attach Visual Studio directly to your Office add-in as described here: https://docs.microsoft.com/en-us/office/dev/add-ins/testing/attach-debugger-from-task-pane

kondzikwawa commented 3 years ago

Ok, I get it it's not straightforward but I think there is a problem with Office.js and I have no idea why. image Is not loaded so that's the reason why I can't see the host and platform. But of course I've included Office.js in my _Host.cshtml file: image And of course I have "Initialize" and "onready" in my code. image

Many thanks for your help.

HansenBerlin commented 3 years ago

Ok, I get it it's not straightforward but I think there is a problem with Office.js and I have no idea why. Is not loaded so that's the reason why I can't see the host and platform. But of course I've included Office.js in my _Host.cshtml file: And of course I have "Initialize" and "onready" in my code.

Many thanks for your help.

Did you find a solution? Same problem here...