so I ran my SSIS Job on my local machine with no errors and deployed it to SQL Agent 2019 and I’m using Visual Studio 2019 and the TargetVersion is set to SQL Server 2019 and I’m getting the followings errors:
- Get Tables for Report:Error: There were errors during task
validation. - Get Tables for Report:Error: The binary code for the
script is not found. Please open the script in the designer by
clicking Edit Script button and make sure it builds successfully. - Script Task 4:Error: The binary code for the script is not found.
Please open the script in the designer by clicking Edit Script button
and make sure it builds successfully. - Script Task 4:Error: CS1504 –
Source file
‘c:WindowsTemp.NETFramework,Version=v4.7.AssemblyAttributes.cs’
could not be opened (‘Access is denied. ‘), CSC, 0, 0 - Script Task 4:Error: Failed to compiled scripts contained in the package. Open
the package in SSIS Designer and resolve the compilation errors.
I thought it was a permissions issues so I asked one of our DBA’s to run it and he is getting the same errors.
I already deleted and redid the script tasks and build each one and saved
Here’s the script Get Tables for Report:
#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Text;
#endregion
namespace ST_70ab92c155744d1396f11009d032d49f
{
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
Variables vars = null;
OleDbConnection conn = null;
string password = string.Empty;
try
{
Dts.VariableDispenser.LockForRead("$Package::SqlDatabasePW");
Dts.VariableDispenser.LockForWrite("User::sqlstatement1");
Dts.VariableDispenser.LockForWrite("User::sqlstatement2");
Dts.VariableDispenser.LockForWrite("User::sqlstatement3");
Dts.VariableDispenser.LockForWrite("User::sqlstatement4");
Dts.VariableDispenser.GetVariables(ref vars);
password = vars["$Package::SqlDatabasePW"].GetSensitiveValue().ToString();
ConnectionManager cm = Dts.Connections["LCGMS Connection Manager"];
string originalConnectionString = cm.ConnectionString;
string passwordToAdd = "Password=" + password + ";";
string connString = originalConnectionString + passwordToAdd;
conn = new OleDbConnection(connString);
conn.Open();
string[] sqlStatements = new string[]
{
"SELECT count(*) as Count FROM Supertable_Storage_Staging WHERE(PDB1_Upload = 'N');",
"SELECT Fiscal_Year + '-' + Location_Code + '-' + CONVERT(varchar(04), Count(*)) FROM Supertable_Storage_Staging WHERE(PDB1_Upload = 'N') AND (Update_Flag='I') GROUP BY Fiscal_Year + '-' + Location_Code + '-' ORDER BY Fiscal_Year + '-' + Location_Code + '-';",
"SELECT Fiscal_Year + '-' + Location_Code + '-' + CONVERT(varchar(04), Count(*)) FROM Supertable_Storage_Staging WHERE(PDB1_Upload = 'N') AND (Update_Flag='U') GROUP BY Fiscal_Year + '-' + Location_Code + '-' ORDER BY Fiscal_Year + '-' + Location_Code + '-';",
"SELECT Fiscal_Year + '-' + Location_Code + '-' + CONVERT(varchar(04), Count(*)) FROM Supertable_Storage_Staging WHERE(PDB1_Upload = 'O') AND (Update_Flag='D') GROUP BY Fiscal_Year + '-' + Location_Code + '-' ORDER BY Fiscal_Year + '-' + Location_Code + '-';"
};
for (int i = 0; i < sqlStatements.Length; i++)
{
using (OleDbCommand cmd = new OleDbCommand(sqlStatements[i], conn))
{
using (OleDbDataReader reader = cmd.ExecuteReader())
{
StringBuilder resultBuilder = new StringBuilder();
while (reader.Read())
{
string count = reader[0].ToString();
resultBuilder.AppendLine(count);
}
string varKey = "User::sqlstatement" + (i + 1).ToString();
vars[varKey].Value = resultBuilder.ToString();
}
}
}
Dts.TaskResult = (int)ScriptResults.Success;
vars.Unlock();
}
catch (Exception ex)
{
Dts.Events.FireError(0, "Script Task Error", ex.Message + "n" + ex.StackTrace, String.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
finally
{
if (conn != null && conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}
}
Here’s the code for Script Task:
#region Namespaces
using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Text;
using System.Threading;
using System.Data.OleDb;
#endregion
namespace ST_143da356cdc14c98a01686eb6c63137b
{
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
int insertedRows1 = 0;
int insertedRows2 = 0;
int updatedRows1 = 0;
int updatedRows2 = 0;
int deletedRows = 0;
string ServerName = string.Empty;
string sqlstatement1 = string.Empty;
string sqlstatement2 = string.Empty;
string sqlstatement3 = string.Empty;
string sqlstatement4 = string.Empty;
try
{
insertedRows1 = (int)Dts.Variables["User::InsertedRowCount1"].Value;
insertedRows2 = (int)Dts.Variables["User::InsertedRowCount2"].Value;
updatedRows1 = (int)Dts.Variables["User::UpdatedRowCount1"].Value;
updatedRows2 = (int)Dts.Variables["User::UpdatedRowCount2"].Value;
deletedRows = (int)Dts.Variables["User::DeletedRowCount"].Value;
ServerName = (string)Dts.Variables["$Package::SqlDatabaseServer"].Value;
bool isDataFlowSuccessful = (bool)Dts.Variables["User::isDataFlowSuccessful"].Value;
String Environment = (string)Dts.Variables["$Package::Environment"].Value;
int totalInsertedRows = insertedRows1 + insertedRows2;
int totalUpdatedRows = updatedRows1 + updatedRows2;
int totalTransaction = totalInsertedRows + totalUpdatedRows + deletedRows;
sqlstatement1 = (string)Dts.Variables["User::sqlstatement1"].Value;
sqlstatement2 = (string)Dts.Variables["User::sqlstatement2"].Value;
sqlstatement3 = (string)Dts.Variables["User::sqlstatement3"].Value;
sqlstatement4 = (string)Dts.Variables["User::sqlstatement4"].Value;
if (isDataFlowSuccessful == true)
{
Dts.Variables["User::emailsubject"].Value = "LCGMS_Supertable_Update_Process_LC1P1_" + Environment + ":" + ServerName + " Success on " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Dts.Variables["User::emailbody"].Value = string.Format(
"Subject:ttSupertable Hourly Process For LC1P1 DB2 Region Successfully Updated (or Override with the failure message)n" +
"Project Name:ttLCGMS_Supertable_Update_Process_LC1P1n" +
"Purpose:ttThis Job gets the data from the Supertable_Storage_Staging SQL table and updates LC1U1.LOCATION_SUPERTBL1 DB2 table.n" +
"tttThis process Insert, Update, or Delete the rows accordingly on an hourly basis.nn" +
"Technical Description:nn" +
"SSIS Package Name:tLCGMS_Supertable_Update_Process_LC1P1n" +
"SQL Table (Input):tSupertable.dbo.Supertable_Storage_Stagingn" +
"DB2 Table (Output):tLC1U1.LOCATION_SUPERTBL1n" +
"SQL Stored Procs:tsp_populate_supertmpn" +
"SQL View:ttNonenn" +
"Schedule to run:tMultiple times per day (@ 9:00 AM, 11 AM, 2:00 PM, 6:30 PM, & 11 on Weekdays)nn" +
"Dependencies:ttIt handles logicallynn" +
"Total Transaction: {0}n" +
"Inserted: t {1}n" +
"Updated: t {2}n" +
"Deleted: t {3}nn" +
"Insert List:n{4}nn" +
"Update List:n{5}nn" +
"Delete List:n{6}nENDnn" +
"Please get in touch with the LCGMS team in case of questions or concerns.nn" +
"Thanks,nLCGMS team",
totalTransaction, totalInsertedRows, totalUpdatedRows, deletedRows, sqlstatement2, sqlstatement3, sqlstatement4);
Dts.TaskResult = (int)ScriptResults.Success;
}
}
catch (Exception ex)
{
// Handle exception
Dts.Events.FireError(0, "Script Task Error", ex.Message + "n" + ex.StackTrace, String.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}
}
What could be causing this error?
Thanks.
2
Answers
I found the Answer our DBA's updated the server to 2022, so I changed the TargetVersion to SQL Server 2022 and it worked.
Thank you everyone!
Without seeing your source code as none is present, the best we can do is guess.
My first guess is that you have a product installed on your computer that is not installed on the server.
If you’re using the nuget package manager, yeah SSIS doesn’t do that. Your script task will use it in development mode but as soon as you close the editor, the packages get nuked and you have a busted Script task/component.
The next guess will be that you have a newer framework version than is installed on the server.
Less probable is something like the package has dependencies on a 32 bit app/dll and execution on the server defaults to 64 bit.
You’ve identified that the target version of packages match the destination sql server version so shouldn’t be any hiccups on deployment. Although, there can be if the deployment tooling (likely isdeploymentwizard.exe) is SQL Sever 2022 based.
If you want a more targeted answer, edit your question to include at least one of the failing Script Tasks (4, 3, or 2) and possibly the SQL Agent definition.