前阵子,使用NetTiers生成底层,新建项目。在还没写入代码时先行生成了一下,但却抛出“Unable to load NetTiersServiceSection”异常。一查,原来是WEB.CONFIG没有进行配置。
配置如下:
<configuration>
<configSections>
<section name="myNameSpace.Data" type="myNameSpace.Data.Bases.NetTiersServiceSection, myNameSpace.Data" allowDefinition="MachineToApplication" restartOnExternalChanges="true"/>
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null"/>
<section name="urlrewritingnet" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter"/>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<section name="TinyMCE" type="Moxiecode.TinyMCE.ConfigHandler,Moxiecode.TinyMCE" requirePermission="false"/>
<section name="TunynetHttpCompress" type="TunyNet.Web.HttpCompress.Configuration,TunyNet.Web.HttpCompress"/>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SpaceBuilder.Web.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<appSettings/>
<connectionStrings>
<add name="ConnectionString" connectionString="server=.;database=XX;uid=dbsa;pwd=dbsa;"/>
</connectionStrings>
<myNameSpace.Data defaultProvider="SqlNetTiersProvider">
<providers>
<!--
*** SqlClient Provider ***
connectionStringName: sqlclient connection string to the db
useStoredProcedure: if true, indicates that we use the stored procedures, otherwise, we use parametrized queries that are embedded.
-->
<add name="SqlNetTiersProvider" type="myNameSpace.Data.SqlClient.SqlNetTiersProvider, myNameSpace.Data.SqlClient" connectionStringName="myNameSpace.Data.ConnectionString" providerInvariantName="System.Data.SqlClient" entityFactoryType="myNameSpace.Entities.EntityFactory" useEntityFactory="true" enableEntityTracking="false" enableMethodAuthorization="false" useStoredProcedure="true" defaultCommandTimeout="30"/>
<!--
*** WebserviceClient Provider ***
The url parameter indicates the webservices url (ex: http://localhost/myNameSpace/myNameSpaceServices.aspx)
<add
name="WsNetTiersProvider"
type="myNameSpace.Data.WebServiceClient.WsNetTiersProvider, myNameSpace.Data.WebServiceClient"
url="/myNameSpaceServices.asmx" />
-->
</providers>
</myNameSpace.Data>
<system.web>
<!--
设置 compilation debug="true" 将调试符号插入
已编译的页面中。但由于这会
影响性能,因此只在开发过程中将此值
设置为 true。
-->
<compilation debug="true" />
<!--
通过 <authentication> 节可以配置 ASP.NET 使用的
安全身份验证模式,
以标识传入的用户。
-->
<authentication mode="Windows" />
<!--
如果在执行请求的过程中出现未处理的错误,
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
开发人员通过该节可以配置
要显示的 html 错误页
以代替错误堆栈跟踪。
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>
这只是我遇到的这个异常的时的情况,可能这个异常还会有其他的问题存在,因为我之前好像遇到过这种异常的另一种情况。
所以有其他资料时,我将进一步善。