Cannot debug a script task - sql-server

I exported a package from the production server (.ispac) to my local computer and opened in SQL Server Data Tools 2015 since I need to make some changes in the work flow. This package also include a script task which I need to alter and debug.
I added a break-point in the code, the problem is that when I run the package from Data Tools, VS 2015 opens but the below error is show and VS 2015 closed immediately and therefore I an not able to debug the code.
I have been trying to solve this for a couple of hours and viewed various post but no success.
I already: Set Run64BitRuntime = False
If I remove all the breakpoints and run the package all tasks will succeed but the script task is not doing what it is intended for... (this is why I need to debug).
I am stuck and not able to fix the code!

This is a reference issue. The references (dll's) version on your production server are different from the installed dlls on your loxal computer.
Try removing all reference used inside the script task and adding them again.
useful links
https://mitchellpearson.com/2015/04/13/upgrading-script-tasks-in-ssis-target-of-invocation-on-script-task/
DTS Script Task Runtime Error: Exception has been thrown by the target of an invocation
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/78373e2b-b4ea-4ce2-9590-b624a284d538/runtime-error-exception-has-been-thrown-by-the-target-of-an-invocation-from-script-task?forum=sqlintegrationservices
"Runtime error Exception has been thrown by the target of an invocation" from Script task

Related

SSIS - package works in VS, fails with "Failed to compiled scripts contained in the package". There are no script objects in the package

VS2017, Deploy to SS2016. Package runs without any errors from VS. Project deployment to a server that previously had package deployments only - we're moving to project deployment, and DBAs said to use that.
Getting many errors like:
Get Error Information:Error: Failed to compiled scripts contained in the package. Open the package in SSIS Designer and resolve the compilation errors.
The package has absolutely no script objects. I've checked with the package explorer, and there isn't even a scripts section. To verify, I added an empty script, and then the explorer did show that section.
Other info: Package deployment is new to our DBAs. They are completely mystified by this, and other errors, like:
Get Error Information:Error: CS2001 - Source file 'C:\Windows\TEMP.NETFramework,Version=v4.0.AssemblyAttributes.cs' could not be found, CSC, 0, 0
My opinion, unexpert in SSIS as I am, is that these servers are not set up or configured properly in some way, but I am out of my depth in this, and DBAs are floundering. What might I do to get to the root of this?
I ended up side-stepping the issue by essentially recreating the package. Even XML search revealed no scripts, so the assumption was some kind of corruption. The package was recently upgraded to package-deployment - perhaps that action had a hand in the problem.
We had the same issue and isolated the problem to a Script Task (regardless of language) that existed in a Sequence Container. Placing the Script Task outside the Sequence Container, and upgrading the package to 2016 worked. The package was originally 2012 (as far as I can see) and the server side SSIS was 2016 13.2.5426.0. We were using VS 2017 as well.
For me this was happening because I was targeting the wrong database version. in your SSIS Package project go into properties and set the TargetServerVersion appropriately And then recompile the project and redeploy to sql server.

C# code disapeared from script task after saving with "There is a compilation error. Do you want to save anyway" message

I am using VS2015 for SSIS development. My package consists of a script task which is very complex (has a number of classes and tricky logic). I made some modification to a class (in the script task), saved the modification, and wanted to close "Microsoft Visual Studio Tools for Applications 2015" which is used for working with C# code in SSIS. I received a VS message that my code had a compilation error, and it gave me a choice of "saving" anyway\"not saving". Since I was running out of work time, I hit "Save" and thought I would deal with the issue later.
Now when I open my SSIS project->script task, I can see that all my classes have gone. There is only one auto generated "ScriptMain.cs" that can be found.
Is there a way I can restore all my work? I cannot believe all code can just disappear if you press "save file" when a compilation error.
Any help is appreciated!
There are many thread in the Visual Studio developer community talking about a software bug found in Visual Studio 2015 and 2017 and it is mentioned that is fixed in the latest releases. I don't think you can try anything more than searching the Script Task project temp directory and the package bin folder if it contains an old version of the package.
The issue was mentioned in the following links:
Developer community - SSIS Script Task losing code
Developer community - Script task losing code
MSDN - Script Tasks losing code for Visual Studio 2015
Developer community - Script Task losing code in SSDT 15.8.0
All links mentioned that you have to install the latest release in order to prevent the error from occurring next time.

SSIS Script Tasks losing code

I have a very strange issue happening that is causing Script Task code to clear out. I have been able to test on 2-3 different machines. We are running SSDT 15.4 preview. The steps to reproduce were as follows.
Create a script task inside of a foreach loop container.
Create a comment in the script task.
Change or add a variable mapping in the foreach.
Save package.
Close the package.
Open the package.
Open the script task and the comment will have vanished.
As my last attempt for success,I have upgraded to 15.5.1 and the problem still exists.
If you close/Cancel the Script Task Editor form in Visual Studio after editing code, the code will not save. This will occur even if the code was saved in the other Visual Studio editor - the one where you edit the code.
You MUST click "OK" for the code to save.
If there is some error in the script it is not saved. Check your script for errors in the menu Build / Run Code Analysis on Solution or pressing Alt+F11
I had something similar. All code was being stripped when I imported the packages into SQL Server. For us it turned out SSMS was silently stripping code with an incompatible DTS version. SSMS v18 was removing scripts built with DTSv14. Once I opened them in a new version of Visual Studio, moved one "block" 1px over, then saved, it changed the package to DTSv15, which then imported fine using SSMS v18.
Just to verify, I tried using SSMS v17 with the DTSv14 package, and the Script Tasks were left alone and imported fine. But for other reasons we need to be using SSMS v18.

Visual Studio 2017 SSIS Error (0xc001f041)

No matter which SQL Server version I use I get the following error when I try to drag common tasks (like Send Mail) into the Package:
Failed to create the task.
Cannot create a task from XML for task "", type "" due to error
0xC001F041 "Cannot create a task from XML. This occurs when the
runtime is unable to resolve the name to create a task. Verify that
the name is correct.". (Sequence Container)"
I have no clue as to why that is happening and couldn't find any information on the internet either.
The strange thing is that I can drag the same tasks into the package when I use solutions that we've developed based on Sql Server 2008 R2 years ago. Restarting the machine didn't help. I could try to repair the Visual Studio installation, but I don't really want to lose all of my settings, extensions and such.
Apparently it works fine for a colleague. I deleted all .tbd-files in AppData/Local/Microsoft/VisualStudio, but neither of those files gets recreated when I start Visual Studio. I also tried to restore Toolbox defaults.
Executing the following command didn't help either. The same error is still appearing whenever I try to drop about 3/4 of the tasks into the package.
devenv /ResetSettings
devenv /setup
devenv /resetskippkgs
devenv.exe /InstallVSTemplates
Apparently the only thing that actually helps is to repair VS.

SSIS package runs in Visual Studio but fails when executed from SQL Agent [duplicate]

This question already has an answer here:
Why does my ODBC connection fail when running an SSIS load in Visual Studio but not when running the same package using Execute Package Utility
(1 answer)
Closed 7 years ago.
Using SQL Server 2014 with Visual Studio 2013 Shell. Relatively new to using SSIS but have had success with creating and executing other packages.
I'm having an issue with one SSIS package in a project running without failing in the first few seconds of the job being kicked off by the SQL Server Agent. I have other packages in the same project that are scheduled and run as schedule with no issues.
The package in question runs with out any issues in Visual Studio, but when it is deployed it will not run. The package details are:
it runs an FTP task to pick up a Excel file from a remote FTP server
then runs a Execute SQL Task to truncate a table
then runs a Data Flow Task that loads the table with the data from the file that was just picked up.
Again this all works fine without errors in Visual Studio. Looking the debug logs in VS there are not even any warnings and takes a little over a minute to run.
I have rebuilt the package in a new package deployed it and it again won't run when deployed, same results. When the deployed package is run it fails right away within 4-15 seconds which is not enough time for it to download the file.
I have other packages doing similar tasks that are deployed and working just fine.
I've seen a couple of things in my searching for a solution but don't think they apply here:
There is only one user (me) and I have a proxy setup for SSIS Package Execution which is the same for all the packages. So I don't think it is a security issue.
The Access Database Engine 2010 (redistributable) installed, ACE I believe I seen it referred to. So I don't think it is an issue with drivers.
Anyone able help guide me in where I should be looking or what the issue might be? Any additional information needed? Much appreciated.
EDIT: Additional information from the log file for this job:
-1071611876 (Data Code)
SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0209303. There may be error messages posted before this with more information on why the AcquireConnection method call failed.
Data flow engine has finished a call to a component method. : 122 : Excel Source : AcquireConnections : 130832947393433501 : 130832947395273663
-1073450985 (datacode)
Excel Source failed validation and returned error code 0xC020801C.
One or more component failed validation.
There were errors during task validation.
So it was the 32-bit run time box needing to be checked in the SSA Job Step Properties Advanced tab. I think I might have saw that some place but figured it wouldn't apply since SQL Server, Office/Excel and ACE are all 64-bit in my system. But I guess Microsoft hasn't gotten around to making all the drivers 64-bit. Thanks for the help.

Resources