NetOfficeFw / NetOffice

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

NetOffice.OutlookApi.Application.GetActiveInstance() returns strange COM object if XmlSpy is running #402

Closed robertmuehsig closed 1 month ago

robertmuehsig commented 8 months ago

This is propably a strange bug, but one of our customers reported it and I can reproduce it as well.

First:

var app = NetOffice.OutlookApi.Application.GetActiveInstance() ?? new NetOffice.OutlookApi.Application();
var mail = app.CreateItem(OlItemType.olMailItem) as MailItem;
--> [exception #1] NetOffice.Exceptions.MethodCOMException: Failed to proceed Method on Outlook.Application=>CreateItem.
    --> [exception #2] System.Runtime.InteropServices.COMException: Unbekannter Name. (Ausnahme von HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))

It seems that the "GetActiveInstance" returns something "broken" if XmlSpy is running:

image

If XmlSpy is not running the result is this:

image

I have no idea why XmlSpy (a completely separat application) has such an effect on our application and on NetOffice.

Our workaround now is, that we check if the ActiveInstance is broken or not and if yes, we return a new Application object.

My main question would be: Any idea why GetActiveInstance might return something strange?

Best regards, Robert

jozefizso commented 1 month ago

Please, contact XmlSpy support.

https://www.altova.com/support