Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Error when connect to Dynamics 365 From Desktop App

(0) ShareShare
ReportReport
Posted on by 4,096

Hi 

What can be possibly wrong with this code as I' trying to connect to D365 from VS Desktop C#

I'm getting this error:

CurrentAccessToken = 'svcClient.CurrentAccessToken' threw an exception of type 'System.NullReferenceException'

string connectstr =
"AuthType= 'ClientSecret';" +
"url='">OrgName.crm3.dynamics.com';" +
"ClientID='75fbd615-af9a-4d2c-b072-d78da6635189';" +
"ClientSecret='wpy8Q~Z2DimQgaYSMNC0w5kaOBcWFUsW_4Zd5aNX';";

using (CrmServiceClient svcClient = new CrmServiceClient(connectstr))
{
if (!svcClient.IsReady)
{
Console.WriteLine("unable to connect!");
return;
}
}

  • Suggested answer
    Manoj Mane Profile Picture
    1,020 on at
    RE: Error when connect to Dynamics 365 From Desktop App

    Hi Alaa Ramadan,

    please refer the  below link:- 

    stackoverflow.com/.../connection-to-microsoft-dynamics-365-working-in-console-app-but-not-in-web-app


    Thanks,

    Manoj Mane.
    Please mark this as VERIFIED if it helps. image

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 671 Super User 2025 Season 1

#2
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 167 Super User 2025 Season 1

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 138 Most Valuable Professional

Product updates

Dynamics 365 release plans