0

I have two Script Components. Fist create list and save it to the Variables.customClasslist (System.Object). When I try read this variable in the second Script Component, SSIS give me an error.

List<CustomClass> CustomClassList = (List<CustomClass>)this.Variables.CustomClassList;

ERROR:

[A]System.Collections.Generic.List1[CustomClass] cannot be cast to [B]System.Collections.Generic.List`1[CustomClass].

Type A originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.

Type B originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.

Probably adding my customClass to ScriptComponent is the source of the problem:

        public class ScriptMain : UserComponent
    {
    
        public override void PreExecute()
        {
            ...
        }
    
        public override void PostExecute()
        {
           ...
        }
    
        public override void CreateNewOutputRows()
        {
         List<CustomClass> CustomClassList = (List<CustomClass>)this.Variables.CustomClassList;
        }
    ...
    public class CustomClass
      { 
       some variables {get; set} 
       ect.
       ...
      }
 }

How can I do it properly?

Community
  • 1
  • 1
  • I believe the issue is that you are declaring the same class in two different script tasks so even though they are identical in code, they are generating different objects so the deserialization in the second doesn't work. I don't recall the easy resolution. The heavy resolution is to sign the assembly with a strong key name and deploy to the gac so all tasks have access to the same assembly. – billinkc Apr 07 '16 at 15:03
  • Heavy resolution its to heavy for me :) My CustomClass contains two string variables and one int (myInt.ToString()). So, the simples way to resolve my problem is create List and add all variables to it. In the second script component I will read my variables using loop and modulo operation. What do you think about this solution? –  Apr 08 '16 at 07:45

0 Answers0