Global.asax not firing on precompiled Sitefinity p

2019-08-15 14:02发布

问题:

I'm trying to launch a Sitefinity 4.2 project. As part of the project I need to register some controls within the global.asax file, like so:

    protected void Application_Start(object sender, EventArgs e) {

        //log call
        logStartUpCall(string.Concat("Application started at: ", DateTime.Now));

        Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);

        //log call
        logStartUpCall(string.Concat("Call made to bootstrapper: ", DateTime.Now));
    }

    protected void Application_OnStart(object sender, EventArgs e) {

        //log call
        logStartUpCall(string.Concat("Application started at: ", DateTime.Now));

        Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);

        //log call
        logStartUpCall(string.Concat("Call made to bootstrapper: ", DateTime.Now));
    }

    protected void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args) {

        //log call
        logStartUpCall(string.Concat("Bootstrapper_Initialized:", " ", DateTime.Now));

        //register dialogs for custom module fields
        Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<SitefinityModuleFields.Dialogs.SimpleImageSelectorDialog>();
        logStartUpCall(string.Concat("Simple Image Selector dialog registered at:", " ", DateTime.Now));
        Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<SitefinityModuleFields.Dialogs.SimpleVideoSelectorDialog>();
        logStartUpCall(string.Concat("Simple Video Selector dialog registered at:", " ", DateTime.Now));
        Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<ioscms.AppCode.ModuleFields.SimpleDocumentSelectorDialog>();
        logStartUpCall(string.Concat("Simple Document Selector dialog registered at:", " ", DateTime.Now));

        //log call
        logStartUpCall(string.Concat("Dialogs registered at: ", DateTime.Now));

    }

    protected void logStartUpCall(string message) {

        TextWriter tw = new StreamWriter(System.Web.Hosting.HostingEnvironment.MapPath("/App_Data/SiteFinity/Logs/Startup.log"), true);

        // write a line of text to the file
        tw.WriteLine(message);

        // close the stream
        tw.Close();

    }

This works perfectly in normal debug mode. I am using a Web Deployment Project to deploy the project. This of course precompiles the website. the settings I am using are:

SingleAssembly UpdateAble: true DebugSymbols: false

The other thing with sitefinity is that the app can't be precompiled, so the PrecompiledApp.config file has to be deleted.

The problem I'm experiencing is that the Application_Start (I've also tried Application_OnStart) is never executed, so of course the dialogs are never registered.

I've also tried the option "Merge each individual folder output to its own assembly" with no avail.

Does anyone have any ideas?

Thanks in advance higgsy