<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RE: Compiler error at line 64: Unexpected character '$' in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/Compiler-error-at-line-64-Unexpected-character/m-p/66335#M18940</link>
    <description>Hi Andrei,&lt;BR /&gt;&lt;BR /&gt;When moving the code to BP, suggest replacing the &lt;SPAN&gt;Console.Error.WriteLine lines with the throw exception as you would not have anything to write to in BP environment.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Krishna A&lt;BR /&gt;Blue Prism&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Tue, 20 Oct 2020 10:54:00 GMT</pubDate>
    <dc:creator>KrishnaA</dc:creator>
    <dc:date>2020-10-20T10:54:00Z</dc:date>
    <item>
      <title>Compiler error at line 64: Unexpected character '$'</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Compiler-error-at-line-64-Unexpected-character/m-p/66334#M18939</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I have a global code stage in C# . The code works perfect in Visual Studio but when copying over to BP gives the following error&lt;BR /&gt;Page: Initialise&lt;BR /&gt;Stage: Stage1&lt;BR /&gt;Type: Error&lt;BR /&gt;Action: Validate&lt;BR /&gt;Description: Compiler error at line 64: Unexpected character '$'&lt;BR /&gt;Repairable: No&lt;BR /&gt;&amp;nbsp;However removing the $ sign makes things worse as it ends up afterwards saying that a number of brackets are missing&lt;BR /&gt;&lt;BR /&gt;Anyone witnessed this error_&lt;BR /&gt;class Credential&lt;BR /&gt;{&lt;BR /&gt;// accout region, use 'default' value unless being instructed otherwise&lt;BR /&gt;private const string d_region = "default";&lt;BR /&gt;// Once created each token will be valid only for the following specified period(in seconds).&lt;BR /&gt;// This value is ajustable on client side, but note that increasing this value too much &lt;BR /&gt;// might not suffice for security concerns, as well as too little value could lead to &lt;BR /&gt;// JWT token invalidation before it being received by the beap server due to network delays.&lt;BR /&gt;// You can adjust this value for your need or use default value unless you definitely know &lt;BR /&gt;// that you need to change this value.&lt;BR /&gt;private const int d_lifetime = 25;&lt;BR /&gt;/// &amp;lt;summary&amp;gt;&lt;BR /&gt;/// Provides access to client id parsed from credential.txt file.&lt;BR /&gt;/// &amp;lt;/summary&amp;gt;&lt;BR /&gt;[JsonProperty("client_id")]&lt;BR /&gt;public string ClientId { get; set; }&lt;BR /&gt;/// &amp;lt;summary&amp;gt;&lt;BR /&gt;/// Accepts client secret form json deserializer and decodes it to bytes.&lt;BR /&gt;/// &amp;lt;/summary&amp;gt;&lt;BR /&gt;[JsonProperty("client_secret")]&lt;BR /&gt;public string ClientSecret { set { DecodedSecret = FromHexString(value); } }&lt;BR /&gt;/// &amp;lt;summary&amp;gt;&lt;BR /&gt;/// Provides access to decoded client secret.&lt;BR /&gt;/// &amp;lt;/summary&amp;gt;&lt;BR /&gt;public byte[] DecodedSecret { get; private set; }&lt;BR /&gt;/// &amp;lt;summary&amp;gt;&lt;BR /&gt;/// Converts hexadecimal string to bytes.&lt;BR /&gt;/// &amp;lt;/summary&amp;gt;&lt;BR /&gt;/// &amp;lt;param name="s"&amp;gt;Input hexadecimal string.&amp;lt;/param&amp;gt;&lt;BR /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;BR /&gt;static private byte[] FromHexString(string input)&lt;BR /&gt;{&lt;BR /&gt;return Enumerable.Range(0, input.Length)&lt;BR /&gt;.Where(charIdx =&amp;gt; charIdx % 2 == 0)&lt;BR /&gt;.Select(charIdx =&amp;gt; Convert.ToByte(input.Substring(charIdx, 2), 16))&lt;BR /&gt;.ToArray();&lt;BR /&gt;}&lt;BR /&gt;/// &amp;lt;summary&amp;gt;&lt;BR /&gt;/// Loads credentials from credential.txt file.&lt;BR /&gt;/// &amp;lt;/summary&amp;gt;&lt;BR /&gt;/// &amp;lt;param name="d_credentialPath"&amp;gt;Path to credential.txt file.&amp;lt;/param&amp;gt;&lt;BR /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;BR /&gt;public static Credential LoadCredential(string d_credentialPath = "credentials/credential.txt")&lt;BR /&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;using StreamReader fileInput = new StreamReader(d_credentialPath);&lt;BR /&gt;using var jsonInput = new JsonTextReader(fileInput);&lt;BR /&gt;var clientCredential = new JsonSerializer().Deserialize&amp;lt;Credential&amp;gt;(jsonInput);&lt;BR /&gt;string clientSecret = Convert.ToBase64String(clientCredential.DecodedSecret);&lt;BR /&gt;&lt;BR /&gt;Console.WriteLine($"client id: {clientCredential.ClientId}");&lt;BR /&gt;Console.WriteLine($"client secret (base64 encoded): {clientSecret}");&lt;BR /&gt;Console.WriteLine();&lt;BR /&gt;&lt;BR /&gt;return clientCredential;&lt;BR /&gt;}&lt;BR /&gt;catch (JsonReaderException error)&lt;BR /&gt;{&lt;BR /&gt;Console.Error.WriteLine($"Cannot read credential file, probably not in JSON format: {error.Message}");&lt;BR /&gt;}&lt;BR /&gt;catch (UnauthorizedAccessException)&lt;BR /&gt;{&lt;BR /&gt;Console.Error.WriteLine($"Cannot access credential file, check file permissions.");&lt;BR /&gt;}&lt;BR /&gt;catch (ArgumentException error)&lt;BR /&gt;{&lt;BR /&gt;Console.Error.WriteLine($"{error.Message}");&lt;BR /&gt;}&lt;BR /&gt;catch (IOException error)&lt;BR /&gt;{&lt;BR /&gt;Console.Error.WriteLine($"Cannot open credential file \nerror description: {error.Message}");&lt;BR /&gt;}&lt;BR /&gt;Environment.Exit(-1);&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/// &amp;lt;summary&amp;gt;&lt;BR /&gt;/// Creates new JWT token for the given input request parameters.&lt;BR /&gt;/// &amp;lt;/summary&amp;gt;&lt;BR /&gt;/// &amp;lt;param name="host"&amp;gt;the beap host being accessed.&amp;lt;/param&amp;gt;&lt;BR /&gt;/// &amp;lt;param name="path"&amp;gt;URI path of the accessed endpoint.&amp;lt;/param&amp;gt;&lt;BR /&gt;/// &amp;lt;param name="method"&amp;gt;HTTP method used to access the endpoint.&amp;lt;/param&amp;gt;&lt;BR /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;BR /&gt;internal string CreateToken(string host, string path, string method)&lt;BR /&gt;{&lt;BR /&gt;string guid = Guid.NewGuid().ToString();&lt;BR /&gt;// Get unix timestamp&lt;BR /&gt;long issueTime = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;&lt;BR /&gt;// Create key for JWT signature&lt;BR /&gt;SymmetricSecurityKey securityKey = new SymmetricSecurityKey(DecodedSecret);&lt;BR /&gt;// Define JWT signing key and algorythm&lt;BR /&gt;SigningCredentials signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);&lt;BR /&gt;// Create JWT header container object&lt;BR /&gt;var header = new JwtHeader(signingCredentials);&lt;BR /&gt;// Create JWT payload container object&lt;BR /&gt;var payload = new JwtPayload&lt;BR /&gt;{&lt;BR /&gt;{ JwtRegisteredClaimNames.Iss, ClientId },&lt;BR /&gt;{ JwtRegisteredClaimNames.Iat, issueTime },&lt;BR /&gt;{ JwtRegisteredClaimNames.Nbf, issueTime },&lt;BR /&gt;{ JwtRegisteredClaimNames.Exp, issueTime + d_lifetime },&lt;BR /&gt;{ "host", host },&lt;BR /&gt;{ "path", path },&lt;BR /&gt;{ "region", d_region },&lt;BR /&gt;{ "jti", guid },&lt;BR /&gt;{ "method", method },&lt;BR /&gt;{ "client_id", ClientId }&lt;BR /&gt;};&lt;BR /&gt;// Create JWT token object&lt;BR /&gt;JwtSecurityToken jwtToken = new JwtSecurityToken(header, payload);&lt;BR /&gt;// Serialize JWT token object to base64 encoded string&lt;BR /&gt;return new JwtSecurityTokenHandler().WriteToken(jwtToken);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Andrei Cozma&lt;BR /&gt;Data&lt;BR /&gt;Zurich&lt;BR /&gt;Europe/Madrid&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Oct 2020 00:03:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Compiler-error-at-line-64-Unexpected-character/m-p/66334#M18939</guid>
      <dc:creator>AndreiCozma</dc:creator>
      <dc:date>2020-10-16T00:03:00Z</dc:date>
    </item>
    <item>
      <title>RE: Compiler error at line 64: Unexpected character '$'</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Compiler-error-at-line-64-Unexpected-character/m-p/66335#M18940</link>
      <description>Hi Andrei,&lt;BR /&gt;&lt;BR /&gt;When moving the code to BP, suggest replacing the &lt;SPAN&gt;Console.Error.WriteLine lines with the throw exception as you would not have anything to write to in BP environment.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Krishna A&lt;BR /&gt;Blue Prism&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Oct 2020 10:54:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Compiler-error-at-line-64-Unexpected-character/m-p/66335#M18940</guid>
      <dc:creator>KrishnaA</dc:creator>
      <dc:date>2020-10-20T10:54:00Z</dc:date>
    </item>
    <item>
      <title>RE: Compiler error at line 64: Unexpected character '$'</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Compiler-error-at-line-64-Unexpected-character/m-p/66336#M18941</link>
      <description>It may be the version of C# that Blue Prism is targeting; string interpolation was added in version 6 of C#, and I think Blue Prism is targeting version 5.&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Nicholas Zejdlik&lt;BR /&gt;RPA Developer&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Oct 2020 13:02:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Compiler-error-at-line-64-Unexpected-character/m-p/66336#M18941</guid>
      <dc:creator>NicholasZejdlik</dc:creator>
      <dc:date>2020-10-20T13:02:00Z</dc:date>
    </item>
    <item>
      <title>RE: Compiler error at line 64: Unexpected character '$'</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Compiler-error-at-line-64-Unexpected-character/m-p/66337#M18942</link>
      <description>Hi Andrei,&lt;BR /&gt;&lt;BR /&gt;To expand on the last comment from Nicholas a little, Blue Prism 6.8 included an update to the code compiler used by code stages that moves the targeted C# version to 7 (this can be found under &lt;SPAN&gt;&lt;STRONG&gt;US-7483&lt;/STRONG&gt; in the release notes)&lt;/SPAN&gt;, but prior to this Nicholas is correct and it would be C# version 5 that the code stages would be using.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Rob&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Robert Nicklin&lt;BR /&gt;Senior Product Owner&lt;BR /&gt;Blue Prism&lt;BR /&gt;Warrington, England&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Oct 2020 08:44:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Compiler-error-at-line-64-Unexpected-character/m-p/66337#M18942</guid>
      <dc:creator>robert.nicklin</dc:creator>
      <dc:date>2020-10-26T08:44:00Z</dc:date>
    </item>
  </channel>
</rss>

