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:
我一直试图在一台机器上运行ASP.Net MVC 1.0,但是无法通过它。我创建了一个新的MVC项目(C#)。它创建了所有文件夹,视图,控制器,模型等。一切都很好。然后,当我点击F5时,我得到以下内容:
d:\VSCode2008\MVC\MvcApplication1\Views\Shared\Site.Master(19): error CS0117: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial'
d:\ VSCode2008 \ MVC \ MvcApplication1 \ Views \ Shared \ Site.Master(19):error CS0117:'System.Web.Mvc.HtmlHelper'不包含'RenderPartial'的定义
this happens at the following line:
这发生在以下行:
httpHandler.ProcessRequest(HttpContext.Current); in Default.aspx.cs
httpHandler.ProcessRequest(HttpContext.Current);在Default.aspx.cs中
It seems when it is trying to do a RenderPartial() to render the logon partial.
它似乎正在尝试执行RenderPartial()以呈现登录部分。
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.
我安装了.Net框架的3.51版本。我安装了1.0版的MVC,并且程序集显然有RenderPartial()作为HtmlHelper的扩展方法。
Anyone seen anything similar? I have found some posts about similar problems with betas and RCs but the suggested fixes have not woredk.
有人见过类似的东西?我发现了一些关于贝塔和RC的类似问题的帖子,但是建议的修补程序还没有woredk。
I am loving the theory of MVC but it is not letting me play!
我喜欢MVC的理论,但它不是让我玩!
5 个解决方案
#1
18
Just trying to rule out the obvious here, but can you make sure have this in the namespaces section of the web.config?
只是试图排除显而易见的问题,但是你能确保在web.config的名称空间部分中有这个吗?
<add namespace="System.Web.Mvc.Html"/>
#2
5
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.
由于您在Code Behind中引用它(即Default.aspx.cs),因此您需要在文件顶部包含命名空间。
using System.Web.Mvc.Html;
is the Namespace that includes the RenderPartial extension method.
是包含RenderPartial扩展方法的命名空间。
#3
5
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.
你可能认为这很愚蠢,但我遇到了同样的问题。我有一个工作的MVC应用程序,运行1.0.0.0,突然它停止工作,给我相同的RenderPartial不在定义中。事实证明,当我疯狂清理我的web.config时,我删除了这一部分。当我重新添加它时,一切都恢复了。我确定这与类扩展在运行时加载的方式有关。
Anyway, re-adding this to my web.config worked on my machine. ;)
无论如何,重新添加到我的web.config工作在我的机器上。 ;)
<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>
#4
2
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
.
根据您的错误消息,您正在引用System.Web.Mvc.HtmlHelper。我在Reflector中查看System.Web.Mvc dll,它告诉我RenderPartial位于命名空间System.Web.Mvc.Html中,而不是System.Web.Mvc.HtmlHelper。
#5
1
Another possible problem (depending on your error string) is that the extension method is there, but that the compiler couldn't match up your parameters to the known method parameters. I ran into this using T4MVC (noob) and forgetting to add ActionNames before the name of the action I was calling.
另一个可能的问题(取决于您的错误字符串)是扩展方法存在,但编译器无法将您的参数与已知方法参数匹配。我使用T4MVC(noob)遇到了这个问题而忘记在我调用的动作名称之前添加ActionNames。
#1
18
Just trying to rule out the obvious here, but can you make sure have this in the namespaces section of the web.config?
只是试图排除显而易见的问题,但是你能确保在web.config的名称空间部分中有这个吗?
<add namespace="System.Web.Mvc.Html"/>
#2
5
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.
由于您在Code Behind中引用它(即Default.aspx.cs),因此您需要在文件顶部包含命名空间。
using System.Web.Mvc.Html;
is the Namespace that includes the RenderPartial extension method.
是包含RenderPartial扩展方法的命名空间。
#3
5
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.
你可能认为这很愚蠢,但我遇到了同样的问题。我有一个工作的MVC应用程序,运行1.0.0.0,突然它停止工作,给我相同的RenderPartial不在定义中。事实证明,当我疯狂清理我的web.config时,我删除了这一部分。当我重新添加它时,一切都恢复了。我确定这与类扩展在运行时加载的方式有关。
Anyway, re-adding this to my web.config worked on my machine. ;)
无论如何,重新添加到我的web.config工作在我的机器上。 ;)
<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>
#4
2
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
.
根据您的错误消息,您正在引用System.Web.Mvc.HtmlHelper。我在Reflector中查看System.Web.Mvc dll,它告诉我RenderPartial位于命名空间System.Web.Mvc.Html中,而不是System.Web.Mvc.HtmlHelper。
#5
1
Another possible problem (depending on your error string) is that the extension method is there, but that the compiler couldn't match up your parameters to the known method parameters. I ran into this using T4MVC (noob) and forgetting to add ActionNames before the name of the action I was calling.
另一个可能的问题(取决于您的错误字符串)是扩展方法存在,但编译器无法将您的参数与已知方法参数匹配。我使用T4MVC(noob)遇到了这个问题而忘记在我调用的动作名称之前添加ActionNames。