An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[NullReferenceException: Object reference not set to an instance of an object.] GleamTech.AspNet.UI.ComponentStateManager.SaveState(String stateId, ComponentState state) +66 GleamTech.AspNet.UI.ComponentRenderer.SaveState(StatefulComponent statefulComponent, String requestPath) +238 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +255 System.Web.UI.Control.PreRenderRecursiveInternal() +255 System.Web.UI.Control.PreRenderRecursiveInternal() +255 System.Web.UI.Control.PreRenderRecursiveInternal() +255 System.Web.UI.Control.PreRenderRecursiveInternal() +255 System.Web.UI.Control.PreRenderRecursiveInternal() +255 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6874
protected void Application_Start(object sender, EventArgs e) { GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart(); }
GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart();
[InvalidOperationException: Cannot register a module after the application has been initialized.] System.Web.DynamicModuleRegistry.Add(Type moduleType) +244 System.Web.HttpApplication.RegisterModule(Type moduleType) +75 GleamTech.AspNet.NetFramework.WebActivation.PreApplicationStart() +404 GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart() +52 GleanTechModule.Application_BeginRequest(Object source, EventArgs e) +42 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +139 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +88
The global.asax doesn't seem to be the best solution to do this because of the deployment issues described in the question.A viable solution is implementing this in a httpmoduleThe init method can be used to wire everything up since this is called when the sharepoint application starts.the httpmodule can be added in the web.config by a feature receiverThis way there is no need to do tricks with the global.asax that is located in a directory you can't deploy to with a feature and you have all the functionality and correct time to instantiate the DI container.
using System.Web; public class GlobalHttpModule : IHttpModule { public void Init(HttpApplication app) { //The init method can be used to wire everything up since this is called when the Sharepoint application starts. GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart(); } public void Dispose() { } }
public class GlobalHttpModuleFeature : SPFeatureReceiver { private readonly Type targetHttpModuleType = typeof(GlobalHttpModule); public override void FeatureActivated(SPFeatureReceiverProperties properties) { var webApp = properties.Feature.Parent as SPWebApplication; var modification = GetModification(); webApp.WebConfigModifications.Add(modification); webApp.Update(); webApp.WebService.ApplyWebConfigModifications(); } public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { var webApp = properties.Feature.Parent as SPWebApplication; var modification = GetModification(); webApp.WebConfigModifications.Remove(modification); webApp.Update(); webApp.WebService.ApplyWebConfigModifications(); } private SPWebConfigModification GetModification() { var modification = new SPWebConfigModification( string.Format("add[@name='{0}']", targetHttpModuleType.Name), "configuration/system.webServer/modules" ); modification.Sequence = 0; modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; modification.Value = string.Format( @"<add name=""{0}"" type=""{1}"" />", targetHttpModuleType.Name, targetHttpModuleType.AssemblyQualifiedName); } }
GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart() +52 GleanTechModule.Application_BeginRequest(Object source, EventArgs e) +42
Trouble logging in? Simply enter your email address OR username in order to reset your password.
For faster and more reliable delivery, add notify@gleamtech.com to your trusted senders list in your email software.