SSIS - C# Script Runs Locally, but Fails on Server

William Zorn 5 Reputation points
2023-03-16T16:38:33.5866667+00:00

I have an SSIS package that calls a C# script to connect to SharePoint and preform some operations. The SSIS package runs fine locally, but fails after it is deployed to the server. I'm positive this is not a permissions issue. I had to add quite a few references to get the authentication to work. At this point, I've imported nearly all of the .ddl files into the GAC on the server and my references are pointing at those DLLs. I THINK the failure is because there are still references that I need to copy over to the server and install in the GAC.

What I need is a way to see more debugging information from the run on the server. Looking at the information returned in the standard reports just doesn't give enough.

What else can I look at, or how can I trap the error and return more information. I'm assuming there isn't a way to connect a debug session to the server run. Any help would be greatly appreciated.


EDIT: I may have answered the first part of this question myself. I was using a try/catch in my script. Removing this allowed me to see the errors.

Now, I can see the error:

Error: Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot file the file specified.

The part I'm not understanding is that I specifically point my reference to GACMSIL\System.Buffers\v4.04.0.3.0_cc7b13ffcd2ddd51. This is the same reference I'm using locally, but when deployed to the server it seems to want to look for a different version. Does that make sense?

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,664 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,339 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. William Zorn 5 Reputation points
    2023-03-20T15:54:47.97+00:00

    I was able to determine that either system.text.json or one of it's dependencies was referencing a version of system.buffers that does not exist.

    The common and most accepted fix (from searching online) is to use bindingRedirect to map system.buffers to a version that does exist.

    Example:

    <dependentAssembly>
    				<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    				<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
    			</dependentAssembly>
    

    I attempted to add this to the app.config file, but it doesn't look like SSIS scripts use that file. I also tried adding redirects to the DTExec.exe.config file on the server and that didn't help either.

    Ultimately, the fix was to abandon use of system.text.json and use newtonsoft.json instead. This required some rework of my code, but ultimately solved the problem since newtonsoft.json does not have the dependency on system.buffers.

    1 person found this answer helpful.
    0 comments No comments

  2. Yitzhak Khabinsky 26,471 Reputation points
    2023-03-16T18:31:02.2866667+00:00

    Hi @William Zorn,

    You also need to make sure that the SSIS run-time server has the same version of the .Net Framework installed which is used by the SSIS Script Task.

    Also, you can restore try/catch block in your code with logging:

    try {
    		...
    }
    catch (Exception ex)
    {
      // Don't forget to tick/check off System::TaskName variable as ReadOnly in the Task Parameters
      Dts.Events.FireError(18, Dts.Variables["System::TaskName"].Value.ToString()
    	   , ex.Message.ToString()
    	   , "", 0);
    }
    

  3. ZoeHui-MSFT 41,291 Reputation points
    2023-03-17T02:11:22.04+00:00

    Hi @William Zorn

    Have you checked the Target Server Version? Make sure it matches with your deployed server version.

    User's image

    Regards,

    Zoe Hui


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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.