Could not load file or assembly

Problem

FatalError: Could not load file or assembly ‘KWizCom.Foundation, Version=13.2.40.0, Culture=neutral, PublicKeyToken=30fb4ddbec95ff8f’ or one of its dependencies. The system cannot find the file specified.
Debug:    at KWizCom.SharePoint.FieldControls.DualLookupType.FieldSettings.GetFieldSettings(String fieldSettings)
at KWizCom.SharePoint.FieldControls.DualLookupType.DualLookupField.OnUpdated()

When

During content deployment.

Why

The above error happens when a content database still uses an older version (eg 13.2.40.0) of Kwizcom.Foundation, but the installed assemblies in your GAC are of later versions (13.2.50.0). .Net provides a cool dependentAssembly redirect feature, using which any older version of dll’s can automatically be redirected to use a newer version. This happens during the import phase and not during the export phase. So you have to check the target server content deployment import logs to verify the error.

During KwizCom upgrade or installation, the web.config, it automatically updates the dependent assembly redirection. But this will not help for Content Deployment. Because the web.config redirections are used by w3wp processes, while content deployment is run by a timer job, which is a Windows Service called “SharePoint 2010 Timer” and runs the file $hive14/bin/owstimer.exe which uses its own config file owstimer.exe.config.

Solution

When I inspected the bin directory, the owstimer.exe.config file was already there and Kwizcom had created one with the following content:

<?xml version=”1.0″ encoding=”utf-8″?>
<configuration>
<runtime>
<assemblyBinding xmlns=”urn:schemas-microsoft-com:asm.v1″>
<dependentAssembly xmlns=””>
<assemblyIdentity name=”KWizCom.SharePoint.Foundation” publicKeyToken=”30fb4ddbec95ff8f” culture=”neutral” />
<bindingRedirect oldVersion=”1.0.0.0-20.0.0.00″ newVersion=”13.2.50.0″ />
</dependentAssembly>
<dependentAssembly xmlns=””>
<assemblyIdentity name=”KWizCom.Foundation” publicKeyToken=”30fb4ddbec95ff8f” culture=”neutral” />
<bindingRedirect oldVersion=”1.0.0.0-20.0.0.00″ newVersion=”13.2.50.0″ />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Just in case, I restarted the timer service, but I was still getting the error, inspite of the above configuration. Now I turned to the next possible solution: google.

Shai Petel has written a blog about how to fix this via a wsp solution. While it is a good solution to keep that in wsp, in our case, I could not afford to change the wsp as the problem was happening in production. I noticed in Mr. Petel ‘s blog where the code replaces xmlns=”” with empty string. So I just went ahead and removed the xmlns=”” string in the above config and restarted the timer service.

Now the content deployment worked fine. The advantage is no need to restart website, so there is no downtime. The disadvantage is this has to be done in every WFE server of the farm.

This problem is probably only until the version of 13.2.62.0. In the current version (13.2.71.0) the xmlns=”” issue is fixed (I have not verified it though).

3 thoughts on “Could not load file or assembly

  1. I had a very similar problem with Kwiz foundation. The solution suggested here did not work for me. Atlast my senior suggested that I should download the the old version (the one which shows up in logs) and then try. That worked.

    Like

    1. @sameer Which version did not work? I remember reading from Shai Petel’s blog that it was fixed in a later version…

      Like

  2. Well, actually he suggested, we extract the dll’s from old version wsp and load them into GAC so that the new and the old versions can run side by side.

    Like

Leave a comment