Search code examples
azuredynamics-crmoffice365azure-web-app-servicedynamics-crm-online

D365 simplified connection Azure App Services


I'm using the simplified connection to D365 from the Microsoft.Xrm.Tooling.Connector.dll Example can be found in the SDK SDK\SampleCode\CS\QuickStart\SimplifiedConnection.cs

The issue is that it doesn't work when the site is deployed to an Azure App Service (former web sites) while it works fine running the site locally.

The exception is very general:

Object reference not set to an instance of an object

Any of you have seen this or knows the issue/resolution?

CrmServiceClient crmConn = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRM"].ConnectionString);
IOrganizationService crmService = crmConn.OrganizationServiceProxy;
<connectionStrings>
<add name="CRM" connectionString="AuthType=Office365;Url=https://instance.crm4.dynamics.com; [email protected]; Password=Lu555" />

EDIT WHEN RESOLVED Added following listener in web.config Source

<system.diagnostics>
<trace autoflush="true" />
 <sources>
 <source name="Microsoft.Xrm.Tooling.Connector.CrmServiceClient"
 switchName="Microsoft.Xrm.Tooling.Connector.CrmServiceClient"
 switchType="System.Diagnostics.SourceSwitch">
 <listeners>
 <add name="console" type="System.Diagnostics.DefaultTraceListener" />
 <remove name="Default" />
 <add name ="fileListener" />
 </listeners>
 </source>
<source name="Microsoft.Xrm.Tooling.CrmConnectControl"
 switchName="Microsoft.Xrm.Tooling.CrmConnectControl"
 switchType="System.Diagnostics.SourceSwitch">
 <listeners>
 <add name="console" type="System.Diagnostics.DefaultTraceListener" />
 <remove name="Default" />
 <add name ="fileListener" />
 </listeners>
 </source>
 </sources>
 <switches>
  <add name="Microsoft.Xrm.Tooling.Connector.CrmServiceClient" value="Verbose" />
 <add name="Microsoft.Xrm.Tooling.CrmConnectControl" value="Verbose" />
 <add name="Microsoft.Xrm.Tooling.WebResourceUtility" value="Verbose" />
 </switches>
 <sharedListeners>
 <add name="fileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="XRMToolingLogs.log" />
 </sharedListeners>
</system.diagnostics>

Solution

  • From the listener above, I got following error

    Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference

    what makes me think there is an issue with NuGet packages, as I have installed all through Manage NuGet Packages in Visual Studio.

    I've resolved the error by adding this in the web.config. After this, my web site connected fine to D365 in an Azure web site.

     <dependentAssembly>
        <assemblyIdentity name="Microsoft.Xrm.Sdk" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
      </dependentAssembly>