An error occurred during local report processing.The definition of the report ' is invalid
EDIT: Solution seem to be that the report defintion was not loaded. It can be done for example by
var reportStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ReportName.rdlc");
localReport.LoadReportDefinition(reportStream);
Old suggestion - not applicable here:
Honestly, there might be different things.
First of all, setting parameters is special. If your projects runs in .NET 4 or higher the reporting engine will run within a different app domain than your application. So you have to set permissions that the parameters can be used. Otherwise it rejects all parameter.
var report = new LocalReport();
report.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));
Another issue could be that you are using a different ReportViewer version on your development machine than on the deployment machine.
RDL Report not rendering
Change your code like below:-
private readonly IHostingEnvironment _webHostEnvironment;
public HomeController( IHostingEnvironment webHostEnvironment)
{
_webHostEnvironment = webHostEnvironment;
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
}
public async Task<IActionResult> Print()
{
string mimetype = "";
int extension = 1;
var path = $"{this._webHostEnvironment.WebRootPath}\\Reports\\test.rdlc";
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("rp1", "Test Value to parameter");
LocalReport localReport = new LocalReport(path);
var result = localReport.Execute(RenderType.Pdf, extension, parameters, mimetype);
return File(result.MainStream, "application/pdf");
}
Also, don't forget to install some NuGet packages as needed.
Hope it will resolve your issue. for more details and connected things, you can read this article:-
http://blog.geveo.com/IntegratingRDLCReportsToNetCoreProjects
UPDATE
App.config
<connectionStrings>
<add
name="MyConnectionString"
connectionString="Data Source=DESKTOP-N41V6ER\SQLEXPRESS;Initial
Catalog=MyDatabase;User ID=userName;Password=password"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
User ID and Password means using SQL credentials, not Windows, but still very simple - just go into your Security section of your SQL Server and create a new Login. Give it a username and password, and give it rights to your database.
AGAIN UPDATE(Data Source Connect)
Now select the object and click next:-
below, the design of a simple report that allows displaying the (assume)product data in your connected database. then click finish.
then click the ok button:-
then you will find your database table in dataset:-
now you can drag and drop your data, which place you want to show in your report file.
.................................................................
.................................................................
AGAIN UPDATE(Data base Connect)
First right click on your report project- => Add=>New Item then you will show:-
above add an entity data model to the windows form project.then click Add
.then:-
Above,click New Connection
.
Above,click Continue
.
Above, give your server name. my machine has just one (SQL server)installed for that i am using .
and select SQL Server in Authentication box.
Above,then click Ok
.you have obisouly select DB name which you want.
Above, type your DB name carefully which you already selected.
Above, I select my product table because I will show that. then click finish
MVC 5 application RDLC Report throws an exception after hosting but works fine with visual studio
Without really knowing what the cause is, I can guess what it could be. It's possible that the RDLC Report File (e.g. MyReport.rdlc
) was not properly deployed to target environment, or doesn't reside in the expected folder (relative paths) when the executing directory changes.
In Visual Studio, ensure that Copy to Output Directory
Property is set to Copy if newer/always
, and when executing on IIS, the Files could appear within \bin
directory, while locally, they're probably within bin\Debug
.
When passing in the File name of MyReport.rdlc
, in our application, we make it configurable and construct the path like this:
var rdlcFullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.AppSettings["ReportingPath"], "MyReport.rdlc");
In the web.config
file, add the Path setting:
<add key="ReportingPath" value="bin\Reports" />
You can override the setting for every environment to match the target structure.
Error. An error occurred while processing your request
I believe I found what I was looking for:
How to deploy ASP.NET MVC 4 application using localDB to local IIS on Windows 7?
This did the trick, though probably not a good idea for production server.
I guess one would have to do some type of restore on the SQL server from the .mdf.
All one has to do is publish their files, drop them in the wwwroot folder (along with the app_data folder containing your database and logs) and set the pool to local and you should be set.
IIS conflict with Sql Server Reporting Services
I changed my controller from Reports to MyReports and this resolved the conflict.
Related Topics
How to Suppress a Stylecop Warning
Is There a C# Generic Constraint for "Real Number" Types
PDF Compression with Itextsharp
"Requested Uri Is Invalid" During Upload with Ftpwebrequest
What Are C# Lambda's Compiled Into? a Stackframe, an Instance of an Anonymous Type, Or
Crud Operations Using Datagridview, Datatable and Dataadapter - Cannot Add New Row to Datagridview
Better Way to Cast Object to Int
How to Use Rsa to Encrypt Files (Huge Data) in C#
Datetimepicker: Pick Both Date and Time
C# Instantiate Generic List from Reflected Type
Generic C# Code and the Plus Operator
Curiously Recurring Template Pattern and Generics Constraints (C#)
How to Get a Combination of Keys in C#
Xml Deserialization of Collection Property with Code Defaults