[CLOSED] Object Reference not set to instance of an object

Page 2 of 2 FirstFirst 12
  1. #11
    Hello,
    I have just isolated the error that I am receiving… in the Ext.Net.ResourceManager class in the GetBeforeInitScript, the
    HttpContext.Current
    is null. I am guessing that it may be a threading issue and am trying to find out what the root cause of this is.

        public static string GetBeforeInitScript(bool clear = false)
            {
                string result = ((StringBuilder)(HttpContext.Current.Items[ResourceManager.BEFOREINITSCRIPT] ?? new StringBuilder())).ToString();
    
                if (clear)
                {
                    HttpContext.Current.Items[ResourceManager.BEFOREINITSCRIPT] = null;
                }
    
                return result;
            }
    Thanks for your help,
  2. #12
    Hello edip,

    Can you provide an updated link with the .zip package you are using to reproduce the error.

    Please keep all communication regarding this issue centralized within this forum thread. If you have updated code samples, please post here.
    Geoffrey McGill
    Founder & CEO
  3. #13
    I looked into the threading and it seems that the Ext.Net.ResourceManager.GetBeforeInitScript is running on a worker thread…as a result, it does not have direct access to HttpContext.Current. I have attached the Thread window below…

    Click image for larger version. 

Name:	ThreadWindow.png 
Views:	2 
Size:	20.4 KB 
ID:	24535
  4. #14
    Hello @edip!

    Your project does not resolve the references because it lacks the package/ directory that should be sitting somewhere two levels above the project's folder.

    I can fiddle with this and makes the references miss but still, if the project does not run at once, there might be other issues that work for you there but will break to me here (or the other way around as well!).

    I will try to set up the packages/ folder structure here and see if NuGet can restore the packages, but I am afraid more things can come up with that.

    If you try unzipping the provided project with the updated .csproj file on a different folder (far from your actual solution, maybe a c:\temp directory just to test) you'd most likely reproduce the errors I am seeing here.
    Fabrício Murta
    Developer & Support Expert
  5. #15
    Hi Fabricio,
    I am trying to build you a project without nuget and will send it to you when ready. Thanks.
  6. #16
    Hello @edip!

    Please do not publish to the open projects with license keys and sensitive information on it. I've noticed your first linked project had the license key on Global.asax.cs. The license key is not needed to run the project locally. I'll review your newly upload project and we will have to remove the link if it also contains the license key inside (or other sensitive customer information).

    Hope you understand.

    Back on the main subject, I ended up reproducing your issue after I sent last post (restored NuGet packages appropriately), and so far, all indicates there's some setting in your project breaking when a view returns (for example) this.RedirectToAction(). This worked perfectly on a clean project. I'm trimming out all I can until the error is no longer reproducible and will try the same code in a clean project.
    Fabrício Murta
    Developer & Support Expert
  7. #17
    Yes, of course I understand and I apologize...I just forgot to remove it.

    I sent you another project with no nuget packages which should work right out of the box. Yes, I imagine it may be some setting in the project and I could not reproduce it from a clean project.

    I have noticed that in the Ext.Net library, the HttpContext.Current is checked for a null value in several locations but there are some code locations where it is not validated.

    Thanks.
    Last edited by edip; Apr 05, 2016 at 6:54 PM.
  8. #18
    Hi!

    You can share them on google drive and it works well -- as long as you do not leave your personal key sitting around. So far, all I found that shouldn't be shared was keys, but I didn't thoroughly search for other things like passwords, etc.

    If you forward via email, it will be delayed considerably as we'd need Geoffrey to forward for the rest of the team manually. Our official communications channel is the forums, so let's use it to our advantage.

    ---

    I have trimmed out the logon controller down to this:
    using Ext.Net;
    using System.Web.Mvc;
    
    namespace Support.Business.Web.Ui.Mvc.Clearview.Controllers
    {
        public class LogonController : Controller
        {
            // GET: /Logon/
    
            #region Constructors
    
            public LogonController()
            {
            }
            #endregion Constructors
    
            public ActionResult Index ()
            {
                return this.View();
            }
    
            [System.Web.Mvc.HttpPost]
            public ActionResult Index(string name)
            {
                return this.RedirectToAction("Logon");
            }
        }
    }
    And still the error happens. I miss some directories that Ext.NET installs when you install NuGet packages (nuget restore does not restore files structure), so it really really feels like a broken Ext.NET installation... somewhere.

    To me, the exception shows no Ext.NET in the path (same with your original code or with the trimmed down version). I'm still trying to get rid of this part, so maybe we are not running into the same problem here?

    Click image for larger version. 

Name:	60782-01_assertionFailMessage.png 
Views:	1 
Size:	30.5 KB 
ID:	24536

    I can make a very similar controller in a clean Ext.NET project and this.RedirectToAction() works fine.
    When I just change the this.RedirectToAction lines on your code so that it returns just this.View(), the direct method returns correctly. (but that's just a rough elimination tests)
    Fabrício Murta
    Developer & Support Expert
  9. #19
    Hi Fabricio,
    I think I have found the source of the error...the "Managed Pipeline Mode" has been set to "Classic" in our application to support legacy com dll's and it looks like the new version of Mvc does not like that. If you change it to "Integrated" it should work fine.

    Thanks for all your help.
  10. #20
    Hello again Emidio!

    Glad you could figure out the problem after all!

    By my side, I've given up your project and copied the logic into a fresh, new project, and it worked fine.

    Just for reference, the clean project with your same logon logic is this: cleanProject-withLogic.zip.
    Fabrício Murta
    Developer & Support Expert
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 11
    Last Post: Aug 12, 2015, 11:30 AM
  2. Replies: 2
    Last Post: Apr 08, 2014, 12:00 AM
  3. Replies: 2
    Last Post: Jun 13, 2013, 4:58 PM
  4. Replies: 2
    Last Post: Dec 17, 2012, 4:00 AM
  5. Replies: 1
    Last Post: Jun 27, 2012, 10:19 PM

Posting Permissions