Answered by:
Getting ScriptTask source code in SSIS 2008
-
I used to get the source code of my script tasks using the code below in SSIS 2005.
Now there is no ScriptTaskCodeProvider class in SSIS 2008.
Does anyone know how to get the source code using 2008?
ScriptTaskCodeProvider codeProvider = new ScriptTaskCodeProvider();
codeProvider.LoadFromTask(scriptTask);
sourceCode = codeProvider.GetSourceCode(
String.Format("dts://Scripts/{0}/ScriptMain.vsaitem", scriptTask.VsaProjectName));
thank
jimmy
Question
Answers
-
Hi Jimmy,
Yes it is possible. There is a property on the script task, which is not browsable (but its there) named ScriptStorage. It is of type: Microsoft.SqlServer.VSTAHosting.VSTAScriptProjectStorage. The property you have to access is ScriptFiles (Hashtable). You have to determine what key you should use to access the required script, but I think you will make it out from there.
Let us know how it goes.
All replies
-
-
Hi Jimmy,
Yes it is possible. There is a property on the script task, which is not browsable (but its there) named ScriptStorage. It is of type: Microsoft.SqlServer.VSTAHosting.VSTAScriptProjectStorage. The property you have to access is ScriptFiles (Hashtable). You have to determine what key you should use to access the required script, but I think you will make it out from there.
Let us know how it goes. -
Hi,
I was trying to utilize the ScriptStorage in the script task / script component to get the source XML in order to traverse it for Lineage Ids. Problem is I keep getting "Name 'ScriptStorage' is not declared.".
Dim Storage As Microsoft.SqlServer.VSTAHosting.VSTAScriptProjectStorage = ScriptStorageCan you please post an example of how I access ScriptStorage? I am sure the above is incorrect.
Thank you,
Ron -
Can you post the complete script you are testing? Have you tried MyBase.ScriptStorage or Me.ScriptStorage ?Hi,
I was trying to utilize the ScriptStorage in the script task / script component to get the source XML in order to traverse it for Lineage Ids. Problem is I keep getting "Name 'ScriptStorage' is not declared.".
Dim Storage As Microsoft.SqlServer.VSTAHosting.VSTAScriptProjectStorage = ScriptStorageCan you please post an example of how I access ScriptStorage? I am sure the above is incorrect.
Thank you,
Ron
SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

-
Thank you for your response.
I have tried 3 methods
Dim ps As Microsoft.SqlServer.VSTAHosting.VSTAScriptProjectStorage = MyBase.ScriptStorage
Dim ps2 As Microsoft.SqlServer.VSTAHosting.VSTAScriptProjectStorage = Me.ScriptStorage
Dim ps3 As Microsoft.SqlServer.VSTAHosting.VSTAScriptProjectStorage = ScriptStorageAll 3 variations give a "is not a member" error
Do you have a sample of how it should work? either c# or vb is fine.
thank you,
Ron
Thank you, Ron -
Ron,
My mistake for not checking what you are trying to solve. The answer is still valid when the script creation is done from outside SSIS. This code will not work from inside the Script Task / Component. The script is contained in the so called host object and this is very different from the object , which controls the host. I don't think you can access the script from inside the script.
Btw the Script Task and Script Component implementations are very different animals.
If you want to traverse lineage ids from inside SSIS you will need third-party solution like CozyRoc Package Connection Manager. It provides access to the Package object.
SSIS Tasks Components Scripts Services | http://www.cozyroc.com/
