Hi,
I've developed a module comprising of a couple of controls (e.g. one of type View, another of type Edit etc.). The view control comprises of a menu system and a placeholder. At runtime depending on which menu item is selected I dynamically load a user control (using the LoadControl method) into the placeholder - essentially providing me with mutiple interfaces. Anway I wish to use DotNetNuke's exception class to handle errors in the dynamically loaded parts of my module, however if I call ProcessModuleLoadException(me, exc) as I've seen it used, from within the click event of a button for example, I always get the following error displayed:
A critical error has occurred.
Object reference not set to an instance of an object.
This occurs no matter what the actual error is (e.g. either a simple division by zero error will produce the same result as a data access error). It seems that something in the error handling chain is falling over - or I'm passing in the wrong arguments. Through trial and error I've found that if I use ProcessModuleLoadException(me.Parent, exc) instead - it seems to work, i.e. I'll get the actual error presented on the page or if I use ProcessModuleLoadException("Custom message" me.Parent, exc, True) I can provide a custom message. Please could someone explain why I have to do this (i.e. use me.Parent instead of simply me)? In the ProcessModuleLoadException declaration the first argument (i.e. the me part) is declared as Entities.Modules.PortalModuleBase. My module and the user controls I load dynamically all inherit from this class.
Thanks,
Norm