C# can't use variable value due to SecureString type

58 views Asked by At

Tell me, in the program it is necessary to use the password of one of the users to start the program, but when I use the value of the variable with the password, the following error occurs: cannot convert from string to System.Secure.Security.SecureString; the value must be obtained from the variable, and not entered from the keyboard.




using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Security;

public class Example
{
    public static void Main()
    {
        string password = "password";

        try
        {
            Process.Start("Notepad.exe", "MyUser", password, "MYDOMAIN");
        }
        catch (Win32Exception e)
        {
            Console.WriteLine(e.Message);
        }

    }
}
0

There are 0 answers