2

I'm using Sitecore 8.1 Original Release and am having problems getting my contact stuff to work properly. Here's my code:

var repository = new ContactRepository();
contact = repository.CreateContact(System.Guid.NewGuid());

When I try to execute this code, I get this error:

Could not load file or assembly 'file://c:\windows\system32\inetsrv\Sitecore.Analytics.Model.Entities.ContactPersonalInfo' or one of its dependencies. The system cannot find the file specified."

This is the same configuration that I've been using for several months, however, I've never tried to create a contact before. I've always just let Sitecore create a contact for me. This error message doesn't make sense, because I'm running my Sitecore instance in a completely separate location (different drive and everything). I've tried copying the Sitecore.Analytics.Model.dll to the specified directory, but I didn't have any luck.

Questions:

  1. What could be causing Sitecore to look in such an odd place for the DLL when I call the create function?
  2. How can I fix this?
3
  • Could you open /sitecore/admin/ShowConfig.aspx on your Sitecore website and search for "Sitecore.Analytics.Model.Entities.ContactPersonalInfo" (without the quotes) on the page? Commented Mar 3, 2017 at 12:30
  • I think you might have a bad dll in there. Can you download the Sitecore zip installer from Sitecore, unzip the bin and beyond compare the sitecore.dll files? I think you'll find its an ancillary dll and not Sirecore.Analytics.Model.dll
    – Chris Auer
    Commented Mar 3, 2017 at 14:47
  • OK, so it took me awhile to finally narrow it down. The issue was caused by a partial XML comment in one of my config override files. The config override was adding some additional Facet definitions, and another developer had uncommented the first part of the definition, but had left the last part of the comment in the config file. This caused the config processor to lose a lot of the definitions, and as a result I got that error. Thanks to everyone who helped me figure out what was going on! Commented Mar 3, 2017 at 21:07

3 Answers 3

1

Error Explanation:

As Error says the type is missing in this assembly as shown and also this has been replaced by an Interface IContactPersonalInfo Interface is implemented in 'Sitecore.Analystics.Mode.Generated.ContactPersonalInfo’

enter image description here

Cross Check:

  1. Please verify you have this in Sitecore configuration through /sitecore/admin/showconfig.aspx patched up thr ‘Sitecore.Analytics.Model.Config’ It states Interface& its implementation.

enter image description here

  1. Please verify you have Sitecore.Analytics.Model.dll in your csproj with appropriate version. Follow these links if old dll is still being used

    Link1 Link2

1
  • By looking at the ShowConfig.aspx and comparing that to a working 8.1 instance, I was able to find out that the definitions for the facets were missing. Commented Mar 3, 2017 at 21:08
0

Couple of points to check:

  1. Check how are you referencing the Sitecore.Analytics.Model.dll in your project
  2. Make sure that this assembly is present in your solution (website) bin directory
  3. You can use the Find in Files feature of i.e. Notepad++ to lookup for references of Sitecore.Analytics.Model* in all *.csproj files of your project to understand how it is referenced.
0

The issue that you are seeing is because you are trying to instantiate a new ContactRepository().

The appropriate way to reference the repository is by creating the object through Sitecore's Configuration Factory.

private ContactRepository _repository = Sitecore.Configuration.Factory.CreateObject("tracking/contactRepository", true) as ContactRepository;
2
  • This didn't end up helping. I got the same error either way. Once I got it working, I was able to call it either with the factory or with the CreateObject method. What's the benefit of using the factory method over the built-in .NET method? Commented Mar 3, 2017 at 21:09
  • On benefit is that in the event someone patches or updates the content repository through sitecore config, code doesnt have to be updated. Commented Mar 3, 2017 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.