UiPath Custom Activity use Office Object as output argument

Hi All,

I create a custom activity in c# using Visual Studio and following this guide https://docs.uipath.com/developer/other/latest/developer-guide/creating-activities-with-code

My .nuget package works if as OutArgument I set type etc etc…
But when I try to set something like <Microsoft.Office.Interop.Outlook.MailItem> as type , when I try to use the activity inside Studio it gives me this error:
Get object by ID: Expression Activity type ‘CSharpReference`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.

In Studio I’ve also imported the same namespace Microsoft.Office.Interop.Outlookin order to get the output argument of that activity

I don’t think the problem is related to the use of Microsoft.Office.Interop.Outlook because because I have another activity which works correctly using it but it uses only string as input/output.

here my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Activities;
using System.ComponentModel;
using System.Security.Cryptography;
using Microsoft.Office.Interop.Outlook;
using System.Activities.Statements;
using System.Net.Mail;

namespace OutlookCustomActivity
{

public class GetObjectByID : CodeActivity
{
    
    [Category("Input")]
    [Description("Enter the UID of the outlook object you want to move")]
    public InArgument<string> UID { get; set; }

    [Category("Input")]
    [RequiredArgument]
    [Description("Enter the email account you want to use")]
    public InArgument<string> email_account { get; set; }

    [Category("Output")]
    
    [Description("Outlook MailItem")]
    public OutArgument<MailItem> out_mailItem { get; set; }

    [Category("Output")]
    
    [Description("Outlook MeetingItem")]
    public OutArgument<MeetingItem> out_meetingItem { get; set; }
    
    
    protected override void Execute(CodeActivityContext context)
    {
        
        Microsoft.Office.Interop.Outlook.Application oApp = null;
        Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null;

        oApp = new Microsoft.Office.Interop.Outlook.Application();
        mapiNamespace = oApp.GetNamespace("MAPI");


        try
        {
            mapiNamespace.Logon(email_account.Get(context));

        }
        catch (System.Exception e)
        {
            throw new ApplicationException("Error logging into with email account'" + email_account.Get(context) + "'.");
        }

        object item;
        try
        {
            item = mapiNamespace.GetItemFromID(UID.Get(context));

        }
        catch (System.Exception e)
        {
            throw new ApplicationException("Outlook object with UID '" + UID.Get(context) + "' not found.");
        }
        Microsoft.Office.Interop.Outlook.MailItem mailItem = null;
        Microsoft.Office.Interop.Outlook.MeetingItem meetingItem = null;
        //if item to move is an email
        if (item is Microsoft.Office.Interop.Outlook.MailItem)
        {
            mailItem = (Microsoft.Office.Interop.Outlook.MailItem)item;
            out_mailItem.Set(context, mailItem);
            out_meetingItem.Set(context, null);
        }
        //if item to move is a meeting
        if (item is Microsoft.Office.Interop.Outlook.MeetingItem)
        {
            meetingItem = (Microsoft.Office.Interop.Outlook.MeetingItem)item;
            out_meetingItem.Set(context, meetingItem);
            out_mailItem.Set(context, null);
        }
    }
}

}