i spend a lot of time to resolve this problem but to working. I use server.mapPath function to specific valid path file. why only local machine is working but not working in production because i this (server.mapPath) is a great function
c#
[WebMethod]
public string getDocument(string id, string location)
{
ReportDocument report = new ReportDocument();
report.Load(Server.MapPath("~/Reports/report1.rpt"));
Stream stream = report.ExportToStream(ExportFormatType.PortableDocFormat);
MemoryStream streamReader = new MemoryStream();
stream.CopyTo(streamReader);
return Convert.ToBase64String(streamReader.ToArray());
}
ajax
function printPreview(reqID) {
var base_url = "/Webservice/webService.asmx/getDocument";
$.ajax({
type: "POST",
url: base_url,
data: "{'id': " + reqID + ", 'location':'" + objUser.location + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
console.log(response.d)
},
error: function (response) {
alert(response.d);
}
});
Check API backend Look like the problem happen when ReportDocument.Load because i test in production with File.Exists function without ReportDocument.Load and the result return file is exist but cannot load why ? Have any one else know this ?
error exception
Could not load file or assembly 'CrystalDecisions.CrystalReports.Engine, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
I'm add bindingRedirect from 13.0.2000.0 -> 13.0.3500.0 in web.config and still not working. I'm see in server production C:/Windows/assembly all of (CrystalDecisions.Shared, CrystalDecisions.CrystalReports.Engine, CrystalDecisions.ReportSource) is version 13.0.2000.0 but why another project is working. Please help me, thank you so much.