SSIS packages programmatically with c# exception

Zion zipris 21 Reputation points
2022-03-09T20:11:41.71+00:00

Hi,

I get an error calling the method: Badinstance.ReinitializeMetaData();, What could be the reason?
I want to point out that this is only in the SQL 2019 version.

                // Add Flat File error component  
                IDTSComponentMetaData100 BadCM = BaddataFlowTask.ComponentMetaDataCollection.New();  
                BadCM.ValidateExternalMetadata = false;  
                
                BadCM.Name = "BadError";  
                BadCM.ComponentClassID = "Microsoft.FlatFileSource";  
                CManagedComponentWrapper Badinstance = BadCM.Instantiate();  
                Badinstance.ProvideComponentProperties();  
                if (BadCM.RuntimeConnectionCollection.Count > 0)  
                {  
                    BadCM.RuntimeConnectionCollection[0].ConnectionManagerID = connectionManagerErrorFlatFile.ID;  
                    BadCM.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.GetExtendedInterface(connectionManagerErrorFlatFile);  
                }  
                Badinstance.AcquireConnections(null);  
                try  
                {  
                    Badinstance.ReinitializeMetaData(); // HERE  
                }  
                catch (Exception ex)  
                {  
  
                }  
                Badinstance.ReleaseConnections();  
  

181643-pic.png

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,587 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.
10,995 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 54,566 Reputation points
    2022-03-09T20:40:39.473+00:00

    Looking up the SSIS error here indicates that it is trying to load something that requires a code page but no such value is given.

    Looking at the method you're calling it appears to be only used when validation fails because metadata is invalid. It also appears that it should be called automatically and not something you should be calling yourself. Finally, based upon what the metadata it seems like it is really only for design time support as validation runs at design time, but I'm not completely sure. Is there a reason you need to call this method?


0 additional answers

Sort by: Most helpful

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.