Asked by:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:Couldn't make connection on time of execution in a NULL reference/ No se puede realizar enlace en tiempo de ejecución en una referencia NULL.

Question
-
User-420639560 posted
I am desperate guys!. I was programming i tested a hundred times and everything worked fine now that i am trying to test it again i got this error Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:Couldn't make connection on time of execution in a NULL reference/
this is my code. The variable "Puntos" comes from the previous page from a <form action="">
@{ Layout = "~/_SiteLayout.cshtml"; Page.TItle="Inscripción por examen de colocación"; WebSecurity.RequireAuthenticatedUser(); var db=Database.Open("StarterSite"); var Puntos = Request["Puntos"].AsInt(); var Nivel = ""; var ModuloACursar = ""; if(Puntos <= 23) { Nivel = "Básico 1"; ModuloACursar = "BX101"; } else { if(Puntos <= 25) { Nivel = "Básico 3"; ModuloACursar = "BX301"; } else{ if(Puntos <= 34) { Nivel = "Básico 5"; ModuloACursar = "BX501"; } else{ if(Puntos <= 37) { Nivel = "Intermedio 2"; ModuloACursar = "IX201"; } else{ if(Puntos <= 46) { Nivel = "Intermedio 4"; ModuloACursar = "IX401"; } else{ if(Puntos <= 49) { Nivel = "Avanzado 1"; ModuloACursar = "AX101"; } else{ Nivel = "Avanzado 3"; ModuloACursar = "AX301"; } } } } } } var FechaIngreso = DateTime.Now; var FechaDePago = Request.Form["FechaDePago"].AsDateTime(); var MensajeDeErrorEnFechaDePago = ""; var Movimiento = ""; var ImagenURL = ""; var NombreImagen = ""; var MensajeDeErrorEnMovimiento = ""; var MensajeDeErrorEnImagen = ""; var CreacionDeMensajeOk = ""; var CreacionDeMensajeError = ""; var CursoId = db.QuerySingle("SELECT CursoId FROM Curso WHERE Modulo = @0 AND InicioDeCurso > @1",ModuloACursar, FechaIngreso); var AlumnoId = WebSecurity.CurrentUserId; var isValid = true; // If this is a POST request, validate and process data if (IsPost) { if (FechaDePago == null) { MensajeDeErrorEnFechaDePago = "Se requiere la fecha de pago."; isValid = false; } Movimiento = Request.Form["Movimiento"]; if (Movimiento == null) { MensajeDeErrorEnMovimiento = "El movimiento debe tener 4 numeros o más."; isValid = false; } if (isValid) { // Check if there was an image posted to the server. WebImage ImagenMovimiento = WebImage.GetImageFromRequest("ImagenMovimiento"); if (ImagenMovimiento != null) { try { NombreImagen = Guid.NewGuid().ToString() + ".png"; ImagenMovimiento.Save(@"~\Pagos\" + NombreImagen, "PNG"); } catch(Exception ex) { MensajeDeErrorEnImagen = "The image file you uploaded is not valid. " + ex.Message; CreacionDeMensajeError = "Cannot upload and process picture file."; isValid = false; } } } // If all information is valid, insert the news item. if (isValid) { if (db.Execute("INSERT INTO Pagos(Movimiento, ImagenURL, FechaDePago, AlumnoId) VALUES(@0, @1, @2, @3)", Movimiento, NombreImagen, FechaDePago, AlumnoId) == 1) { if (db.Execute("INSERT INTO Clase(AlumnoId, CursoId, FechaIngreso) VALUES(@0, @1, @2)", AlumnoId,CursoId.CursoId,FechaIngreso) == 1) { CreacionDeMensajeOk = "Tu inscripcion ha sido exitosa."; } } else { CreacionDeMensajeError = "No te pudiste inscribir a la clase."; } } } }
Thursday, July 28, 2016 6:19 AM
All replies
-
User-420639560 posted
After checking different parts of the code individually everything was working fine. So i decided to reinstall WebMatrix. Well I couldn't because there was an error. So i had to restore my PC. Then I install WebMatrix again and everything is working fine now.
Friday, July 29, 2016 3:28 AM -
User325035487 posted
var Puntos = Request["Puntos"].AsInt();This will give u error every time the form posts null for that.
Better check if Puntos is not null oe empty string first
Friday, July 29, 2016 5:14 AM