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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

error connecting to CRM

(0) ShareShare
ReportReport
Posted on by

I'm getting an error trying to query CRM - Program does not contain a static 'Main' method suitable for an entry point. Any ideas?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi!

    That's not a CRM error, that's coming out of the C# project you're writing to hit CRM. You're getting that error because the project don't know where to start the program. It looks like either a Console App or a Windows Service to give that error. For those types of programs, you need a static method for when the program should start. With a console app, add:

    static void Main(string[] args)

    {

    }

    and for a service, do the same thing but with no parameters. Then that method will be called when you start running the program.

    Hope this helps! I'd appreciate if you'd mark this as a Verified answer.

    Thanks,

     Aiden

  • Community Member Profile Picture
    on at

    Okay... I don't get that error any more but how do I get records from CRM? I'm trying to get all accounts that have been changed in the last 7 days.

  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi,

    First, download the CRM 2015 SDK. It has assemblies you need to reference and lots of good samples to get you started. Once you get that set up, connecting to CRM is really easy. You can set up a connection string using a SQL style format:

    var connection = Microsoft.Xrm.Client.CrmConnection.Parse("Url=http://{my url}; Domain={dom}; Username={un}; Password={pwd};");
    var service = new Microsoft.Xrm.Client.Services.OrganizationService(connection);
    


    Any requests to CRM should go through your organization service 'service'. You can run your query as fetch XML like this:

    ExecuteFetchRequest request = new ExecuteFetchRequest() { FetchXml = fetchXml };
    fetchResponse = service.Execute(request) as ExecuteFetchResponse;
    


    or using a Microsoft.Xrm.Sdk.Messages.RetrieveMultipleRequest. 
    I like using RetrieveMultiple, but Fetch may be easier because you can build your query in the advanced find and export the fetch xml to use in your query. Hope this helps!

     

    Thanks,

      Aiden

  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    FYI - you can get the SDK here: www.microsoft.com/.../details.aspx

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans