Invoke code activity showing error while i am using c sharp language in it

i am getting the error as ‘System.Text’ is a namespace but is used like a variable and ‘System.Security.Cryptography’ is a namespace but is used like a variable while I am using the invoke code activity and writing as c sharp code in it

Welcome to the forum

May we ask for sharing with us the full code snippet, which is used within the invoke code?

please share the screenshot of error with activity proparities

You can’t write usings and classes in Invoke Code. For this you need to either restructure the code to use in Invoke Code, use the new Coded Workflows (source files) feature or wrap it in a Custom Activity.

We would also recommend to realign the code and to change it more into a script style

do the imports:


Rewrite to script style:

DateTime now = DateTime.UtcNow;
string myDate = now.ToString("r");

string stringToSign = "X-Date: " + myDate;
byte[] secretBytes = Encoding.UTF8.GetBytes(secret);
byte[] stringToSignBytes = Encoding.UTF8.GetBytes(stringToSign);

using (HMACSHA256 hmac = new HMACSHA256(secretBytes))
	byte[] hashBytes = hmac.ComputeHash(stringToSignBytes);
	string signature = Convert.ToBase64String(hashBytes);
	hmacAuth = string.Format("hmac username=\"{0}..........",username);


So, we can use it as a one time part.

For reusability we agree to:

1 Like