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.
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)]));
});
});
}
Hi Steve,
We are not aware of there being any issues with the SqlServerCache and IDistributedCache.
The "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." message suggests that the Resolve Document request is failing but the last part - "Object reference not set to an instance of an object" is too ambiguous to draw any conclusions from it.
In order to get more information about the error, please produce and share in this ticket the following logs:
Even better, if possible, attach a sample project where the issue is reproducible so that we may debug it locally.
I will be looking forward to receiving an update from you.
Hi Dimitar
The trace option resulted in the error:
IOException: The process cannot access the file 'D:\home\site\wwwroot\log.txt' because it is being used by another process.
I ran Fiddler Jam and have a link that I don't want to post here. How can I share it with you privately?
Hi Steve,
I opened a new support ticket so that you may share the logs there.