NetofficeFw Exception when calling GetActiveInstance

167 Views Asked by At

I am trying to open the active instance of Outlook 365 (32bit) with NetOfficeFw 1.7.8 on visual studio 2017 application running at 64 bit. I have Outlook 365 Opened. My class starts like this:

using System;
using System.Linq;
using NetOffice.OutlookApi;
using NetOffice.OutlookApi.Enums;
using Prism.Core;
using Prism.Core.SimpleTypes;

namespace Prism.MSOffice.Integration
{
    public class OutlookActivity : Entity
    {
        public string Subject { get; set; }
        public string Body { get; set; }
        public string Location { get; set; }
        public DateTime ScheduledStart { get; set; }
        public DateTime ScheduledEnd { get; set; }
        public string NoteText { get; set; }
        public ActivityType ActivityType { get; set; }

        public string Save()
        {
            Application tempApp = Application.GetActiveInstance();   <<== Exception At this line
        
            if (tempApp == null)
            {
                tempApp = new Application();
            }
    ...

I get this Exception at my call to GetActiveInstance: System.Runtime.InteropServices.COMException: 'Error HRESULT E_FAIL has been returned from a call to a COM component.'

The stack trace:

   at System.Windows.Forms.NativeMethods.IProvideClassInfo.GetClassInfo()
   at System.Windows.Forms.ComponentModel.Com2Interop.Com2TypeInfoProcessor.FindTypeInfo(Object obj, Boolean wantCoClass)

My Google search did not return anything useful and banging my head on my desk is not working.

UPDATE

I changed my project to 32bit and ran it, but the Exception popped up in the same place as 64bit.

0

There are 0 best solutions below