Sitecore: Could not load file or assembly ‘Oracle.DataAccess, Version=2.112.1.0’ or one of its dependencies. The system cannot find the file specified.

I recently came across this error on my Sitecore site after I installed and uninstalled Sitecore.Ship:

Could not load file or assembly 'Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

I’d like to share here how I fixed this error and my debugging process. The first thing I did was to enable assembly binding logging to get more information. To do this: type in Regedit in your Start search bar and open Registry Editor. On the left panel navigate to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion, right click on the empty space on the right side and click New > DWORD(32-bit) Value. Make the Name “EnableLog” and right click on it, click “Modify…” and change Value data from 0 to 1.

regedit

After modifying this setting, go back to your Sitecore website and hit refresh (restart your computer if the error message does not change). Now you can see the binding log:

=== Pre-bind state information ===
LOG: DisplayName = Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342
 (Fully-specified)
LOG: Appbase = file:///C:/inetpub/wwwroot/dotcom3/Website/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\dotcom3\Website\bin
Calling assembly : Sitecore.Oracle, Version=8.1.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\dotcom3\Website\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.]
   System.RuntimeTypeHandle.GetDeclaringType(RuntimeType type) +0
   System.RuntimeTypeCache.GetEnclosingType() +27
   Nancy.TinyIoc.TinyIoCContainer.<AutoRegisterInternal>b__13(Type type) +80
   System.Linq.WhereListIterator`1.MoveNext() +79
   Nancy.TinyIoc.TinyIoCContainer.AutoRegisterInternal(IEnumerable`1 assemblies, Boolean ignoreDuplicateImplementations, Func`2 registrationPredicate) +652
   Nancy.DefaultNancyBootstrapper.AutoRegister(TinyIoCContainer container, IEnumerable`1 ignoredAssemblies) +270
   Nancy.Bootstrapper.NancyBootstrapperBase`1.Initialise() +191
   Nancy.Hosting.Aspnet.NancyHttpRequestHandler..cctor() +44
[TypeInitializationException: The type initializer for 'Nancy.Hosting.Aspnet.NancyHttpRequestHandler' threw an exception.]
   Nancy.Hosting.Aspnet.NancyHttpRequestHandler..ctor() +0

The first block of red text tells us the calling assembly is Sitecore.Oracle. If you open that dll using a decompiler such as dotPeek you can see under References near Oracle.DataAccess there is a question mark, and Location is empty in Properties.

dotPeekOracle4

From the second block of red text you can see that an exception is thrown by Nancy, a lightweight .Net framework for building HTTP based services. Sitecore.Ship has added a dependency Nancy.Hosting.AspNet. You’d think with the uninstallation of Sitecore.Ship this dependency should go away, but it doesn’t. This configuration is done in your Sitecore wwwroot/Website/Web.config file and it’s not removed upon uninstallation. Before installing Sitecore.Ship everything worked fine because although the Oracle.DataAccess assembly doesn’t exist, it was not being called.

So, find these lines in your Web.config file and remove them:

<add name="Nancy" verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" /><remove name="Sitecore.Ship" /><add name="Sitecore.Ship" verb="*" type="Sitecore.Ship.AspNet.SitecoreShipHttpHandler, Sitecore.Ship.AspNet" path="/services/*" />
<httpHandlers>
<add verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" />    <add verb="*" type="Sitecore.Ship.AspNet.SitecoreShipHttpHandler, Sitecore.Ship.AspNet" path="/services/*" />
</httpHandlers>

Now the error message should go away. Remember to delete the EnableLog registry value in Registry Editor.

Feel free to let me know your thoughts.

Sitecore PowerShell – Enable Item Level Language Fallback

The use case for this blog is to enable item-level fallback on all items based on any user-defined template (or based on any template located in a given folder).

Here are three steps you need to follow in order to set up the language fallback functionality in Sitecore:

  1. Enable site-level fallback in \Website\App_Config\Include\Sitecore.LanguageFallback.config.
  2. Specify the Fallback Language for the language items located in sitecore/system/Languages.
  3. Either enable item-level fallback or field-level fallback per your need.

To enable fallback for all items of a given template, just set it on the template’s __Standard Values.

fallback

However, when there are too many templates to deal with, this task can become very tedious, so we are going to automate this process and perform a batch update using Sitecore Powershell Extensions.

Here is my script:

Write-Host "Creating Standard Values items for:" -ForegroundColor green
$Items = Get-ChildItem master: -ID "{GUID of the templates folder}" -Recurse | Where-Object {$_.TemplateName -eq 'Template'-and `
                !$_.Children["__Standard Values"] }

foreach($Item in $Items)
{
    Write-Host $Item.Paths.Path
    $standardvalues = New-Item -Parent $Item -Name "__Standard Values" -type $Item.ID
    $Item.Editing.BeginEdit()
    $Item["__Standard values"] = $standardvalues.ID
    $Item.Editing.EndEdit()
}
Write-Host "Total number of items modified: " $Items.Count

Write-Host "Enabling Item Level Fallback for:" -ForegroundColor green
$Items = Get-ChildItem master: -ID "{ GUID of the templates folder }" -Recurse | Where-Object {$_.Name -eq '__Standard Values'-and `
                $_.'__Enable item fallback' -eq $false }
foreach($Item in $Items)
{
    $Item.'__Enable item fallback' = $true
    $Item.Paths.Path
}
Write-Host "Total number of items modified: " $Items.Count

The first half of the script finds all templates within the given folder (such as a “User Defined Templates” folder), and creates a __Standard Values item for the templates that don’t already have one. The second half of the script goes through all the __Standard Values items that don’t have Enable Item Fallback checked and set them to true.

The paths of all modified items are printed to the console:

Creating Standard Values items for:
 /sitecore/templates/User Defined/Public/Carousels/FeaturedItemsCarousel
 True
 /sitecore/templates/User Defined/Public/Carousels/RecognitionCarousel
 True
 /sitecore/templates/User Defined/Public/Carousels/TimelineCarousel
 True
  …
Total number of items modified:  39


Enabling Item Level Fallback for:
 /sitecore/templates/User Defined/Public/Careers/Statement Block/__Standard Values
 /sitecore/templates/User Defined/Public/Careers/Header Section/__Standard Values
 /sitecore/templates/User Defined/Public/Careers/Landing Hero Section/__Standard Values
  …
Total number of items modified:  227

 

Now you efficiently have all items based on the templates in that folder enabled for fallback. Please feel free to let me know your thoughts and suggestions. Thanks!

My Experience with the new Sitecore® Professional Developer Certification Exam (MVC)

I have just passed the new Sitecore® Professional Developer Certification exam today and I’d like to share some of my experience here. It’s a two-hour exam but you are likely to finish it in one hour or less. 70 multiple choice questions in total, no notes allowed. The exam questions are not very hard but they are very comprehensive. They cover all the topics (shown below) listed on the Exam Study Guide page, and the accompanied percentages are quite accurate. The Sample Questions on that Study Guide page were a big help on the exam, and so were the review questions at the end of each module in the training material.

Competencies % of Questions
API 6 %
Architecture 2 %
Creating and Editing Items 9 %
Development Environment 6 %
Fields and Field Types 9 %
Installation 2 %
Marketing 10 %
Media 2 %
Module Packages 2 %
Multi-Language 3 %
Publishing 6 %
Search 10 %
Security 6 %
Sitecore Documentation and Support 2 %
Templates 11 %
Versioning 2 %
Workflows 3 %
xManagement 9 %
TOTAL 100%

It’s been about four months since I first got on Sitecore. I was staffed on a Sitecore project after the first month of learning and now the project has just been completed. If you could fully focus on just preparing for the exam, one month of time should be enough, assuming you have some prerequisite knowledge in ASP.NET and MVC. Here are some of my personal experience and recommendations:

– Watch all the Sitecore® Experience Solution Developer eLearning training videos. This is the most helpful resource for the exam. Take notes and screenshots throughout the course because:

  1. The course expires after a few months and you won’t be able to come back to it.
  2. Reviewing the notes and screenshots when it gets close to the exam day proved to be very helpful to me. Many exam questions come directly from details that I have taken down in my notes.

– Complete all the labs in the Workbook PDFs that come with the training. The labs are very hands-on and well designed. I did the labs after I went through all the training videos, because:

  1. I couldn’t help but first cover all the aspects Sitecore has to offer; doing the corresponding lab right after each module slows me down.
  2. Many, many topics are covered in the training (and surely in the exam), and I tend to forget some knowledge that I’ve learned as I go along with the training. Starting the labs after completing all the training videos gives me another chance to refresh and enhance my memory. There were some exam questions that I was able to answer because I did the labs, coded in Visual Studio and configured in Sitecore.

– (Optional) Get on a real-life Sitecore project. I have heard talk that the old Web Form training was not super helpful in terms of practical usage, but that’s not the case with the new training. I got up to speed with the project development quite fast because I was prepared from the training. More than a few times I used my notes and the book mentioned below as reference to resolve the problems I had at hand. On the other hand, the project experience familiarized me with Sitecore development and thus I could fly though the labs later without much need to debug.

– (Optional) Read the Professional Sitecore 8 Development book by Phil Wicklund and Jason Wilkerson. This book should be read after you complete the training material (said from someone who didn’t – I read the book first), or else you might often get confused reading it. This book will help you more in your development experience than the certification exam; it includes some discussion and projects on topics such as Helix, Inversion of Control, Design Patterns, the Sitecore PowerShell extension etc. If all you have is the book and you don’t have access to the $1500 training, this free course, Sitecore® Developer Foundations, can get you started with some basic concepts.

I’m very happy to share my experience with the hope that it can help prepare you for the exam. I encourage you to write any feedback about your experience or questions about the exam. Good luck!