Skip to content

Commit 8d1a8f2

Browse files
committed
ManagedComponentWrapper GUID, back to hard coded. Reliable.
1 parent f3df6f7 commit 8d1a8f2

1 file changed

Lines changed: 19 additions & 35 deletions

File tree

SSIS/PackageHelper.cs

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,22 @@ internal class PackageHelper
3434
/// </summary>
3535
private static object componentLock = new object();
3636

37-
/// <summary>
38-
/// Private field for the ManagedComponentWrapper property
39-
/// </summary>
40-
private static string managedComponentWrapper;
41-
4237
/// <summary>
4338
/// All managed components in the data flow share the same wrapper, identified by this GUID.
4439
/// The specific type of managed component is identified by the UserComponentTypeName custom property of the component.
40+
/// The GUID is documented in teh class Syntax section - https://technet.microsoft.com/en-gb/library/microsoft.sqlserver.dts.pipeline.wrapper.cmanagedcomponentwrapperclass(v=sql.105).aspx
4541
/// </summary>
46-
public static string ManagedComponentWrapper
47-
{
48-
get
49-
{
50-
if (managedComponentWrapper == null)
51-
{
52-
// This value changed unexpectedly
53-
// SQL2014 - {33D831DE-5DCF-48F0-B431-4D327B9E785D}
54-
// SQL2005 - {BF01D463-7089-41EE-8F05-0A6DC17CE633}
55-
// See documentation https://technet.microsoft.com/nl-nl/library/microsoft.sqlserver.dts.pipeline.wrapper.cmanagedcomponentwrapperclass(v=sql.90).aspx
56-
57-
// To prevent future issues, we will get it from the object itself.
58-
GuidAttribute attribute = (GuidAttribute)Attribute.GetCustomAttribute(typeof(CManagedComponentWrapperClass), typeof(GuidAttribute));
59-
managedComponentWrapper = attribute.Value;
60-
}
61-
62-
return managedComponentWrapper;
63-
}
64-
}
65-
42+
#if SQL2016
43+
public const string ManagedComponentWrapper = "{4F885D04-B578-47B7-94A0-DE9C7DA25EE2}";
44+
#elif SQL2014
45+
public const string ManagedComponentWrapper = "{33D831DE-5DCF-48F0-B431-4D327B9E785D}";
46+
#elif DENALI
47+
public const string ManagedComponentWrapper = "{2E42D45B-F83C-400F-8D77-61DDE6A7DF29}"
48+
#elif KATMAI
49+
public const string ManagedComponentWrapper = "{874F7595-FB5F-40FF-96AF-FBFF8250E3EF}"
50+
#else
51+
public const string ManagedComponentWrapper = "{BF01D463-7089-41EE-8F05-0A6DC17CE633}"
52+
#endif
6653

6754
public static List<TaskHost> GetControlFlowObjects<T>(DtsContainer container)
6855
{
@@ -123,16 +110,13 @@ public static ComponentInfos ComponentInfos
123110
}
124111
else
125112
{
126-
// Script Component ID
127-
////public const string ScriptComponentID = "Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost, Microsoft.SqlServer.TxScript, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91";
128-
////if (pipelineComponentInfo.ID == ScriptComponentID)
129-
////{
130-
//// // For the script component on SQL 2014, PipelineComponentInfo shows an ID of Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost, Microsoft.SqlServer.TxScript, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
131-
//// // When enumerating components in the pipeline the ComponentClassID is the GUID, not the creation name
132-
//// // COM CLSID vs COM ProgID vs assembly strong name, they all get mixed up sometimes.
133-
//// componentInfos.Add("{33D831DE-5DCF-48F0-B431-4D327B9E785D}", new ComponentInfo(pipelineComponentInfo));
134-
////}
135-
componentInfos.Add(pipelineComponentInfo.ID, new ComponentInfo(pipelineComponentInfo));
113+
componentInfos.Add(pipelineComponentInfo.CreationName, new ComponentInfo(pipelineComponentInfo));
114+
115+
// Add both the creation name and the component GUID to ensure we get a match
116+
if (pipelineComponentInfo.CreationName != pipelineComponentInfo.ID)
117+
{
118+
componentInfos.Add(pipelineComponentInfo.ID, new ComponentInfo(pipelineComponentInfo));
119+
}
136120
}
137121
}
138122
}

0 commit comments

Comments
 (0)