I have a transformation script component within a data flow task - using KingswaySoft.
However, I get the error "Object reference not set to an instance of an object" when the script task executes.
I pass an SSIS variable into the component called "ContactGUID". The component also has 1 input, "CRMRecordId", which is the GUID of the custom entity I want to retrieve the x_contact value from. The component has a CRMConnection manager and one output column added.
My first question is there anyway to debug Script Components? I have tried setting a message box/break points - but the object error appears as soon as the script component is reached within the data flow.
Here is my code:
#region Namespaces using System; using System.Data; using Microsoft.SqlServer.Dts.Pipeline.Wrapper; using Microsoft.SqlServer.Dts.Runtime.Wrapper; using Microsoft.SqlServer.Dts.Runtime; using System.Windows.Forms; using KingswaySoft.IntegrationToolkit.DynamicsCrm; using KingswaySoft.DynamicsCrmServices.Soap2011; using KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.Query; using KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService; using KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.Messages; using KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.Metadata; using System.ServiceModel.Description; using Microsoft.SqlServer.Dts.Pipeline; using System.Runtime.Serialization; #endregion [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute] public class ScriptMain : UserComponent { public IOrganizationService _service; KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.IOrganizationService orgService; public override void PreExecute() { Console.WriteLine("starting pre-execute"); base.PreExecute(); var connMgr = this.Connections.CrmConnection; var connectionString = (string)connMgr.AcquireConnection(null); var conn = new CrmConnection(connectionString); var orgService = (IOrganizationService)conn.GetCrmService(); // SOAP 2011 } public override void PostExecute() { base.PostExecute(); } public override void Input0_ProcessInputRow(Input0Buffer Row) { ColumnSet cols = new ColumnSet( new String[] { "x_contact" }); Entity contactIdentifier = orgService.Retrieve("x_contactidentifier", Row.CrmRecordId, cols); if (contactIdentifier.Contains("x_contact")) { Variables.ContactGUID = Convert.ToString(contactIdentifier.Attributes["x_contact"]); } } }
When I comment out the call to "orgService" the error is no longer - which leads me to believe it may be something todo with the "Pre-Execute" Method.
Any help would be much appreciated - Thanks
Additional Information:
CRM 365 Online
SQL Server 2017
*This post is locked for comments