1

I am in the process of trying to upgrade a Helix based 8.2 update 5 project to Sitecore 9.0.1.

I have updated all projects to .NET 4.7 and have removed all Sitecore 8.2 DLLs that have no update to 9 option in Nuget.

All Sitecore DLLs that are available for upgrade have been updated to v9. The solution builds but when I run the gulp task to deploy to my Sitecore 9.1 instance webroot I get the following generic error..

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Stack Trace: 


[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
   System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) +0
   System.Reflection.Assembly.GetTypes() +112
   Sitecore.Services.Infrastructure.Sitecore.DependencyInjection.<>c.<AddWebApiControllers>b__0_0(Assembly assembly) +40
   System.Linq.<SelectManyIterator>d__17`2.MoveNext() +292
   Sitecore.Services.Infrastructure.Sitecore.DependencyInjection.ServiceCollectionExtensions.AddWebApiControllers(IServiceCollection serviceCollection, IEnumerable`1 assemblies) +204
   Sitecore.Content.Services.Configurator.Configure(IServiceCollection serviceCollection) +81
   Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +159
   Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +159
   Sitecore.DependencyInjection.BaseServiceProviderBuilder.ConfigureServiceCollection() +142
   Sitecore.DependencyInjection.ServiceLocator.ConfigureServiceProvider() +240
   Sitecore.DependencyInjection.ServiceLocator.get_ServiceProvider() +514
   Sitecore.DependencyInjection.SitecorePerRequestScopeModule..ctor() +13

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +142
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +105
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1515
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +186
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +27
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +79
   System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +213
   System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1086
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +120
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +169
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +372
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +329

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +118
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +708

The suggested solution to this on Stackoverflow post https://stackoverflow.com/q/1091853/266552 is to wrap the code that causes the error with the code below...

using System.IO;
using System.Reflection;
using System.Text;

try
{
    //The code that causes the error goes here.
}
catch (ReflectionTypeLoadException ex)
{
    StringBuilder sb = new StringBuilder();
    foreach (Exception exSub in ex.LoaderExceptions)
    {
        sb.AppendLine(exSub.Message);
        FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
        if (exFileNotFound != null)
        {                
            if(!string.IsNullOrEmpty(exFileNotFound.FusionLog))
            {
                sb.AppendLine("Fusion Log:");
                sb.AppendLine(exFileNotFound.FusionLog);
            }
        }
        sb.AppendLine();
    }
    string errorMessage = sb.ToString();
    //Display or log the error based on your application.
}

The problem is that this is a helix solution with 52 projects. I’m not sure where I need to add this code to reveal the issue. I’ve tried application start but it doesn’t work, and I cannot debug either. This error must happen before any debugging is possible.

Any help to point me in the right direction is most appreciated.

1

In my case, the reason for this error was the presence of some incompatible DLLs at my /bin folder. Due to the framework upgrade to 4.6.2, some of your libraries can break Sitecore. They must, during the upgrade process, be removed from the /bin folder (preferably moved to a backup folder Eg: /bin_Disabled).

To find these DLLs, use a file comparison tool such as Winmerge to compare you /bin folder (LEFT) against a fresh /bin folder from 9.0.1 (RIGHT). All LEFT ONLY Dlls are suspect.

After your upgrade is done, you must verify those DLLs see what you can stop using (if unused) and what needs to be upgraded to .NET 4.6.2.

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.