Uri does not exist

I have a report that grabs images from Azure Blob Storage. It was working just fine until I updated to FastReports.Net 2025.1.6. I just tested with FastReports.Net 2025.2.4 and the same thing is happening.

In my Code page, I have a function:

public string EscapeString(string myString)      

  {

    return Uri.EscapeDataString(myString);

  }  

Through some research, during Compile, it looks like AddStubClasses in MsAssemblyDescriptor shows that Uri belongs to System.Net instead of System.

Comments

  • I have been using the Fast Report .NET Designer to generate the .rpt file. The code page always has default using statements. I had tried a combination of different attempts but still cannot seem to get EscapeDataString to work. I may just end up writing my own function for escaping the strings. Below are my attempts.

    -----

    using System;

    Uri.EscapeDataString(myString);


    This previews in the Designer but not from my API using FastReport.Net v 2025.1.16

    "Exception occurred: (21,15): Error CS0103: The name 'Uri' does not exist in the current context\r\n"

    -----

    using System;

    System.Uri.EscapeDataString(myString);


    This previews in the Designer but not from my API using FastReport.Net v 2025.1.16

    "Exception occurred: (21,15): Error CS1069: The type name 'Uri' could not be found in the namespace 'System'. This type has been forwarded to assembly 'System.Private.Uri, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.\r\n"

    -----

    using System;

    using System.Private;

    System.Private.Uri.EscapeDataString(myString);


    In the Designer, 

    "Error CS0234: The type or namespace name 'Private' does not exist in the namespace 'System' (are you missing an assembly reference?)"

    From the API,

    "Exception occurred: (22,15): Error CS0234: The type or namespace name 'Uri' does not exist in the namespace 'System.Private' (are you missing an assembly reference?)\r\n"

    -----

    using System;

    using System.Net;

    Uri.EscapeDataString(myString);


    This previews in the Designer but not from my API using FastReport.Net v 2025.1.16

    "Exception occurred: (22,19): Error CS0117: Please, don't use the method 'EscapeDataString'\r\n"

    -----

    using System;

    using System.Net;

    System.Net.Uri.EscapeDataString(myString);


    This previews in the Designer but not from my API using FastReport.Net v 2025.1.16

    "Exception occurred: (22,19): Error CS0117: Please, don't use the method 'EscapeDataString'\r\n"

  • Hello!

    To resolve your issue, wrap the data in C# and pass the final value to the report:

    var rows = source.Select(x => new Row
    {
    Url = x.Url,
    EscapedUrl = Uri.EscapeDataString(x.Url) // standard C#, outside the report script
    }).ToList();
    
    report.RegisterData(rows, ‘Rows’);
    report.SetParameterValue(‘BlobUrl’, Uri.EscapeDataString(url));
    

    If you need the function specifically within an expression, register your own static function and call it as [EscapeUri([Rows.Url])].

This discussion has been closed.