tags:

views:

552

answers:

4

I've been trying to run ASP.Net MVC 1.0 on one machine, but can't get past this. I create a new MVC project (C#). It creates all the folders, views, controllers, models etc. All good. Then, when I hit F5, I get the following:

d:\VSCode2008\MVC\MvcApplication1\Views\Shared\Site.Master(19): error CS0117: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial'

this happens at the following line:

httpHandler.ProcessRequest(HttpContext.Current); in Default.aspx.cs

It seems when it is trying to do a RenderPartial() to render the logon partial.

I have version 3.51 of .Net framework installed. I installed version 1.0 of MVC, and the assembly clearly has RenderPartial() as extension methods of HtmlHelper.

Anyone seen anything similar? I have found some posts about similar problems with betas and RCs but the suggested fixes have not woredk.

I am loving the theory of MVC but it is not letting me play!

+1  A: 

Just trying to rule out the obvious here, but can you make sure have this in the namespaces section of the web.config?

<add namespace="System.Web.Mvc.Html"/>
dcp
Yes - thanks - got that in web config (there are 2 web.configs, one at project level and one under views)
John Davies
A: 

According to your error message, you are referencing System.Web.Mvc.HtmlHelper. I am looking at the System.Web.Mvc dll in Reflector, and it's telling me that RenderPartial resides in the namespace System.Web.Mvc.Html, not System.Web.Mvc.HtmlHelper.

Robert Harvey
thanks Robert, I had a look and I see the same thing. I forgot to mention that when I run the project (or any asp.net web project) it complains about an unrecorgnised section in web.config - System.Codedom. I am thinking maybe my VS2008 needs updating - although I thought I installed sp1 it doesn't look like it's there.
John Davies
Tried sp1 - no fix. Renistalled VS2008 - no fix. I think a re-image may be the quickest option here...
John Davies
+1  A: 

You may think this is dumb, but I just had the same problem. I had a working MVC app, running 1.0.0.0 and all of a sudden it stopped working giving me the same RenderPartial isn't in the definition. Well it turns out that while I was going crazy cleaning up my web.config, I removed this section. When I re-added it, everything worked again. I'm sure this has something to do with how the class extensions load during runtime.

Anyway, re-adding this to my web.config worked on my machine. ;)

<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
                     type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5"/>
            <providerOption name="WarnAsError" value="false"/>
        </compiler>

        <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4"
                     type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5"/>
            <providerOption name="OptionInfer" value="true"/>
            <providerOption name="WarnAsError" value="false"/>
        </compiler>
    </compilers>
</system.codedom>
Nathan
aha! i just did exactly the same thing! doh!
Andrew Bullock
A: 

Since you are referencing it in your Code Behind (ie. Default.aspx.cs) you need to include the namespace at the top of the file.

using System.Web.Mvc.Html;

is the Namespace that includes the RenderPartial extension method.

Justin