atList is null, causing exceptions


I'm getting an exception when I try to run this tool. I downloaded the source code and I'm stepping through it; I can tell you where it errors, but my C# isn't good enough to propose a fix.
Steps to reproduce:
  1. Choose a server, database, and PC Dimension from the UI.
  2. Click Change Settings.

3. Two null reference exceptions, See first exception below.

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
   at PCDimNaturalizer.frmASFlattenerOptions.lbAttributes_ItemCheck(Object sender, ItemCheckEventArgs e)
   at System.Windows.Forms.CheckedListBox.OnItemCheck(ItemCheckEventArgs ice)
   at System.Windows.Forms.CheckedListBox.SetItemCheckState(Int32 index, CheckState value)
   at System.Windows.Forms.CheckedListBox.SetItemChecked(Int32 index, Boolean value)
   at PCDimNaturalizer.frmASFlattener.btnOptions_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at PCDimNaturalizer.Program.Main(String[] args)
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()


  1. If I swallow the exceptions, I can get into the Options dialog, where it appears to correctly identify my hierarchies and attributes. I set it to "Create SQL View" and hit ok. Then I click the Naturalize button.
  2. It fails shortly after this method in PCDimNaturalizer.cs, line 369: public static List<DimensionAttribute> GetAttrRelOwnerChainToKey(DimensionAttribute Attr)
    I guess because this method is returning null for atList.
    Attr.Name is: Web Id - Domain Ind
    ((Microsoft.AnalysisServices.ModelComponentCollection)(atRelOwner.AttributeRelationships)).values are:
    ["web id - level id"]: {Level Id}
    ["web id - domain ind"]: {Domain Ind}
    ["web hierarchy"]: {Web Hierarchy}
    ["web id - parent id"]: {Parent Id}
    ["web id - small site flag"]: {Small Site Flag}
    ["web id - has children"]: {Web Id - Has Children}

6. Finally, here is the last exception that kills it:

System.NullReferenceException was caught
Message="Object reference not set to an instance of an object."
   at PCDimNaturalizer.ASPCDimNaturalizer.EnsureAllIncludedPCAttributesRelateToKey() in C:\Documents and Settings\ddaniel\Desktop\PCDimNaturalizer v2\PCDimNaturalizer\PCDimNaturalizer.cs:line 973

at PCDimNaturalizer.ASPCDimNaturalizer.Naturalize(Object MinLevels) in C:\Documents and Settings\ddaniel\Desktop\PCDimNaturalizer v2\PCDimNaturalizer\PCDimNaturalizer.cs:line 1013

I can't wait to get this tool working; it looks promising.


ddaniel wrote Jun 11, 2009 at 9:58 PM

I solved the initial problem. This tool requires that the name and ID of attribute relationships are the same.
However, I also ran into the problem mentioned by gedgafov... This tool incorrectly identifies table names as dbo_tablename instead of dbo.tablename.
Hack your way through that problem, and the next issue is a bunch of runtime errors and mangled SQL generation in CreateNaturalizedView().
Add to that the sparseness of comments in the code, so you can't fix it yourself very easily.

Very disappointing. The idea of this tool is great, but it looks like I'm going to have to create my own naturalizer because this one is very very broken.

wrote Feb 13, 2013 at 11:17 PM