Could not load file or assembly 'CMS.PortalControls'

Kyle G asked on May 15, 2017 19:45

I'm trying to add a Faceted Search webpart to my solution but I'm getting the following error:

Message: Could not load file or assembly 'CMS.PortalControls, Version=6.0.4463.26642, 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 applied the latest .50 hotfix to my Kentico 8.2 solution, and I'm hoping it's an easy fix vs an upgrade to the latest version. I have also confirmed that the CMS.PortalControls.dll is present.

If anyone has insight, it would be much appreciated.

Kyle

Recent Answers


Brenden Kehren answered on May 15, 2017 19:53

It appears you're referencing an old assembly somewhere.

...CMS.PortalControls, Version=6.0.4463.26642...

I'd check in your web.config for that assembly and see if it's possible it was added accidentally.

There could be a variation of other things to check but that is where I'd start.

0 votesVote for this answer Mark as a Correct answer

Kyle G answered on May 15, 2017 20:26 (last edited on May 15, 2017 20:26)

Thanks Brenden, there are no references to Version=6.0.4463.26642 anywhere in the solution. The reference in web.config looks like this:

add tagPrefix="cms" namespace="CMS.PortalControls" assembly="CMS.PortalControls"

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 15, 2017 20:28

Have you checked the versions of your dlls in your bin directory?

0 votesVote for this answer Mark as a Correct answer

Kyle G answered on May 15, 2017 20:33

The file version in the bin folder is 8.2.5816.17364

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on May 16, 2017 14:50

Perhaps you can provide a bit more detail on the error? such as page that reports the error and if available a Stack Trace since this will let us know what is trying to referrnce the older DLL.

0 votesVote for this answer Mark as a Correct answer

Kyle G answered on May 16, 2017 15:16

Here's the stack trace:

Message: Could not load file or assembly 'CMS.PortalControls, Version=6.0.4463.26642, 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)

Exception type: System.IO.FileLoadException Stack Trace: at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) at System.Reflection.Assembly.GetType(String name) at System.Web.Compilation.BaseTemplateBuildProvider.GetGeneratedType(CompilerResults results, Boolean useDelayLoadTypeIfEnabled) at System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results) at System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results) at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at CMS.PortalControls.CMSWebPartZone.LoadWebPart(Control container, CMSWebPartZone zone, WebPartInstance part, Boolean reloadData, Boolean isVariant)

Message: Could not load file or assembly 'CMS.PortalControls, Version=6.0.4463.26642, 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)

Exception type: System.IO.FileLoadException Stack Trace: at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) at System.Reflection.Assembly.GetType(String name) at System.Web.Compilation.BaseTemplateBuildProvider.GetGeneratedType(CompilerResults results, Boolean useDelayLoadTypeIfEnabled) at System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results) at System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results) at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at CMS.PortalControls.CMSWebPartZone.LoadWebPart(Control container, CMSWebPartZone zone, WebPartInstance part, Boolean reloadData, Boolean isVariant)

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 16, 2017 15:24

What it looks like is you have an old DLL in your project referencing Kentico CMS.PortalControls v6 dll. Was your site upgraded from a previous version? I'd go to the file system and look in the bin directory and show the file version number column in the explorer window and see which version is off.

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on May 16, 2017 16:08

The stack trace indicates a control being loaded via the VirtualPath is referencing the older CMS.PortalControls.

Brenden's suggestion would be a good place to start, however, it could be that you have a custom dll that was built against Kentico 6 and hence your version numbers may look good.

If your version numbers do look good, you could try changing the assembly binding by adding the following to the Web.Config under the configuration node (replace the x's in newVersion to match the 8.2 version you have):

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="CMS.PortalControls" publicKeyToken="834b12a258f213f9" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="x.x.x.x" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

Hopefully this will allow your code to continue but provide another error to help you figure out what is referencing it so you can fix it properly.

0 votesVote for this answer Mark as a Correct answer

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