0

I have generated the XRM class file using SDK in cmd prompt.

And I have installed the Package Microsoft.CrmSdk.Xrm.Tooling.CoreAssembly for my solution then I have started using XRM file entities in my solution for query the data.

While querying the data from Dynamics CRM 365 online in Local, if I debug everything works file but if I publish and deploy it in the PROD environment I get an error

var dict = new Dictionary<string, string>();
using (var conn = getconnection())
{
  e2 = "Connected: "+ conn.ConnectedOrgFriendlyName;
  _orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null 
    ? (IOrganizationService)conn.OrganizationWebProxyClient 
    : (IOrganizationService)conn.OrganizationServiceProxy;

  e3 = "Initiatedsss";
  using (var service = new XrmContext(conn))
  {
    crmOpp = service.OpportunitySet.Where(x => x.new_OppHubspotid == hubSpotId).ToList();
  }
}

Object reference not set to an instance of an object.
StackTrace : at HubSpot_CRMIntegration.HubSpotDealService.GetDataCrmconnection(String hubSpotId) Date :10/30/2018 6:10:03 AM HubspotID: 03b0b3db-22d6-e811-a954-000d3a59746e FrameCount: 1 Error Line: 0, GetDataCrmconnection at offset 807 in file:line:column :0:0 Error 1: Entered Error 2: Connected: Anexinet Dev Testing CRM: Error 3: Initiatedssss Error 4: Error 5

jasonscript
  • 5,189
  • 1
  • 23
  • 39
  • Can you see any errors in the Plugin Trace Log? You should try to write the value of the `e2` and `e3` variables to the Plugin Trace Log – jasonscript Oct 30 '18 at 03:41
  • Message :Object reference not set to an instance of an object.
    StackTrace : at HubSpot_CRMIntegration.HubSpotDealService.GetDataCrmconnection(String hubSpotId) Date :10/30/2018 6:10:03 AM HubspotID: 03b0b3db-22d6-e811-a954-000d3a59746e FrameCount: 1 Error Line: 0, GetDataCrmconnection at offset 807 in file:line:column :0:0 Error 1: Entered Error 2: Connected: Anexinet Dev Testing CRM: Error 3: Initiatedssss Error 4: Error 5:
    – Vaasir Nisaar S Oct 30 '18 at 10:32
  • `var url = "https://xxx.crm.dynamics.com/"; var user = "x.xxx@xxx.com"; var pass = "xxxxxxxx"; IOrganizationService service = CreateProxy(url, user, pass); var ctx = new OrganizationServiceContext(service); var firstAccountNumber = ctx.CreateQuery("account") .Take(1) .Select(c => c.GetAttributeValue("accountnumber")) .FirstOrDefault(); Console.WriteLine();` – Marcelo Acosta Díaz Nov 06 '18 at 13:21
  • This issue is fixed by adding the System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Before the ClientCrmConnection code line – Vaasir Nisaar S Nov 19 '18 at 10:29

0 Answers0