-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
-
.NET Core Version: 5.0
-
Have you experienced this same bug with .NET Framework?: No
Problem description:
I am experimenting with doing Office Addins without VSTO and using .NET 5. So far, I have succesfully manged to add ribbon buttons and I'm now working on a custom TaskPane, hosting a Winforms UserControl.
So far, so good. However, when instantiating the UserControl, an exception is thrown here:
winforms/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs
Line 841 in cb03d37
| HRESULT hr = _inPlaceUiWindow.GetWindow(&hwndParent); |
_inPlaceUiWindow is null here and there is no check for that case.
Comparing to .NET Framework 4.8 reference source (https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Control.cs,17065), the implementation is different and I suspect that a regression has snuck in.
Expected behavior:
No NullReferenceException should be thrown.
Minimal repro:
You can download the project here: https://1drv.ms/u/s!AkwgkpetCvCpr4JeJeZfCGlKlHs4qA?e=PeB0So
You need to manually run regsvr32 OutlookAddinNet5.comhost.dll in the bin folder and register the addin in outlook:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Outlook\Addins\OutlookAddinNet5]
"CommandLineSafe"=dword:00000001
"Description"="OutlookAddinNet5 description"
"FirendlyName"="OutlookAddinNet5 name"
"LoadBehavior"=dword:00000003
Then Open Outlook and click the [2] button added to the ribbon.