Error associating Azure SQL database with Azure website: System.NullReferenceException: Object reference not set to an instance of an object -
i having strange error publishing website azure. published service using vs 2010 have run error in connecting database website. login page works, of pages on site, rely on same database. page issue comes following text:
server error in '/' application. object reference not set instance of object. description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.nullreferenceexception: object reference not set instance of object. source error: unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using exception stack trace below. stack trace: [nullreferenceexception: object reference not set instance of object.] mao.controllers.reviewcontroller.index() +603 lambda_method(closure , controllerbase , object[] ) +62 system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters) +14 system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) +214 system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) +27 system.web.mvc.<>c__displayclass15.<invokeactionmethodwithfilters>b__12() +55 system.web.mvc.controlleractioninvoker.invokeactionmethodfilter(iactionfilter filter, actionexecutingcontext precontext, func`1 continuation) +253 system.web.mvc.<>c__displayclass17.<invokeactionmethodwithfilters>b__14() +21 system.web.mvc.controlleractioninvoker.invokeactionmethodfilter(iactionfilter filter, actionexecutingcontext precontext, func`1 continuation) +253 system.web.mvc.<>c__displayclass17.<invokeactionmethodwithfilters>b__14() +21 system.web.mvc.controlleractioninvoker.invokeactionmethodwithfilters(controllercontext controllercontext, ilist`1 filters, actiondescriptor actiondescriptor, idictionary`2 parameters) +191 system.web.mvc.controlleractioninvoker.invokeaction(controllercontext controllercontext, string actionname) +324 system.web.mvc.controller.executecore() +106 system.web.mvc.controllerbase.execute(requestcontext requestcontext) +91 system.web.mvc.controllerbase.system.web.mvc.icontroller.execute(requestcontext requestcontext) +10 system.web.mvc.<>c__displayclassb.<beginprocessrequest>b__5() +34 system.web.mvc.async.<>c__displayclass1.<makevoiddelegate>b__0() +19 system.web.mvc.async.<>c__displayclass8`1.<beginsynchronous>b__7(iasyncresult _) +10 system.web.mvc.async.wrappedasyncresult`1.end() +62 system.web.mvc.<>c__displayclasse.<endprocessrequest>b__d() +48 system.web.mvc.securityutil.<getcallinapptrustthunk>b__0(action f) +7 system.web.mvc.securityutil.processinapplicationtrust(action action) +22 system.web.mvc.mvchandler.endprocessrequest(iasyncresult asyncresult) +60 system.web.mvc.mvchandler.system.web.ihttpasynchandler.endprocessrequest(iasyncresult result) +9 system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +9629708 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +155
the error occurs within following section of code:
public actionresult shortdateresponse(int reviewid, int questionid, string response) { if (string.isnullorempty(response)) { var answer = repository.getanswerbyquestionid(reviewid, questionid); if (answer != null) { repository.deleteanswerbyid(answer.id); } } else { try { datetime date = datetime.parseexact(response, "mm/yyyy", cultureinfo.invariantculture); repository.shortdateresponse(reviewid, questionid, date); } catch (exception fe) { throw new argumentexception("date format should mm/yyyy", fe); } } return json(new { success = true, error = "none" }); }
on line:
datetime date = datetime.parseexact(response, "mm/yyyy", cultureinfo.invariantculture);
as such, seems me code not responsible.
i have tried uploading database azure multiple different ways, , according various microsoft tutorials, , have reviewed others have presented similar questions on , other places. @ point not sure how move forward, i'm asking.
initially, used sql management studio 2008r's "extract data-tier application" , "import data-tier application" load schema database, "export data" , "import data" load data onto server. ensured commandtimeout variable sat 0 tables nothing lost along way, , sure enough, showed on azure database. when presented aforementioned error, attempted use "generate scripts" upload schema, in case there had been error previous process. used export/import data put data on website. received same error.
this website work on internal servers, has been deployed elsewhere, i'd migrate azure if possible. also, have checked uploaded website linked local sql servers , has worked properly, issue lies in upload of sql database azure servers.
i aware many people error have been able solve editing connection strings within web.config. have looked this, , have manually edited connection string via filezilla format put forth on various websites, no avail.
i appreciate insights have, , let me know if need more details. thank you!
one thought might firewall rule on sql azure instance. in windows azure management portal, go "configure" page sql azure server. set "yes" allow windows azure services?
can post code controller action mao.controllers.reviewcontroller.index() can see null reference exception occurs?
Comments
Post a Comment