UiPath Custom Activity

Hi,
I have created a custom activity to convert a secure string to string. Everything is good but, I’m not getting any output. It is nothing. I guess it’s the issue with C# code. Can anyone correct the code? and where i’m missing?

My custom Activity:

C# 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;
using System.Net.Security;

namespace ClassCustomActivitySrini
{
public class SimpleFormula : CodeActivity
{
[Category(“Input”)]
[RequiredArgument]
public InArgument Input { get; set; }

    [Category("Output")]
    public OutArgument<String> output { get; set; }
    public string Str { get; private set; }
    
    protected override void Execute(CodeActivityContext context)
    {

        Str = new System.Net.NetworkCredential(string.Empty, Input);
        output.Set(context, Str);
    }
} 

}

Thanks!

Try this( modified)

public class SimpleFormula : CodeActivity
    {
        [Category(“Input”)]
        [RequiredArgument]
        public InArgument<SecureString> Input { get; set; }

        [Category("Output")]
        public OutArgument<String> output { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            var strSecPassword = Input.Get(context);
            var strPassword = new System.Net.NetworkCredential(string.Empty, strSecPassword).Password;
            output.Set(context, strPassword);
        }
    }

Thank you @vvaidya, but still getting conversion error- from secure string to string

Don’t have studio handy, try modified code above.

@vvaidya, I just started C#, don’t know how to solve this error. Can you please provide the modified code?

Thanks!

It is in my first post above.

@Sat see what he changed:

1 Like

Thank you @nadim.warsi

Well dont thank me :slight_smile: i just should what he had edited in his post.
Please mark that answer as solution.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.