I am trying to create a script component as transform programmatically (not manually going inside script component) but i am unable to update main.cs file, i am getting below error.
Am i missing something, Any help would be appreciated.
FYI if i set second parameter in CreateNewProject to true i.e. "host.CreateNewProject(Guid.NewGuid().ToString("N"), true, true)", i am able to generate script component correctly but my changes done using PutSourceCode is not working.
Code:
IDTSComponentMetaData100 _ScriptComponent = pipeline.ComponentMetaDataCollection.New(); _ScriptComponent.ComponentClassID = typeof(Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost).AssemblyQualifiedName; // Get the design time instance of the derived column var DesignScriptComponent = _ScriptComponent.Instantiate(); DesignScriptComponent.ProvideComponentProperties(); //design time //VSTAScriptingEngine // Create a Precedence Constraint between derived column and OLEDB Destination Components var path = pipeline.PathCollection.New(); path.AttachPathAndPropagateNotifications(pipeline.ComponentMetaDataCollection[Prev_Transform.Transformation_Name].OutputCollection[Prev_Transform.Output_Number], _ScriptComponent.InputCollection[0]); // Get the list of available columns var ScriptComponentInput = _ScriptComponent.InputCollection[0]; var ScriptComponentvInput = ScriptComponentInput.GetVirtualInput(); var ScriptComponentVirtualInputColumns = ScriptComponentvInput.VirtualInputColumnCollection; string scriptValue = @"using System; using System.Data; using Microsoft.SqlServer.Dts.Pipeline.Wrapper; using Microsoft.SqlServer.Dts.Runtime.Wrapper; [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute] public class ScriptMain : UserComponent { public override void PreExecute() { base.PreExecute(); } public override void PostExecute() { base.PostExecute(); } public override void Input0_ProcessInputRow(Input0Buffer Row) { //sam generated this } }"; // //DesignScriptComponent.SetComponentProperty("ScriptLanguage","Microsoft Visual C# 2017" ); //DesignScriptComponent.SetComponentProperty("VSTAProjectName","CustomTransform1.csproj"); ScriptComponentHost host = (DesignScriptComponent as IDTSManagedComponent100).InnerObject as ScriptComponentHost; host.CreateNewProject(Guid.NewGuid().ToString("N"), false, true); host.PutSourceCode("main.cs", "UTF8", scriptValue); host.SaveScriptProject(); //string[] sourcecode_array= _ScriptComponent.CustomPropertyCollection["SourceCode"].Value; //// when counted manually array 9 had main.cs //sourcecode_array[9] = scriptValue; //DesignScriptComponent.SetComponentProperty("SourceCode", sourcecode_array);
Error
Validation error. Data Flow Task: Data Flow Task: Microsoft.SqlServer.Dts.Pipeline.CannotCreateUserComponentException: Cannot create user component class. Make sure there is one class marked with SSISScriptComponentEntryPointAttribute
in your script.
at Microsoft.SqlServer.Dts.Pipeline.VSTAComponentScriptingEngine.CreateScriptObjectHelper(Assembly scriptAssembly)
at Microsoft.SqlServer.Dts.Pipeline.VSTAComponentScriptingEngine.GetScriptEntryPoint(String versionGuid)
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.CreateUserScriptInstance()
Sam