web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Queryexpression not returing results

(0) ShareShare
ReportReport
Posted on by 75

I am attempting to make a console application to retrieve results using the Dynamics CRM SDK and C# but I can't seem to get any results from my queries. I can see that I am connected to the CRM instance, but any QueryExpression I try to make seems to come back with nothing, even if I set it with no filter.  I have also tried with fetchxml, no results returned. I am getting the below error.

Exception thrown: 'System.ServiceModel.FaultException`1' in Microsoft.Xrm.Sdk.dll
An unhandled exception of type 'System.ServiceModel.FaultException`1' occurred in Microsoft.Xrm.Sdk.dll
Invalid XML.

The account which I am using is admin account. Any suggestions would be helpful. Thanks in advance!!

8168.screen.PNG1050.Capture.PNG

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    checking if the userid value is not an empty is kind of useless, if you have connection problems you will get an exception before getting to that line.

    Let's assume only the QueryExpression of your second screenshot (the fetchxml of your first screenshot is clearly unformatted but it should be ok) if you remove the condition you will get all the contacts in the system (up to 5000), if you still get an error (and the userid has value) then post your full code, because that code you posted should work

  • Verified answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    Hi,

    There seems to be an issue with fetch xml.

    I would recommend to use below tool to format your fetchxml to use in C# console.

    www.ashishvishwakarma.com/.../

    If found helpful, Please mark my answer verified.

  • Jayaa E Profile Picture
    75 on at

    Thanks a lot Bipin. As you said, the issue was in fetchxml.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 184 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 125

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans