views:

530

answers:

2

Hi

I been going through this tutorial and it looks really good. So I went through it and downloaded the sample file.

I been playing around with it and I understand how to use it and was able to add my own validation too it.

So I decided to add it to my current project I am working on. I was able to get it to compile and run yet when I try my form no validation(both client side and server side) happens.

I don't know why. So I made a another project and tried to add all the stuff again yet I don't know what I am missing it does not work.

You can download it here

This is the only real way I can show you theirs too many files to copy and paste the code around.

I am not even using the remote validation part for my tests yet too. I am only using like straight stuff from xval like the one thing I had is "Required Email".

Thanks

Edit now I get an error

System.IO.FileNotFoundException was unhandled by user code
  Message="Could not load file or assembly 'System.ComponentModel.DataAnnotations, Version=99.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."
  Source="Online.com"
  FileName="System.ComponentModel.DataAnnotations, Version=99.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  FusionLog="=== Pre-bind state information ===\r\nLOG: User = CHOBO2\\chobo\r\nLOG: DisplayName = System.ComponentModel.DataAnnotations, Version=99.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\n (Fully-specified)\r\nLOG: Appbase = file:///I:/OnlineV2/trunk/Current Site/\r\nLOG: Initial PrivatePath = I:\\OnlineV2\\trunk\\Current Site\\bin\r\nCalling assembly : Online.com, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: Using application configuration file: I:\\OnlineV2\\trunk\\Current Site\\web.config\r\nLOG: Using machine configuration file from C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\config\\machine.config.\r\nLOG: Post-policy reference: System.ComponentModel.DataAnnotations, Version=99.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\r\nLOG: The same bind was seen before, and was failed with hr = 0x80070002.\r\n"
  StackTrace:
       at Microsoft.Web.Mvc.DataAnnotations.DataAnnotationsModelBinder.GetTypeDescriptor(Object model, Type modelType)
       at Microsoft.Web.Mvc.DataAnnotations.DataAnnotationsModelBinder.GetModelProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) in I:\OnlineV2\trunk\Current Site\Models\DataAnnotationsModelBinder\DataAnnotationsModelBinder.cs:line 35
       at System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext)
       at System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model)
       at System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
       at System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
       at System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor)
       at System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
       at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
  InnerException:
A: 

Have you read the error closely? It looks like a file can't be found. I'm surprised it'd even compile, but I don't know much about file referencing. This error is on your testing box, and not after you publish it to another machine?

I'd start with removing it from your references and re-adding it.

Apparently DataAnnotations requires .NET 3.5SP1, but you should have that if you're even marginally up-to-date.

James S
Ya I read the error. I know where the is. Nothing was moved so the path is 100% right. I figured it out though I had it in a Custom folder within my bin directory. xVal seems to want to use it directly under the bin root no where else.
chobo2
A: 

I had a similar issue. I downloaded the Data Annotations Model Binder Sample, built, and referenced the new assemblies in my project. Worked like a charm.

newslacker