Assembly errors after 11 to 12 upgrade

Michael Legacy asked on February 28, 2020 15:55

It seems like Kentico is still trying to load version 11 Assemblies after the upgrade from 11 to 12. This is a portal engine upgrade. I have tried both the automated Upgrade installer, and doing a manual upgrade where I start with a base Kentico 12 site and move my custom files over.

Stack trace of the error:

 Line 16: #endif
Line 17:         // Initialize CMS application. This method should not be called from custom code.
Line 18:         InitApplication(Assembly.GetExecutingAssembly());
Line 19:     }
Line 20: }

Source File: C:\Users\miket\OneDrive\Documents\GIT\CLR-NEW\CMS\App_Code\Global.asax.cs    Line: 18

Assembly Load Trace: The following information can be helpful to determine why the assembly 'CMS.Base, Version=11.0.0.0, Culture=neutral, PublicKeyToken=834b12a258f213f9' could not be loaded.

Could not load file or assembly 'CMS.Base, Version=11.0.0.0, Culture=neutral, PublicKeyToken=834b12a258f213f9' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have checked CMS.Base and countless other assemblies and they are all version 12. Where can I see what is referencing the incorrect assembly, because this error doesn't seem to be helping.

Full trace below:

[FileLoadException: Could not load file or assembly 'CMS.Base, Version=11.0.0.0, Culture=neutral, PublicKeyToken=834b12a258f213f9' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +197
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +166
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +156
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +612
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +149
System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) +104
System.Reflection.CustomAttributeExtensions.GetCustomAttributes(Assembly element) +58
CMS.Core.TypeManager.PreInitializeTypes(Assembly assembly) +126
CMS.Core.TypeManager.PreInitializeTypes() +241
CMS.Core.ModuleEntryManager.PreInit() +26
CMS.Core.AppCore.PreInit() +113
CMS.DataEngine.CMSApplication.PreInit() +119
CMS.DataEngine.CMSHttpApplication.InitApplication(Assembly webProjectAssembly) +65
Global..cctor() in C:\Users\miket\OneDrive\Documents\GIT\CLR-NEW\CMS\App_Code\Global.asax.cs:18

[TypeInitializationException: The type initializer for 'Global' threw an exception.]
Global..ctor() +0
ASP.global_asax..ctor() +42

[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) +107
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1476
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) +28
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +82
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +174
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +347

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

Recent Answers


Brenden Kehren answered on February 28, 2020 16:10

I'd suggest checking a few things:

  • make sure your local IIS is pointing to the same directory you're verifying the version information on
  • make sure you have your references setup right in your project in Visual Studio.
  • make sure any references in your web.config are updated, especially if they have a version specified in them.
  • make sure your project builds successfully after the upgrade. This will probably point you to the offending file(s) or issues pretty quick.
0 votesVote for this answer Mark as a Correct answer

Michael Legacy answered on February 28, 2020 16:19

Brenden, thanks for the answer!

I have only the new site setup in IIS, so the files it's hitting are definitely correct. This is also a .NET website, not a web application, so I'm not really dealing with references in that sense. The project has never had an issue building. It feels like a wild goose chase.

Anywhere else in the site files that there are references specifically to 11? Cause I can't find any references to version 11 in the web.config.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 28, 2020 16:29

What I'd do then is open file explorer and navigate to the /Bin directory, then display the File Version column. Then order the files by the file version to review the actual version info. Most likely there is a base dll which didn't get updated to v12. This happens when the website is open in Visual Studio or File Explorer and the system can't get a lock on the file to replace it.

Image Text

1 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on March 2, 2020 09:01

To add to what Brenden wrote - make sure that any of the custom projects you may be using, I mean custom assembly projects (.Net library) added to the solution have the references updated too. Recently I had the same issue reported and the cause was a custom project was still referencing old Kentico DLL.

0 votesVote for this answer Mark as a Correct answer

Samy Khalil answered on November 21, 2020 03:48

To add to the above, I had same issue when doing the upgrade, the problem was in the Toolkit module that I had it installed, with removing it the site work as expected.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.