views:

76

answers:

2

I just joined a team thats developing a asp.net mvc 1 application. I only have visual studio 2010 installed which comes with mvc 2.

I ran the conversion wizard and now the app doesnt seem to compile

The error I get is

"Cannot apply indexing with [] to an expression of type 'System.Web.Mvc.IValueProvider"

i get this error 5 times in different places of the app.

The line is

ModelState.SetModelValue(inputTagName, new ValueProviderResult(ValueProvider[inputTagName].AttemptedValue, file.FileName, System.Globalization.CultureInfo.CurrentCulture));

To be honest I've no clue on what its doing but my peers (using Mvc 1) dont have trouble compiling.

Please help.

A: 

Change ValueProvider[inputTagName].AttemptedValue to ValueProvider.GetValue(inputTagName).AttemptedValue.

Note that your entire team should be developing against the same version of ASP.Net MVC; otherwise; you'll run into lots of trouble.

SLaks
Thanks, that fixed it although I am going to try fixing it properly using tvanfosson's suggestion
NachoF
+1  A: 

This is one of the (few) breaking changes between MVC 1 and MVC 2. The ValueProvider has been completely redone to support multiple value providers and no longer has an index property. The short answer is to change this to use GetValue( inputTagName ). The longer (and better) answer is to change the code to use models for your action method inputs and not pull the data out of the value provider directly in your code. Rather, you rely on model binding to access the value provider and set the properties on your model.

tvanfosson