c# - Generating .rdlc report works on local but not after deploying to azure -
in asp.net mvc 5 application have following method:
public actionresult sendmailasastudent(string studentid, string companyid, int applicationid, string companycvr, string studentcpr) { var manager = new usermanager<applicationuser>(new userstore<applicationuser>(new applicationdbcontext())); var student = manager.findbyid(studentid); var company = manager.findbyid(companyid); var application = db.applications.find(applicationid); project projectobj = db.projects.find(application.projectid); var mymessage = new sendgridmessage(); mymessage.from = new mailaddress("info@leepio.dk"); mymessage.addto(student.email); mymessage.addto(company.email); mymessage.subject ="the contract " + projectobj.title + " signed!"; mymessage.html = "here final contract"; localreport localreport = new localreport(); localreport.reportpath = server.mappath("~/contracts/contract.rdlc"); reportparameter cvrparameter = new reportparameter("cvrparameter", companycvr); reportparameter companynameparameter = new reportparameter("companynameparameter", company.companyname); reportparameter companyaddressparameter = new reportparameter("companyaddressparameter", company.address); reportparameter studentnameparameter = new reportparameter("studentnameparameter", student.firstname+" "+student.lastname); reportparameter studentaddressparameter = new reportparameter("studentaddressparameter", student.address); reportparameter studentzipcodeparameter = new reportparameter("studentzipcodeparameter", student.zipcode); reportparameter jobstartdateparameter = new reportparameter("jobstartdateparameter", projectobj.startdate); reportparameter jobenddateparameter = new reportparameter("jobenddateparameter", projectobj.enddate); reportparameter jobdescriptionparameter = new reportparameter("jobdescriptionparameter", projectobj.description); reportparameter jobhoursperweekparameter = new reportparameter("jobhoursperweekparameter", projectobj.hoursperweek.tostring()); reportparameter jobhourlyrateparameter = new reportparameter("jobhourlyrateparameter", projectobj.hourlyrate.tostring()); reportparameter cprparameter = new reportparameter("cprparameter", studentcpr); localreport.setparameters(new reportparameter[] { cprparameter }); localreport.setparameters(new reportparameter[] { cvrparameter }); localreport.setparameters(new reportparameter[] { companynameparameter }); localreport.setparameters(new reportparameter[] { companyaddressparameter }); localreport.setparameters(new reportparameter[] { studentnameparameter }); localreport.setparameters(new reportparameter[] { studentaddressparameter }); localreport.setparameters(new reportparameter[] { studentzipcodeparameter }); localreport.setparameters(new reportparameter[] { jobstartdateparameter }); localreport.setparameters(new reportparameter[] { jobenddateparameter }); localreport.setparameters(new reportparameter[] { jobdescriptionparameter }); localreport.setparameters(new reportparameter[] { jobhoursperweekparameter }); localreport.setparameters(new reportparameter[] { jobhourlyrateparameter }); string reporttype = "pdf"; string mimetype; string encoding; string filenameextension = "pdf"; warning[] warnings; string[] streams; var renderedbytes = localreport.render(reporttype, "", out mimetype, out encoding, out filenameextension, out streams, out warnings); response.addheader("content-disposition", "attatchment; filename=contract." + filenameextension); memorystream stream = new memorystream(renderedbytes); mymessage.addattachment(stream, "contract.pdf"); var apikey = "key removed post"; var transportweb = new web(apikey); transportweb.deliverasync(mymessage); contract contract = new contract(); contract.studentid = studentid; contract.companyid = companyid; contract.cvr = companycvr; contract.applicationid = applicationid; contract.issigned = true; db.contracts.add(contract); db.savechanges(); return redirecttoaction("index", "projects"); }
if run on localhost works, sends mail report file succesfully. when deploying azure no longer works. commenting out report generation , adding attachment makes work, pinpointed problem around report generation.
what can possibly cause no longer work on site? have checked parameters not null.
i turned on error showing in web.config so:
<customerrors mode="off">
then got error:
could not load file or assembly 'microsoft.reportviewer.processingobjectmodel, version=10.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' or 1 of dependencies. system cannot find file specified.
thanks crowcoder found out problem, had install microsoft.report.viewer 10.0.0 nuget package manager!
built, published , works!
Comments
Post a Comment