NetOfficeFw / NetOffice

🌌 Create add-ins and automation code for Microsoft Office applications.
MIT License
697 stars 143 forks source link

Using Netoffice.Office with UWP/Xamarin? #298

Closed JKennedy24 closed 4 years ago

JKennedy24 commented 4 years ago

I installed the Netoffice.office component into a UWP project that uses xamarin. and I was lookig to implement a method to send an email but only on the uwp platform.

The nuget package installed ok but unfortunatly gave these errors: build time:
Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: NetOffice, Version=1.7.8.0,

runtime: Error HRESULT E_FAIL has been returned from a call to a COM component.

Is it possible to use these libraries on UWP with Xamarin?

JKennedy24 commented 4 years ago

So I found a duplicate issue here: https://github.com/NetOfficeFw/NetOffice/issues/286

Which talks about using com components in uwp using windows runtime component: https://docs.microsoft.com/en-us/uwp/win32-and-com/win32-and-com-for-uwp-apps

I did try install the nuget to a windows runtime component but it gave t he same error.

Has anyone managed to do this?

jozefizso commented 4 years ago

Hi @JKennedy24, the UWP/Xamarin applications are not supported by NetOffice. This is the limitation of the UWP platform.

Here is a workaround: https://stefanwick.com/2017/05/26/uwp-calling-office-interop-apis/

You must access MS Office from the standard Windows Desktop application using .NET Framework and call it using the FullTrustProcessLauncher API.