question

Aviskumar-1057 avatar image
0 Votes"
Aviskumar-1057 asked Aviskumar-1057 commented

Script entry point invalid


Hello, In ssis script task getting error like Error: Cannot execute script because the script entry point is invalid.
script below: please suggest

using System;
using System.Net;
using System.IO;
using System.Data;
using Microsoft.SqlServer.Dts;
using Microsoft.SqlServer.Dts.Runtime;
namespace DemoApplication
{

 [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntr‌​yPointAttribute]

    
 public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectM‌​odelBase
 {

     public class Program
     {
         public static void Main()
         {
             string url = "SiteURL";
             string savePath = @"c:\test.txt";
             WebClient client = new WebClient();
             client.DownloadFile(url, savePath);
             Console.ReadLine();
         }
     }
 }

}

sql-server-integration-services
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Aviskumar-1057,

  • You can safely ignore try/catch suggestion. Your code is not even compiling.

  • Did you have a chance to try suggestions from my answer?


0 Votes 0 ·
YitzhakKhabinsky-0887 avatar image
0 Votes"
YitzhakKhabinsky-0887 answered YitzhakKhabinsky-0887 edited

@Aviskumar-1057,

(1) Are you able to successfully build the script in VS?

Please follow the following process after you finished modifying any SSIS Script Task:

  1. Go to the Build menu, and select 2nd option from the top Build ST_<GUID> (Ctrl+B).

  2. Observe that build is successful in the VS Output pane. Along the following lines:
    Build started: Project: ST_6ed65bbae4654154b980936109095fa4
    Build succeeded

  3. Select File => Exit

This process will make sure that the Script Task was compiled successfully and it is ready to be executed, deployed, etc.

(2) Also, I see that your code is using a namespace that is different from the default namespace:
namespace DemoApplication

Usually, it is namespace ST_<GUID>
I would suggect to keep it as-is.
Just create a new Script Task as keep its default naming as-is. And copy all code from the not working Script Task.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Monalv-msft avatar image
0 Votes"
Monalv-msft answered Aviskumar-1057 commented

Hi @Aviskumar-1057 ,

Please use the try {} catch {} method below in the Script Task to get detailed error messages.

 public void Main()
         {
             string url = "SiteURL";
             string savePath = @"c:\test.txt";
    
             try
             {
                 WebClient client = new WebClient();
                 client.DownloadFile(url, savePath);
                 Console.ReadLine();
                 Dts.TaskResult = (int)ScriptResults.Success;
             }
             catch (Exception ex)
             {
                 Dts.Events.FireError(0, "ERROR", ex.Message, null, 0);
                 Dts.TaskResult = (int)ScriptResults.Failure;
             }
         }

We can refer to the following picture and links:
91974-scripttaskerrormessage.png
Coding and Debugging the Script Task
Script Task Debugging in SQL Server Integration Services (SSIS)

Best regards,
Mona



If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I tried to add but it throughing Build error. Please help92118-28-apr-21-6-41-47-pm.jpg


0 Votes 0 ·

Hi @Aviskumar-1057 ,

Please check if you set the namespaces correctly.

 #region Namespaces
 using System;
 using System.Data;
 using Microsoft.SqlServer.Dts.Runtime;
 using System.Windows.Forms;
 using System.Net;
 #endregion

92463-scripttask.png

Best regards,
Mona


0 Votes 0 ·
scripttask.png (35.8 KiB)

Hi Monalv-msft
Thank you for Reply. I have tired it the existing build error gone ,But again showing some new build error.

Request you to help.
93893-05-may-21-1-53-32-pm.jpg


0 Votes 0 ·