Resource Manager is null

  1. #1

    Resource Manager is null

    Hello,
    I am building the control tree in code behind and it has not been added to a form or view yet. When i add a control to a container as shown below
                            Ext.Net.AbstractContainer oContainer
                                = ( Ext.Net.AbstractContainer ) parent;
    
                            Ext.Net.AbstractComponent oChild
                                = ( Ext.Net.AbstractComponent ) 
    
                            oControl;oContainer.Items.Add ( oChild );
    I receive an
    Object reference not set to an instance of an object.
    error message and the stack trace looks like it getting a property value from the ResourceManager. The stack trace is as follows

    at Ext.Net.MVC.MvcResourceManager.get_IsMVC()
    at Ext.Net.BaseControl.get_IsMVC()
    at Ext.Net.BaseControl.get_SafeResourceManager()
    at Ext.Net.BaseControl.get_IsPageSelfRender()
    at Ext.Net.BaseControl.EnsureDynamicID()
    at Ext.Net.BaseControl.get_ClientID()
    at Ext.Net.RadioGroup.AfterItemAdd(Observable item)
    at Ext.Net.ItemsCollection`1.Add(T item)
    I do not have a ResourceManager since i am loading control dynamically in code behind. Is there anything i can do to avoid this error? Thanks.
    Last edited by edip; Sep 09, 2019 at 5:59 PM. Reason: More information
  2. #2
    I found the solution...i was running under unit testing and i had no HttpContext.Current. So, I added a fake Context to the unit tests based on https://stackoverflow.com/questions/...in-a-unit-test and the error went away. The code is shown below..

            [nsMsTest.TestInitialize]
            public void TestInit ( )
            {
                if ( nsMyRoot.Configuration.IsWebApplication )
                {
                    System.Web.Hosting.SimpleWorkerRequest oRequest
                        = new System.Web.Hosting.SimpleWorkerRequest
                            ( ""
                                , ""
                                    , ""
                                        , null
                                            , new System.IO.StringWriter ( ) );
    
                    System.Web.HttpContext oContext
                        = new System.Web.HttpContext
                            ( oRequest );
    
                    System.Web.HttpContext.Current
                        = oContext;
    
                    var oSessionContainer
                        = new System.Web.SessionState.HttpSessionStateContainer
                            ( "id"
                                , new System.Web.SessionState.SessionStateItemCollection ( )
                                    , new System.Web.HttpStaticObjectsCollection ( )
                                        , 10
                                            , true
                                                , System.Web.HttpCookieMode.AutoDetect
                                                    , System.Web.SessionState.SessionStateMode.InProc
                                                        , false );
    
                    System.Web.SessionState.SessionStateUtility.AddHttpSessionStateToContext
                        ( oContext , oSessionContainer );
                }
            }

Similar Threads

  1. [CLOSED] [#511] Resource manager addscript in IE
    By iansriley in forum 2.x Premium Help
    Replies: 10
    Last Post: Jun 23, 2014, 9:36 AM
  2. [CLOSED] Resource manager
    By MTSI in forum 2.x Premium Help
    Replies: 1
    Last Post: Apr 04, 2014, 3:07 PM
  3. Replies: 4
    Last Post: Aug 29, 2011, 6:46 PM
  4. Script Manager and Resource Manager Conflict
    By EugeneNiemand in forum 1.x Help
    Replies: 6
    Last Post: Jun 20, 2011, 7:34 AM
  5. Replies: 4
    Last Post: Sep 22, 2010, 7:43 AM

Posting Permissions