Kentico 12: Change .NET target framework version

Chad Tran asked on June 11, 2021 09:43

Dear Kentico supports, I'm using Kentico version 12 for my project with default .Net framework 4.6.1. Now, I tried to change to .Net framework 4.7 or higher because the 4.5.2, 4.6, 4.6.1 will reach End of Support on April 26, 2022.

Following the release note of Kentico 12 and solution from this article, I have success retarget to new framework version but I got this error when running CMS app. Images.

Log:

[InvalidOperationException: Additional assemblies have to be registered before application pre-initialization.]
   CMS.Core.AssemblyDiscoveryHelper.RegisterAdditionalAssemblies(Assembly[] assemblies) +236
   CMS.DataEngine.CMSHttpApplication.InitApplication(Assembly webProjectAssembly) +53
   Global..cctor() +56

[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) +80
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +182
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

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

And on the presentation URL, all the scripts and css files cannot loading. Image.

I have checked in packages.config and web.config files and the target is already changed. Did I miss something? Please help me as soon as available.

Best regards,

Chan Tran

Correct Answer

Juraj Ondrus answered on June 14, 2021 11:26

Have you changed the target framework for all projects in the solution? Are you able to rebuild the solution without any errors? I would also use the clean solution option.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Chad Tran answered on June 15, 2021 12:24

Dear Juraj, Thanks for your support, it seem like my Visual Studio has error compile or something. I have reset Visual Studio, clean solution, change target framework for all projects in solution and use command reinstall again and it's OK now. Best regards,

0 votesVote for this answer Mark as a Correct answer

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