Notifications
Announcements
No record found.
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
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
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.
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!
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2