Hi @André Ferraz Ramos ,
Obviously, the .Net Framework version shall be the same as defined for a Script Task in Visual Studio on dev. machine.
Though the following three lines (##19-21 in the original code) are questionable:
SearchResult result = search.FindOne();
DirectoryEntry user = result.GetDirectoryEntry();
Dts.Variables["User::vEmail"].Value = user.Properties["mail"].Value.ToString();
You need to make sure that the search is successful and the returned user variable is not null.
Don't believe your eyes. It is a bug in VS, it doesn't remember what .Net Framework a Script Task was compiled with. And it sets that dropdown value to its default depending on the SSIS version.
You can check the .Net Framework directly by lookin inside the *.dtsx file.
It is a textual file in XML format just with the dtsx extension
You need to look for the following tag:
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
My other project/package shows the following (the default .Net was 4.7 originally):
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
That value shows a real .Net Framework version you manually selected.