2

Really weird error. I have two independently working source C# scripts in SSIS. Basically they go and grab information from an external CRM source.

When they are both enabled in the same script, On the first script that executes I get:

Object reference not set to an instance of an object

This works

http://i.imgur.com/dz6fi2o.png

This does not - it freezes on the the first script.

http://i.imgur.com/Kgvi51a.png

I would think it might be a buffer issue, but it would still complete the first script before throwing the error. Both scripts have unique ids and guids.

Debugging is useless, it dosen't stop on any of the code that I've programmed. I'm stumped.

This is ScriptThree.CreateNewOutputRows() - Important to note that scriptthree is part of the second dataflow task.

    public override void CreateNewOutputRows()
{
    /*
      Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
      For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
    */

    QueryExpression query = new QueryExpression("email")
    {
        ColumnSet = new ColumnSet(new string[] { "subject", "regardingobjectid", "createdon", "directioncode" }),
        PageInfo = new PagingInfo()
        {
            Count = 250,
            PageNumber = 1,
            ReturnTotalRecordCount = false
        }
    };

    EntityCollection results = null;

    do
    {
        results = organizationservice.RetrieveMultiple(query);

        foreach (Entity record in results.Entities)
        {
            emailBuffer.AddRow();

            emailBuffer.emailid = record.Id;

            if (record.Contains("subject"))
                emailBuffer.subject = record.GetAttributeValue<string>("subject");
            if (record.Contains("regardingobjectid"))
                emailBuffer.regarding = record.GetAttributeValue<EntityReference>("regardingobjectid").Id;
            if (record.Contains("createdon"))
                emailBuffer.createdon = record.GetAttributeValue<DateTime>("createdon");
            if (record.Contains("directioncode"))
                emailBuffer.directioncode = record.GetAttributeValue<bool>("directioncode");

        }
        query.PageInfo.PageNumber++;
        query.PageInfo.PagingCookie = results.PagingCookie;
    }        
    while (results.MoreRecords);
}
Arthur
  • 279
  • 2
  • 12
  • 1
    Did you copy & paste the code inside the second data flow from the first? Without seeing code, it's very hard to determine what's failing. – billinkc Jan 09 '15 at 18:32
  • The error means that you are trying to access the properties of an object whose value is null. At some point in your code, there is an object that is not being instantiated. – crthompson Jan 09 '15 at 18:33
  • There are bits and peices of code that I copied and pasted, but it's not the same. Basically just the connection string. I can show you the code from both scripts... edit incoming. – Arthur Jan 09 '15 at 18:33
  • @paqogomez See, that's the thing that confuses me - It should return that error regardless of if the second script is enabled, should it not? – Arthur Jan 09 '15 at 18:34
  • What is the code in `ScriptThree.CreateNewOutputRows()`? – crthompson Jan 09 '15 at 18:35
  • `organizationservice` and `results` what are their values when you go through that while? – crthompson Jan 09 '15 at 18:41
  • possible duplicate of [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – 48klocs Jan 09 '15 at 18:46

2 Answers2

0

I still don't know what the exact cause was, But i copied and pasted my script into a new script object, it suddenly started working again.

Arthur
  • 279
  • 2
  • 12
0

I suppose, you copied and pasted the whole script component and then modified code in the second one, so you had two script components with the same ComponentScriptId. That's why adding a new one fixed the issue.