Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Designing packages by code using parallelism

$
0
0

I have create a package generator for out company by which we would like to generate packages dynamically. Generator is based on Microsoft.SQLServer.ManagedDTS

All was fine until I have started to call my generator from parallelly from threads which were totally separated.

Example:

using System;
using Microsoft.SqlServer.Dts.Runtime;

public class Program
{
    static void Main()
    {
        //for(int i = 0; i<1000; i++)
        //{
        //    packageGenerator.CreatePackage();
        //    Console.WriteLine("package #{0} was built",i);
        //}

        System.Threading.Tasks.Parallel.For(0, 1000, i =>
        {
            var packageGenerator = new PackageGenerator();
            packageGenerator.CreatePackage();
            Console.WriteLine("package #{0} was built", i);
        }
        );
    }
}

class PackageGenerator
{
    public void CreatePackage()
    {
        var package = new Package();

        var connectionManager = CreateConnectionManager(package);
    }

    private ConnectionManager CreateConnectionManager(Package package)
    {
        const string name = "AnyName";

        
        if (package.Connections.Contains(name))
            return package.Connections[name];

        var cm = package.Connections.Add("ADO.NET:SQL");
        cm.ConnectionString = "Data Source=localhost;User ID=myAccout;Initial Catalog=myDb;Application Name=Empty;";
        cm.Name = name;

        return null;
    }
}


Since that time I'm ramdomly getting One of those exceptions:

  • An unhandled exception of type 'System.StackOverflowException' occurred in Microsoft.SQLServer.ManagedDTS.dll
  • Creating an instance of the COM component with CLSID {17BCA6E8-A95D-497E-B2F9-AF6AA475916F} from the IClassFactory failed due to the following error: c0010009.
  • The connection type "ADO.NET:SQL" specified for connection manager "{732F7B58-06C5-4443-B894-5DF4C2E42CFC}" is not recognized as a valid connection manager type. This error is returned when an attempt is made to create a connection manager for an unknown connection type. Check the spelling in the connection type name.

Any idea what s wrong?


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>