a collection of technical fixes and other randon stuff


  • Join Us on Facebook!
  • Follow Us on Twitter!
  • LinkedIn
  • Subcribe to Our RSS Feed

Solving Error Unable to cast object of type '<>f__AnonymousType1`1[myType]' to type myType'.


When coding in MVC , i Came across this or similar error message:

"Unable to cast object of type '<>f__AnonymousType1`1[myType]' to type myType"


I had been getting used to wrapping parameters in new{} when passing data from the controller to the view.
This error message was saying, i can't convert you class to your class. The new{} statement wrapping my object was changing it to an 'anonymous type'. So how did i fix it?




I found that removing the new{} section of the code solved this for me.