What is a "NullReferenceError" in ASP.NET MVC? - asp.net-mvc

I keep getting "NullReferenceError" in my output, could someone kindly explain what exactly this statement means.

Somewhere in your code, you are trying to access a member of a reference type, but the variable actually is null. Without code and a stacktrace it's impossible to say what exactly happens. It might be because some parameter is expecting a value but isn't supplied one.

If it helps, a decent description of NullReferenceException -- why/when they occur, and how to prevent them -- at http://www.dotnetperls.com/nullreferenceexception

Related

What's the difference between domain.errors.hasErrors() and just domain.hasErrors()?

Can someone please explain why sometimes grails developers use foo.errors.hasErrors() and other times they use just foo.hasErrors()? Are they synonymous or is one correct while the other is not?
Both are synonymous. See GormValidationApi.groovy. Domain.hasErrors delegates to underlying Errors object.

how to write blank lines in object ADODB.Stream?

I want to know how to skip a/multiple line(s) in object ADODB.Stream in visual basic code. The only paramater for writing text that I know is stream.WriteText for this object. Parameter:
Write, WriteLine and WriteBlankLines is for object FileSystemObject. So there is no way to type stream.WriteBlankLines under ADODB.Stream. It will pop-out error. If anyone knows, I appreciate your kindness.
Error is caused by stream.vbcrlf, using:
stream.WriteText vbCrLf
should work.
Finally, I found the answer. Just type stream.vbCrLf after stream.WriteText. And it will go down and start at new line.

Removing ModelErrors from ModelState once written to ValidationSummary()

I may be approaching this from the wrong angle entirely, but hopefully someone will know a way of acheiving what I'm after.
I reference a web service, which returns an ErrorInfo object. I add each returned error to the ModelState as a ModelError:
foreach(ErrorInfo error in serviceResponse)
ModelState.AddModelError(error.AssociatedField, error.Description);
For errors which relate to a particular input field (using strongly-typed Views here), I get a nice inline error returned to Html.ValidationMessageFor(x), which is great.
The problem is that in addition to these input-related errors, there may also be more generate results.
What I'd LIKE to do is have these output in a list similar to Html.ValidationSummary() - however if I do this at the moment, it will also include the errors which have already been displayed inline against each input.
Is there an elegant way of just displaying all the errors which DON'T relate to a particular form input?
This is a good enough solution for me, it doesn't print the individual error detail, but thats not important for the non-input related errors
Html.ValidationSummary(true, "Failed to login for some other reason")

What/Where is the value of E_CLR_ALREADY_STARTED?

The docs for ICLRRuntimeHost::SetHostControl claim that it can return E_CLR_ALREADY_STARTED. I have been unable to find a definition for this value. Ideally, I'd like to know what the appropriate header to include is (it does not appear to be in corerror.h) but if someone can provide me with the canonical value too I can live with that.
Thanks
I can't seem to find it either and I'm usually pretty good at finding missing or misspelled constants. You could try calling the method after initializing the CLR and if it does in fact return the HRESULT that it's documented to return, you could just trace it. But it definitely seems like a documentation bug.

Custom Error handling in ASP MVC

I want to go beyond the default error handling given in ASP mvc. I have an errors controller, so I can hopefully give different error messages according to whats happened: i.e Invalid arguments, Permission denied, OMG DATABASE DEAD, etc.
But I cant seem to work out how to do this, this is what I have tried:
[HandleError(View="/Errors/InvalidArgument",ExceptionType=typeof(ArgumentException))]
It ends up giving a Runtime Error.
Also, on the same subject, is it possible to add more parameters that I could pass to the error controller, such as:
[HandleError(View="/Errors/InvalidArgument",ExceptionType=typeof(ArgumentException), Error="dumb arguments")]
Thanks
Just specify the View name, not it's path...as for passing arguments, I don't think you can.

Resources