类型或命名空间名称不命名空间中存在'System.Web.Mvc“ [英] The type or namespace name does not exist in the namespace 'System.Web.Mvc'
问题描述
层楼高MVC3解决方案进行得很顺利,但已经得到浏览器中的一个错误:
编译器错误信息:CS0234:类型或命名空间名称HTML中的命名空间System.Web.Mvc不存在(是否缺少程序集引用?)
源错误:
第25行:其中,添加命名空间=System.Web.Mvc/>
第26行:< - <添加命名空间=System.Web.Mvc.Ajax/> - >
27号线:其中,添加命名空间=System.Web.Mvc.Html/>
28号线:其中,添加命名空间=System.Web.Routing/>
第29行:其中,添加命名空间=System.Web.WebPages/>
我已经安装了与的NuGet
解包并为所有项目 MVC3
。请问 MVC3
包括图书馆 System.Web.Mvc.Ajax
, System.Web.Mvc。 HTML
和其他人?为什么我得到的错误?
在引用文件夹,我有System.Web.Mvc
运行时版本:v4.0.30319
,
版本:3.0.0.0
Web.config文件
<?XML版本=1.0编码=UTF-8&GT?;
<! -
有关如何配置ASP.NET应用程序的更多信息,请访问:
http://go.microsoft.com/fwlink/?LinkId=152368
- >
<结构>
< configSections>
<! - 有关Entity Framework的配置的详细信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468 - >
<节名称=的EntityFrameworkTYPE =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,的EntityFramework,版本5.0.0.0 =文化=中性公钥= b77a5c561934e089requirePermission =FALSE/>
< / configSections>
<&的appSettings GT;
<添加键=ASPNET:UseTaskFriendlySynchronizationContextVALUE =真/>
<添加键=网页:版本值=1.0.0.0/>
<添加键=ClientValidationEnabledVALUE =真/>
<添加键=UnobtrusiveJavaScriptEnabledVALUE =真/>
< /的appSettings>
<&的System.Web GT;
<编译调试=真targetFramework =4.5/>
<身份验证模式=表格>
<形式loginUrl =〜/帐号/登录超时=2880/>
< /认证>
<网页和GT;
<&命名空间GT;
<添加命名空间=System.Web.Helpers/>
<添加命名空间=System.Web.Mvc/>
<添加命名空间=System.Web.Mvc.Ajax/>
<添加命名空间=System.Web.Mvc.Html/>
<添加命名空间=System.Web.Routing/>
<添加命名空间=System.Web.WebPages/>
< /命名空间>
< /页>
<的httpRuntime targetFramework =4.5EN coderType =System.Web.Security.AntiXss.AntiXssEn codeR,System.Web程序,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a/>
<的machineKey compatibilityMode =Framework45/>
<型材defaultProvider =DefaultProfileProvider>
<供应商>
<添加名称=DefaultProfileProviderTYPE =System.Web.Providers.DefaultProfileProvider,System.Web.Providers,版本= 1.0.0.0,文化=中性公钥= 31bf3856ad364e35的connectionStringName =DefaultConnection的applicationName =// >
< /供应商>
< / profile文件>
<会员defaultProvider =DefaultMembershipProvider>
<供应商>
<添加名称=DefaultMembershipProviderTYPE =System.Web.Providers.DefaultMembershipProvider,System.Web.Providers,版本= 1.0.0.0,文化=中性公钥= 31bf3856ad364e35的connectionStringName =DefaultConnectionenablePasswordRetrieval =false的enablePasswordReset设置=真requiresQuestionAndAnswer =假requiresUniqueEmail =假maxInvalidPasswordAttempts =5minRequiredPasswordLength =6minRequiredNonalphanumericCharacters =0passwordAttemptWindow =10的applicationName =//>
< /供应商>
< /会员>
< roleManager defaultProvider =DefaultRoleProvider>
<供应商>
<添加名称=DefaultRoleProviderTYPE =System.Web.Providers.DefaultRoleProvider,System.Web.Providers,版本= 1.0.0.0,文化=中性公钥= 31bf3856ad364e35的connectionStringName =DefaultConnection的applicationName =// >
< /供应商>
< / roleManager>
<的sessionState模式=是InProccustomProvider =DefaultSessionProvider>
<供应商>
<添加名称=DefaultSessionProviderTYPE =System.Web.Providers.DefaultSessionStateProvider,System.Web.Providers,版本= 1.0.0.0,文化=中性公钥= 31bf3856ad364e35的connectionStringName =DefaultConnection/>
< /供应商>
< /&的sessionState GT;
< /system.web>
< system.webServer>
<验证validateIntegratedModeConfiguration =FALSE/>
< /system.webServer>
<&运行GT;
< assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1>
< dependentAssembly>
< assemblyIdentity名称=System.Web.Mvc公钥=31bf3856ad364e35/>
< bindingRedirect oldVersion =1.0.0.0-2.0.0.0NEWVERSION =3.0.0.0/>
< / dependentAssembly>
< / assemblyBinding>
< /运行>
<&的EntityFramework GT;
< defaultConnectionFactory TYPE =System.Data.Entity.Infrastructure.SqlConnectionFactory,的EntityFramework/>
< /&的EntityFramework GT;
<&是connectionStrings GT;
<添加名称=EFDbContext的connectionString =数据源= \\ SQLEX $ P $干燥综合征;初始目录= SportStore;集成安全性= TRUE;池= FALSE;的providerName =System.Data.SqlClient的/>
< /&是connectionStrings GT;
< /结构>
MSDN 的System.Web.Mvc命名空间
文件 packages.config
:
<?XML版本=1.0编码=UTF-8&GT?;
<套餐及GT;
<包ID =的EntityFramework版本=5.0.0-RC/>
<包ID =jQuery的版本=1.7.2/>
<包ID =jQuery.UI.Combined版本=1.8.11/>
<包ID =jQuery.Validation版本=1.9/>
<包ID =Microsoft.AspNet.Mvc版本=3.0.20105.1/>
<包ID =Microsoft.AspNet.Providers.Core版本=1.0/>
<包ID =Microsoft.AspNet.Providers.LocalDB版本=1.0/>
<包ID =Microsoft.AspNet.Razor版本=1.0.20105.408/>
<包ID =Microsoft.AspNet.WebPages版本=1.0.20105.408/>
<包ID =Microsoft.Web.Infrastructure版本=1.0.0.0/>
<包ID =Modernizr的版本=2.0.6/>
<包ID =起订量版本=4.0.10827/>
<包ID =Ninject版本=3.0.1.10/>
< /包>
清洁您的解决方案,然后将这些文件的属性设置为复制本地=真
。
要复制本地属性设置为True或False
在解决方案资源管理器中,单击显示所有文件按钮,显示引用节点。
- 打开引用节点项目。
- 右键单击引用列表的引用,然后单击属性。
与该参考相关的属性出现在属性窗口的列表。 - 在属性窗口,将复制本地属性更改为真或假。
Buiding MVC3 solution went well but have got an error in browser:
Compiler Error Message: CS0234: The type or namespace name 'Html' does not exist in the namespace 'System.Web.Mvc' (are you missing an assembly reference?)
Source Error:
Line 25: <add namespace="System.Web.Mvc" />
Line 26: <!--<add namespace="System.Web.Mvc.Ajax" />-->
Line 27: <add namespace="System.Web.Mvc.Html" />
Line 28: <add namespace="System.Web.Routing" />
Line 29: <add namespace="System.Web.WebPages" />
I have installed packets for the solution with NuGet
and set up for all projects MVC3
. Does MVC3
include libraries System.Web.Mvc.Ajax
, System.Web.Mvc.Html
and others? Why am I getting the error?
In References folder, I have System.Web.Mvc
Runtime version: v4.0.30319
,
Version: 3.0.0.0
Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<httpRuntime targetFramework="4.5" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<machineKey compatibilityMode="Framework45" />
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<connectionStrings>
<add name="EFDbContext" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=SportStore;Integrated Security=True;Pooling=False;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
MSDN the System.Web.Mvc namespace
file packages.config
:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="5.0.0-rc" />
<package id="jQuery" version="1.7.2" />
<package id="jQuery.UI.Combined" version="1.8.11" />
<package id="jQuery.Validation" version="1.9" />
<package id="Microsoft.AspNet.Mvc" version="3.0.20105.1" />
<package id="Microsoft.AspNet.Providers.Core" version="1.0" />
<package id="Microsoft.AspNet.Providers.LocalDB" version="1.0" />
<package id="Microsoft.AspNet.Razor" version="1.0.20105.408" />
<package id="Microsoft.AspNet.WebPages" version="1.0.20105.408" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="Modernizr" version="2.0.6" />
<package id="Moq" version="4.0.10827" />
<package id="Ninject" version="3.0.1.10" />
</packages>
Clean your solution and then set the property of those files to Copy Local = True
.
To set the Copy Local property to True or False
In Solution Explorer, click the Show All Files button to display the References node.
- Open the References node for the project.
- Right-click a reference in the References list, and click Properties. The properties associated with that reference appear in a list in the Properties window.
- In the Properties window, change the Copy Local property to True or False.
这篇关于类型或命名空间名称不命名空间中存在'System.Web.Mvc“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!