Problems loading a aspx page

Topics: Web Client Software Factory, UIP Application Block discussion, User Forum
Sep 21, 2007 at 7:30 PM
Edited Sep 21, 2007 at 7:31 PM
In order to eliminate duplicate code within our views, we have extended our pages as explained by Mariano Szklanny (http://staff.southworks.net/blogs/mariano/archive/2007/01/13/How-to3A00-add-a-base-class-for-Web-pages.aspx)

When we load the page in our browser, we get the following stack trace
NullReferenceException: Object reference not set to an instance of an object.
Microsoft.Practices.CompositeWeb.WebClientApplication.BuildItemWithCurrentContext(Object obj) +122
Microsoft.Practices.CompositeWeb.Web.UI.Page.OnPreInit(EventArgs e) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +521

We seem to believe that this has to do with not initializing our container properly... Any ideas??

Thanks for your help
Pascale
Sep 21, 2007 at 9:13 PM
The source of all my problems.... For some reason the authorization service won't load properly.
I have included my web.config and stack trace below. I have also double checked to make sure all references are correct in all module projects and the website's bin

  <configSections>
    <sectionGroup name="compositeWeb">
      <section name="modules" type="Microsoft.Practices.CompositeWeb.Configuration.ModulesConfigurationSection, Microsoft.Practices.CompositeWeb"/>
      <section name="authorization" type="Microsoft.Practices.CompositeWeb.Configuration.AuthorizationConfigurationSection, Microsoft.Practices.CompositeWeb"/>
    </sectionGroup>
    <section name="securityConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Security.Configuration.SecuritySettings, Microsoft.Practices.EnterpriseLibrary.Security, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </configSections>
	<appSettings/>
	<connectionStrings/>
  <compositeWeb>
    <modules>
      <module name="Shell" assemblyName="Shell" virtualPath="~/" />
    </modules>
  </compositeWeb>
  <securityConfiguration defaultAuthorizationInstance="RuleProvider" defaultSecurityCacheInstance="">
    <authorizationProviders>
      <add type="Microsoft.Practices.EnterpriseLibrary.Security.AuthorizationRuleProvider, Microsoft.Practices.EnterpriseLibrary.Security, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="RuleProvider">
        <rules>
          <!-- Add your own rules here:
          e.g.:
              <add expression="R:Customer" name="AllowViewAccountsSummary"/>          
          -->
        </rules>
      </add>
    </authorizationProviders>
  </securityConfiguration>

Stack trace below:

Line 44:         protected virtual void AddGlobalServices(IServiceCollection globalServices)
Line 45:         {
Line 46:             globalServices.AddNew<EnterpriseLibraryAuthorizationService, IAuthorizationService>();
Line 47:             _siteMapBuilderService = globalServices.AddNew<SiteMapBuilderService, ISiteMapBuilderService>();
Line 48:         }
 
 
Source File: C:\Users\sys3032\Documents\Visual Studio 2005\Projects\cms\Modules\Shell\ShellModuleInitializer.cs    Line: 46
 
Stack Trace:
 
[NullReferenceException: Object reference not set to an instance of an object.]
   Microsoft.Practices.EnterpriseLibrary.Security.SecurityConfigurationView.GetDefaultAuthorizationProviderName() +35
   Microsoft.Practices.EnterpriseLibrary.Security.Configuration.AuthorizationProviderDataRetriever.MapName(String name, IConfigurationSource configSource) +65
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id) +122
   Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) +315
   Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) +168
   Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies) +104
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp(IReadWriteLocator locator, IConfigurationSource configurationSource) +228
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp(IConfigurationSource configurationSource) +65
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.CreateDefault() +72
   Microsoft.Practices.EnterpriseLibrary.Security.AuthorizationFactory.GetAuthorizationProvider() +86
   Microsoft.Practices.CompositeWeb.EnterpriseLibrary.Services.EnterpriseLibraryAuthorizationService..ctor() +33
 
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
   System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +72
   System.Reflection.RuntimeConstructorInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +499
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +17
   Microsoft.Practices.ObjectBuilder.CreationStrategy.InitializeObject(IBuilderContext context, Object existing, String id, ICreationPolicy policy) +376
   Microsoft.Practices.ObjectBuilder.CreationStrategy.BuildUpNewObject(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +486
   Microsoft.Practices.ObjectBuilder.CreationStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +70
   Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
   Microsoft.Practices.ObjectBuilder.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +409
   Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
   Microsoft.Practices.ObjectBuilder.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +409
   Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
   Microsoft.Practices.ObjectBuilder.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +409
   Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
   Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +184
   Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
   Microsoft.Practices.ObjectBuilder.TypeMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id) +457
   Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
   Microsoft.Practices.CompositeWeb.BuilderStrategies.ContainerAwareTypeMappingStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +194
   Microsoft.Practices.CompositeWeb.ObjectBuilder.WCSFBuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) +114
   Microsoft.Practices.CompositeWeb.ObjectBuilder.WCSFBuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) +46
   Microsoft.Practices.CompositeWeb.Collections.ServiceCollection.BuildFirstTimeItem(Type typeToBuild, Type typeToRegisterAs, Object item) +67
   Microsoft.Practices.CompositeWeb.Collections.ServiceCollection.Build(Type typeToBuild, Type typeToRegisterAs, Object serviceInstance) +258
   Microsoft.Practices.CompositeWeb.Collections.ServiceCollection.AddNew(Type serviceType, Type registerAs) +64
   Microsoft.Practices.CompositeWeb.Collections.ServiceCollection.AddNew() +127
   Apption.CMS.Shell.ShellModuleInitializer.AddGlobalServices(IServiceCollection globalServices) in C:\Users\Tariq.OFFICE\Documents\Visual Studio 2005\Projects\Apption\Apption.CMS\Modules\Shell\ShellModuleInitializer.cs:46
   Apption.CMS.Shell.ShellModuleInitializer.Load(CompositionContainer moduleContainer) in C:\Users\Tariq.OFFICE\Documents\Visual Studio 2005\Projects\Apption\Apption.CMS\Modules\Shell\ShellModuleInitializer.cs:39
   Microsoft.Practices.CompositeWeb.Services.ModuleLoaderService.Load(CompositionContainer rootContainer, IModuleInfo[] modulesInfo) +422
 
[ModuleLoadException: Failed to load module from assembly Shell, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Error was:
Failed to load module from assembly Shell, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Error was:
Exception has been thrown by the target of an invocation.]
   Microsoft.Practices.CompositeWeb.Services.ModuleLoaderService.ThrowModuleLoadException(Exception innerException, Assembly assembly) +201
   Microsoft.Practices.CompositeWeb.Services.ModuleLoaderService.Load(CompositionContainer rootContainer, IModuleInfo[] modulesInfo) +442
   Microsoft.Practices.CompositeWeb.WebClientApplication.LoadModules() +184
   Microsoft.Practices.CompositeWeb.WebClientApplication.Application_Start(Object sender, EventArgs e) +118
Sep 21, 2007 at 11:16 PM
Figured out the problem. If you specified an alternate configuration source for Enterprise Library then it won't read the sections listed in the web.config file. Didn't realize at first because it wasn't happening when I disabled the logging info, only security. Anyway I've tested my resolution with diff config sources and its worked everytime.
Feb 7, 2008 at 10:16 AM
Tariq, I'm having a similar problem. When you talk about specifying an alternate configuration source for Enterprise Library, how do you do this?

Thanks

Emmet
Feb 21, 2008 at 2:52 PM

Hi

I have similar problem, for some reason the config section is not read...
Any ideas?

Thanks,
Costas


Tariq wrote:
Figured out the problem. If you specified an alternate configuration source for Enterprise Library then it won't read the sections listed in the web.config file. Didn't realize at first because it wasn't happening when I disabled the logging info, only security. Anyway I've tested my resolution with diff config sources and its worked everytime.