Telerik Forums
Reporting Forum
0 answers
155 views

Hello,

I am getting the following error when trying to print a report from my website:

But when in my local machine, it displays correctly. The database is the same, no changes between then.

Regards,

Alexandre

Alexandre
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 04 Jul 2023
0 answers
143 views

My report viewer was working without issue for some time until caching with DistributedSqlServerCache was implemented. It is configured as follows.

services.TryAddSingleton<IReportServiceConfiguration>(configuration =>
    new ReportServiceConfiguration {
        HostAppId = "Reports",
        ReportingEngineConfiguration = new ConfigurationBuilder().AddJsonFile(Path.Combine(configuration.GetService<IWebHostEnvironment>().ContentRootPath, "appsettings.json"), true).Build(),
        ReportSourceResolver = new UriReportSourceResolver(Path.Combine(configuration.GetService<IWebHostEnvironment>().ContentRootPath, "App_Data")).AddFallbackResolver(new TypeReportSourceResolver()),
        Storage = new MsSqlServerStorage("connection-string")
    }
);
public class ReportsController : ReportsControllerBase {
    public ReportsController(IReportServiceConfiguration reportServiceConfiguration) : base(reportServiceConfiguration) {
        reportServiceConfiguration.Storage.AcquireLock(string.Format("Lock-{0}", new Random().Next()));
    }
}

Note that the AcquireLock() method mentioned above was added in response to this comment from Telerik:

The interface also exposes a method called AcquireLock which is used from the service to enforce serialized access to all stored resources from each thread of the application and between the instances of the application in case of multi-instance environment (i.e., Web Farm)

Which I suspect may apply here, but unfortunately I can only hazard guess in light of its appalling lack of documentation.

A typical error message reported by the viewer is:

Error creating report document (Report = 'XXXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; Format = 'HTML5'). An error has occurred. Object reference not set to an instance of an object.

As a workaround, I have resorted to manually configuring the report viewer, then editing a method in the javascript file, from this:
function registerDocumentAsync(format, deviceInfo, useCache, baseDocumentId, actionId) {
    throwIfNotInitialized();
    throwIfNoReportInstance();

    return client.createReportDocument(clientId, reportInstanceId, format, deviceInfo, useCache, baseDocumentId, actionId).catch(function(xhrErrorData) {
        handleRequestError(xhrErrorData, utils.stringFormat(sr.errorCreatingReportDocument, [ utils.escapeHtml(report), utils.escapeHtml(format) ]));
    });
}

to this:

function registerDocumentAsync(format, deviceInfo, useCache, baseDocumentId, actionId) {
    throwIfNotInitialized();
    throwIfNoReportInstance();

    return client.createReportDocument(clientId, reportInstanceId, format, deviceInfo, useCache, baseDocumentId, actionId).catch(function () {
        console.log("Failed to create report document. A retry has been attempted.");

        return client.createReportDocument(clientId, reportInstanceId, format, deviceInfo, useCache, baseDocumentId, actionId).catch(function (xhrErrorData) {
            handleRequestError(xhrErrorData, utils.stringFormat(sr.errorCreatingReportDocument, [utils.escapeHtml(report), utils.escapeHtml(format)]));
        });
    });
}
Up until now, the second attempt has worked every time. The odd thing is, after the workaround is applied it can continue to work for some time without failing again, even after loading a different page. Given that I cannot reproduce this issue locally, I suspect there may be a race condition happening.
Steve
Top achievements
Rank 1
 updated question on 03 Jul 2023
3 answers
122 views

Hello,

I have a report wich has one parameter. When I try to pass a new value in javascript it does not accept it, and uses the sample parameter that is inside the report.

Parameter in the Report:

Passing Parameter in Javascript:

Where 'noFichaVistoria' is the variable containing the new parameter value.

Has anyone faced this before?

Alexandre

Nikolay
Telerik team
 answered on 30 Jun 2023
2 answers
125 views

Hi i'm davide, in these days i'm working for a project that requires telerik on windows form c# desktop application.        So i'm trying to figure out what i need to do it but i don't find pretty much anything online, i can't find a solution please help me.

My little exercise consist in asking a year of school (1 to 5) to print only the ones students in that year, cvyear is a int from 0 to 5, I'M ITALIAN SO 1) ANNO = YEAR, classes is a type class, stu is a list of student. CODE:

string year = cvyear.ToString();
            var report1 = new Telerik.Reporting.Report();
            report1.DataSource = null;
            reportViewer1.ReportSource = null;
            var objectDataSource1 = new Telerik.Reporting.ObjectDataSource();
            objectDataSource1.DataSource = null;
            objectDataSource1.DataSource = classes.Stu;
            report1.DataSource = objectDataSource1;
            Telerik.Reporting.ReportParameter reportParameter1 = new Telerik.Reporting.ReportParameter();
            reportParameter1.Name = "yearParam";
            reportParameter1.Text = "Enter Value for year";
            reportParameter1.Type = Telerik.Reporting.ReportParameterType.Integer;
            reportParameter1.AllowBlank = false;
            reportParameter1.AllowNull = false;
            reportParameter1.Value = year;
           
            reportParameter1.Visible = true;
            
            reportParameter1.AvailableValues.DataSource = objectDataSource1;
            reportParameter1.AvailableValues.ValueMember = "= Fields.Anno";
  
            Telerik.Reporting.Filter filter1 = new Telerik.Reporting.Filter();
            filter1.Expression = "= Fields.Anno";
            filter1.Operator = Telerik.Reporting.FilterOperator.Equal;
            filter1.Value = "="+ year;
            

            Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource();
            reportSource.ReportDocument = report1;
            reportViewer1.ReportSource = reportSource;
            reportViewer1.ClearHistory();
            
            reportViewer1.RefreshReport();

 

Davide
Top achievements
Rank 1
Iron
 updated answer on 29 Jun 2023
1 answer
219 views

This is my scenerio.
i have report in xml stored in database, report has subreports as uri            
<UriReportSource Uri="sub_report1.trdx">

i have rest api service that consume xml , render it as pdf and returns it as byte[].
And everything works fine but my custom resolver dosnt fire.

It seems to be that when I DO NOT use telerik_ReportViewer,  resolve event doesnt invoke, am i right? My rest api service does not even inherits from Telerik ReportsControllerBase

 

my desire is when i call renderReport customResolver is invoked, i download xml for subreport (based on uri trdx) and i put them together with main report and return "As complete"

Can i configure it to achieve what i want ?

my server side code

//xDoc represents report in xml

using var tr = new StringReader(xDoc.Root.ToString());
var xmlSerializer = new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
var report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(tr);

ReportProcessor reportProcessor = new ReportProcessor();
Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = report;

RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);

return result.DocumentBytes;

Dimitar
Telerik team
 answered on 28 Jun 2023
1 answer
214 views

On all of our reports we have a `CustomerId` and `UserId` that are part of our JWT token, this is what our reports controller looks like 


[Route("api/[controller]")]
[Authorize]
[ApiController]
public class ReportsController : ReportsControllerBase
{
    public ReportsController(IReportServiceConfiguration reportServiceConfiguration)
        : base(reportServiceConfiguration)
    {
    }
}

 

So how can we set the CustomerId and UserId on the server side?  We call our client side code like this:


$("#reportViewer1")
                    .telerik_ReportViewer({
                        serviceUrl:  "/api/reports/",
                        authenticationToken: token,
                        viewMode: "PRINT_PREVIEW",
                        
                        reportSource: {                            
                            report: fileName + ".trdp",

                            parameters: postData
                        },
                        //sendEmail: { enabled: true },
                    });


How can we set the token on the server side?
Dimitar
Telerik team
 answered on 28 Jun 2023
1 answer
267 views

[ENGLISH]

Greetings, I'm a newbie, I'm testing telerik while learning c# with visual studio and WinForms. The issue is that I have made a report that is later displayed in a reportviewer, the problem is that clicking on the print icon of the reportviewer adds a blank space to the right side of the sheet to be printed, it is worth mentioning that the sheet is set to A4 (margins 0.5mm, + width 20cm = 21cm =>A4).

Image 01 - The report design is seen,
Screenshot 02 - The reportviewer added in the windowsform is seen,
Image 03 - It is seen when the report is loaded, so far so good.
Image 04 - It is seen when I click on the print or preview icon (any of the two) and the blank space on the sheet is displayed. Even when printing a physical document, the additional space is shown.
Image 05 - This image shows the code that I use to pass data to the reportviewer and the table.

By code I have not added any configuration, only the filling of data to the table.

What am I doing wrong, do I need to configure any additional parameters? Please help.

 

[ESPAÑOL]

Saludos, soy novato, estoy probando telerik mientras aprendo c# con visual studio y WinForms. El asunto es que tengo realizado un informe que posteriormente se muestra en un reportviewer, el problema es que al hacer clic en el icono de imprimir del reportviewer se agrega un espacio en blanco al lado derecho de la hoja a imprimir, cabe mencionar que la hoja está configurada en A4 (margins 0.5mm, + width 20cm = 21cm =>A4).

Imagen 01 - Se ve el diseño de reporte, 
Imagen 02 - Se ve el reportviewer agregado en el windowsform,  
Imagen 03 - Se ve cuando se carga el reporte, hasta ahí todo bien. 
Imagen 04 - Se ve cuando doy clic en el icono de imprimir o previsualizar (cualquiera de los dos) y se muestra el espacio en blanco en la hoja. Inclusive al imprimir un documento físico se muestra el espacio adicional.
Imagen 05 - En esta imagen se ve el codigo que utlizo para pasar datos al reportviewer y a la tabla.

Por código no tengo agregado ninguna configuración, solamente el llenado de datos a la tabla.

¿Qué estaré haciendo mal, necesito configurar algún parámetro adicional? Ayuda por favor.
Momchil
Telerik team
 answered on 26 Jun 2023
2 answers
218 views

Hello,

I had a report in my application that was working fine, but suddendly it started displaying the following message:

Unable to get report parameters. An error has occurred. Cannot read a document with the specified schema: http://schemas.telerik.com/reporting/2023/1.0. You might be using an older version of the product.

Does anyone has ever seen that?

Regards,

Alexandre

 

 

Alexandre
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 24 Jun 2023
1 answer
309 views

Hi,

I use the telerik reporting version: 15.2.21.1125 .NET Core 6 MVC.

The service is working correctly, but there are errors in the logs.

And sometimes when I click to generate a report, I get this error.

 

RequestPath: /TelerikReporting/Report/clients/f06d6c18a51/instances/d88f958a6a9/documents

Exception.StackTrace:

{
  "ClassName": "System.NullReferenceException",
  "Message": "Object reference not set to an instance of an object.",
  "RemoteStackTraceString": null,
  "RemoteStackIndex": 0,
  "HResult": -2147467261,
  "HelpURL": null,
  "Depth": 0,
  "Source": "Telerik.Reporting",
  "StackTraceString": "   at Telerik.Reporting.Services.Engine.ReportEngine.CreateDocumentCore(ReportInstance instance, Refresh refresh, String format, Dictionary`2 deviceInfo, ReportDocumentState rds, String clientID)\n   at Telerik.Reporting.Services.Engine.ReportEngine.CreateDocument(String clientID, String instanceID, String format, Dictionary`2 deviceInfo, Boolean useCache, String baseDocumentID, String actionID)\n   at Telerik.Reporting.Services.AspNetCore.ReportsControllerBase.CreateDocument(String clientID, String instanceID, CreateDocumentArgs args)\n   at lambda_method473(Closure , Object , Object[] )\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\n--- End of stack trace from previous location ---\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)"
}

I would be grateful for your assistance.

Dimitar
Telerik team
 answered on 22 Jun 2023
1 answer
111 views

Hi,

We already have a licence for the 2023 Telerik Reporting licence. However, since our application uses R3 2017 Telerik Reporting, I wanted to install that instead. However, it keeps on installing the 2023 version. Could you please tell me where the R3 2017 version is and the link to download this particular version. 

Iva
Telerik team
 answered on 21 Jun 2023
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?