1

In this Sitecore article, there is a code sample implements ICondition and IContactSearchQueryFactory. We believe that this code will help us to add custom rules to the Sitecore List Manager. However, when we try to implement this class, we get the errors "The type or namespace name 'ICondition' could not be found." and "The type or namespace name 'IContactSearchQueryFactory' could not be found."

We have added references to the dlls Sitecore.XConnect.Segmentation.Predicates.dll and Sitecore.Framework.Rules.dll (per this documentation for 9.1 - we're on Sitecore 10.2) from our sitecore instance, and they're referenced via usings in the file where we're trying to implement the class, but the error persists.

I'm wondering if there is a possibility that those are in a different DLL, otherwise I'm stumped as to why they wouldn't be found. Our code is exactly the same as the example in that sitecore article (see below). How can we resolve those two interfaces?

using System;
using System.Linq.Expressions;
using Sitecore.Framework.Rules;
using Sitecore.XConnect;
using Sitecore.XConnect.Segmentation.Predicates;
using Sitecore.XConnect.Collection.Model;
using System.Linq;

namespace Documentation.Examples
{
    public class PreferredCinemaMatches : ICondition, IContactSearchQueryFactory
    {
        //implementation
    }
}

3 Answers 3

1

I tried it on my system and added all the references given in your question and in the article that you are following. And it works for me without any errors.

Here is my class.

using System;
using System.Linq.Expressions;
using Sitecore.Framework.Rules;
using Sitecore.XConnect;
using Sitecore.XConnect.Segmentation.Predicates;

namespace WebApplication1
{
    public class PreferredCinemaMatches : ICondition, IContactSearchQueryFactory
    {
        public Expression<Func<Contact, bool>> CreateContactSearchQuery(IContactSearchQueryContext context)
        {
            throw new NotImplementedException();
        }

        public bool Evaluate(IRuleExecutionContext context)
        {
            throw new NotImplementedException();
        }
    }
}

And here are the reference that I have for my project.

enter image description here

You can verify all the references for your solution. Maybe you are missing something.

Hope it helps.

1
  • Adding more references got it working. I've added my own answer below with all of the DLLs I ended up adding, for reference for anyone who finds this question in the future, but I believe adding the list of references you shared would resolve the issue, so I've accepted your answer. Thank you for your help in troubleshooting this!
    – James G.
    Commented Feb 28, 2023 at 16:44
0

Seems that you need to add a reference to Sitecore.Framework.Rules.

Credit: https://sitecorewithraman.wordpress.com/2021/05/02/custom-rules-segmented-list-marketing-automation/

Just tested and this keeps the compiler happy:

using Sitecore.XConnect;
using Sitecore.XConnect.Segmentation.Predicates;
using Sitecore.Framework.Rules;
using System.Linq.Expressions;
using System;

namespace Documentation.Examples
{

    public class PreferredCinemaMatches : ICondition, IContactSearchQueryFactory
    {
        public Expression<Func<Contact, bool>> CreateContactSearchQuery(IContactSearchQueryContext context)
        {
            throw new NotImplementedException();
        }

        public bool Evaluate(IRuleExecutionContext context)
        {
            throw new NotImplementedException();
        }
    }
}
1
  • The reference to Sitecore.Framework.Rules on it's own didn't seem to work. I'm not sure why, but some other references were needed for the Sitecore.Framework.Rules to work as expected. Maybe this is a Sitecore subversion specific issue?
    – James G.
    Commented Feb 28, 2023 at 16:46
0

I do believe adding all of the DLLs listed in the answer by Sumit would work to troubleshoot this issue, however, I'm putting my own answer here with a list of the DLLs I've added to get everything working, just in case. In order to resolve this issue, I needed to add references to a variety of DLLs other than Sitecore.Framework.Rules.dll and Sitecore.XConnect.Segmentation.Predicates.dll

enter image description here

enter image description here

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.