Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • James Joplin 11 posts 62 karma points
    Feb 05, 2013 @ 16:49
    James Joplin
    0

    V6 Global.asax Issues - Implementing UmbracoApplication

     

    To some previous documentation I found somewhere (my apologies, don't remember where!) I was implementing this global class

    global.asax

     

    <%@ Application Codebehind="Global.asax.cs" Inherits="Project.Name.Web.Global" Language="C#" %>
    

    global.asax.cs

    namespace Project.Name.Web
    {
        public class Global : UmbracoApplication
        {
            protected override void OnApplicationStarted(object sender, EventArgs e)
            {
                base.OnApplicationStarted(sender, e);
                // our custom code here
           var contentService = ApplicationContext.Current.Services.ContentService;
                contentService.RePublishAll();
                umbraco.library.RefreshContent();
            }
        }
    }

    This was working fine in my visual studio development environment and web server (Visual Studio 2010).  Upon deploying to our Windows Server 2008R2 environment we were receiving a strange startup error that took awhile to iron out.

    [ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.]
       System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +109
       Umbraco.Core.Persistence.Database.CommonConstruct() +60
       Umbraco.Core.Persistence.UmbracoDatabase..ctor(String connectionStringName) +67
       Umbraco.Core.Persistence.DefaultDatabaseFactory.CreateDatabase() +426
       Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWorkProvider.GetUnitOfWork() +26
       Umbraco.Core.Services.ContentService.GetRootContent() +53
       Umbraco.Core.Services.ContentService.RePublishAllDo(Boolean omitCacheRefresh, Int32 userId) +149
       Project.Name.Web.Global.OnApplicationStarted(Object sender, EventArgs e) in c:\TeamCity\buildAgent\work\7a66fe180416e6cb\Project.Name.Web\Global.asax.cs:33
    Umbraco.Core.CoreBootManager.Complete(Action`1 afterComplete) +62 Umbraco.Web.WebBootManager.Complete(Action`1 afterComplete) +31

    My guess is the database isn't spooled up yet. But the error message can lead you on a wild goose chase if you aren't careful.

    I will be switching to the ApplicationEventHandler instead but just wanted you to be aware of the issue.  It's strange that the code works FINE in development but breaks in IIS.  If you want more details please let me know and I'll be happy to provide them.

  • James Joplin 11 posts 62 karma points
    Feb 05, 2013 @ 17:02
    James Joplin
    0

    IApplicationEventHandler doesn't give any resolution either, this function call still causes issue

    contentService.RePublishAll();
    

    I am going to compile umbraco 6 locally to provide more detail.

  • James Joplin 11 posts 62 karma points
    Feb 05, 2013 @ 18:05
    James Joplin
    100

    Upon further investigation I made a very trivial error! In my Staging web config transform I made a typo during copy and paste.

    providerName="System.Data.EntityClient" 

    After changing this to SqlClient all is well. Sorry for the false report!

Please Sign in or register to post replies

Write your reply to:

Draft