Copied to clipboard

Flag this post as spam?

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


  • Chris Van Oort 110 posts 371 karma points
    Jul 21, 2021 @ 19:13
    Chris Van Oort
    0

    No factory has been set error after Upgrading Umbraco 7 to Umbraco 8

    Hello,

    I'm in the process of trying to do a quick Umbraco 7.15.4 to Umbraco 8.15.0 upgrade and I'm getting an error when running via Visual Studio after I've upgraded all of the packages and fixed references.

    I've tried the suggestions mentioned below:

    Global.asax contents:

    <%@ Application Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %>
    

    I'm wondering if maybe I have an error in my \App_Start\UmbracoEventsHandler.cs file after I migrated to the new format for components and composers? UmbracoEventsHandler.cs file:

    using System;
    using System.Web.Http;
    using System.Web.Optimization;
    using Umbraco.Core;
    using Umbraco.Core.Composing;
    
    
    namespace ProjectSite.App_Start
    {
        public class ApplicationComposer : ComponentComposer<ApplicationComponent>, IUserComposer
        {
            public override void Compose(Composition composition)
            {
                // ApplicationStarting event in V7: add IContentFinders, register custom services and more here
                GlobalConfiguration.Configure(WebApiConfig.Register);
    
                composition.Components().Append<ApplicationComponent>();
    
                base.Compose(composition);
            }
        }
    
        public class ApplicationComponent : IComponent
        {
            public void Initialize()
            {
                // ApplicationStarted event in V7: add your events here
                BundleConfig.RegisterBundles(BundleTable.Bundles);
                GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add(new System.Net.Http.Formatting.RequestHeaderMapping("Accept",
                                  "text/html",
                                  StringComparison.InvariantCultureIgnoreCase,
                                  true,
                                  "application/json"));
            }
    
            public void Terminate()
            { }
        }
    }
    

    Error text:

    Server Error in '/' Application.
    No factory has been set.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: System.InvalidOperationException: No factory has been set.
    
    Source Error:
    
    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.
    
    Stack Trace:
    
    
    [InvalidOperationException: No factory has been set.]
       Umbraco.Core.Composing.Current.get_Factory() in D:\a\1\s\src\Umbraco.Core\Composing\Current.cs:55
       Umbraco.Web.Composing.ModuleInjector`1.Init(HttpApplication context) in D:\a\1\s\src\Umbraco.Web\Composing\ModuleInjector.cs:50
       System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +524
       System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +176
       System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +220
       System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +303
    
    [HttpException (0x80004005): No factory has been set.]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +680
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +188
    
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4330.0
    

    Any help would be much appreciated! Thank you! Chris

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Jul 25, 2021 @ 10:05
    Marc Goodson
    0

    Hi Chris

    Generally the advice is that there isn't a direct upgrade path from V7 to V8 - but there is a migration path, where you get to keep your content.

    https://our.umbraco.com/Documentation/Fundamentals/Setup/Upgrading/migrating-to-v8?_ga=2.152323001.1664531814.1564385463-1412256652.1558683561

    Essentially, Start with a new Visual Studio project, install V8, and point it at the database to update the database structures and migrate the content. Then reimplement your site, in the V8 solution, start by moving in your views, etc, and updating all the syntax - rewrite any application starting hookins etc to use Composition and Components.... etc etc

    It will be really hard to get a V7 solution to run if you just Nuget it to V8, and you need it to run to able to upgrade the database!

    regards

    Marc

  • Christian Fredh 2 posts 24 karma points
    Jul 26, 2022 @ 08:52
    Christian Fredh
    1

    For me, it turned out I had an old setting left in umbracoSettings.config:

      <useDomainPrefixes>false</useDomainPrefixes>
    

    I removed it and I got rid of the error. "No factory has been set." is a cryptic error message but I did find the cause after checking the logs:

    Umbraco.Core.Exceptions.BootFailedException: Boot failed. ---> System.Configuration.ConfigurationErrorsException: Unrecognized element 'useDomainPrefixes'.
    

    So check if you have this setting. And if not, the logs might give you direction to other settings or issues.

Please Sign in or register to post replies

Write your reply to:

Draft