keif888 / SQLServerMetadata

SQL Server Metadata Toolkit
Microsoft Public License
82 stars 32 forks source link

localIColumn.CustomPropertyCollection["JoinToReferenceColumn"].Value is null #13

Closed fmms closed 6 years ago

fmms commented 6 years ago

Hi Keith,

I mentioned an Exception in #4 i was now able to narrow it down. However I am not sure what a "correct" fix is:

Processing Project package 'STG_TL_xxx'... Error enumerating packages on SQL Server 'x.x.x.x': Cannot perform runtime binding on a null reference
Strack Trace :   at CallSite.Target(Closure , CallSite , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at CallSite.Target(Closure , CallSite , Object )
   at Microsoft.Samples.DependencyAnalyzer.SSISEnumerator.EnumerateDataFlowComponent(Int32& packageRepositoryID, Package package, TaskHost taskHost, String packageLocation, Int32& dataFlowRepositoryObjectID, Dictionary`2& componentIDToSourceRepositoryObjectMap, Dictionary`2& componentIDToRepositoryObjectMap, IDTSComponentMetaData100 component)
   at Microsoft.Samples.DependencyAnalyzer.SSISEnumerator.InspectDataFlow(IDTSPipeline100 pipeline, Int32 packageRepositoryID, Package package, TaskHost taskHost, String packageLocation)
   at Microsoft.Samples.DependencyAnalyzer.SSISEnumerator.EnumerateTask(Package package, String location, Int32 packageRepositoryID, DtsContainer dtsContainer)
   at Microsoft.Samples.DependencyAnalyzer.SSISEnumerator.EnumerateTask(Package package, String location, Int32 packageRepositoryID, DtsContainer dtsContainer)
   at Microsoft.Samples.DependencyAnalyzer.SSISEnumerator.EnumeratePackage(Package package, String location)
   at Microsoft.Samples.DependencyAnalyzer.SSISEnumerator.EnumerateProjectPackages(ProjectInfo project, DirectoryInfo tempDirectory, String server)
   at Microsoft.Samples.DependencyAnalyzer.SSISEnumerator.EnumerateSqlPackages(String server, String user, String pwd, String[] rootFolders, Boolean storeThreePartNames, String[] storePackagePasswords)

After adding a lot of debugging information, i could find the error in the expression

repository.AddAttribute(componentRepositoryID, localInput.Name + " [" + localIColumn.Name + "] [ID: " + localIColumn.ID.ToString() + "]", "From [" + localIColumn.UpstreamComponentName + "] " + FormatColumnDescription(localIColumn.Name, localIColumn.DataType, localIColumn.Length, localIColumn.Precision, localIColumn.Scale) + " Reference Column [" + localIColumn.CustomPropertyCollection["JoinToReferenceColumn"].Value.ToString() + "]");

https://github.com/keif888/SQLServerMetadata/blob/master/DependencyAnalyzer2008/SsisEnumerator.cs#L1141

The problem is that localIColumn.CustomPropertyCollection["JoinToReferenceColumn"] is null.

Changing this to localIColumn.CustomPropertyCollection["JoinToReferenceColumn"].Value != null ? localIColumn.CustomPropertyCollection["JoinToReferenceColumn"].Value.ToString() : "null"

Makes the reading of SSIS packages work for me.

Thanks

keif888 commented 6 years ago

Fixed in code base.

keif888 commented 6 years ago

Fix deployed in V0.22.0.0 release.

nimearo commented 6 years ago

I still receive some Null Pointers for lookup components when CustomerPropertyCount == 2 in some packages. I'll try to find more information for debugging next week