I'm running Sitecore 8.1 Original Release, and I'm trying to run this code:

var repository = new ContactRepository();
var contact = repository.LoadContactReadOnly(contactId);

where contactId is passed in as a System.Guid Datatype.

I have 3 IDs that I should be able to load and not return a null value. Here they are (in RoboMongo): Contact IDs

Here's what I've tried:

  1. I reset IIS and not browsed to my dev site located on my local box. This should ensure that the contact isn't locked.
  2. I've changed Robomongo to return the UUID Encoding as "Legacy" as well as ".NET encoding", which changed the UUIDs, but did not affect the outcome.
  3. I've checked the Sitecore_Analytics_Index for a clue about what IDs would return any valid information, but those IDs don't seem to match anything that I've got anywhere else, and if I query with them, that doesn't seem to get me anywhere either.

It seems that no matter what I try, I can't find a contact to load, even though I see it in Mongo. Any ideas on how I can load a contact?


  • Can you confirm that your connection strings are pointing to the right Mongo server and collection? I know it may seem like a elementary task. Mar 3 '17 at 0:18
  • I was able to confirm that. This problem seemed to stem from the fact that I wasn't able to load or create any contact card information. I didn't realize that both of my problems were related to a bad configuration setting. Thank you so much for your help, Pete! Mar 3 '17 at 21:11
  • Well, not sure I was as much help. But I do suggest using configuration factory for the contact repository. That way, if someone or something or Sitecore changes it through config, it will still work. Mar 3 '17 at 22:08

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;

See also: Could not load file or assembly 'file://c:\windows\system32\inetsrv\Sitecore.Analytics.Model.Entities.ContactPersonalInfo' or one of its dependencies

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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