FormulaTextBox Exception: Object reference not set to an instance of an object.

Posted by: greygranite on 8 September 2017, 1:33 pm EST

  • Posted 8 September 2017, 1:33 pm EST

    When attempting to use the Formula Textbox formula wizard by typing in "=S", an exception is raised that prevents the wizard popup from displaying.  The special circumstance of this error is that its occurring when the .net farpoint control is run in a COM enabled user control in a html browser.  I've attached a project that reproduces this error and the steps needed to reproduce.


    Thank you for your assistance,


    Ed Ostrowski



    Description:
    Project is a COM exposed user control with a FormulaTextBox linked to FpSpread spreadsheet.  Goal of this project is to show that the .Net version of Farpoint works as a wrapped COM object.  In all aspects this is successful, except for the formula textbox wizard.  Please note that all farpoint binaries will need to be added to the project.  They were left out due to upload size restrictions.


    Environment:
    .net 2008 IDE
    build as .net 2005


    Farpoint Version:
    FarPoint.Win.Spread 4.0.2001.2005


    How to reproduce:
    1. Build attached project
    2. Register the COM enabled wrapped component
    3. Browse to debug build folder
    4. Run Text_ClassId.htm
    5. Accept the running of an ActiveX component in the browser
    6. Set focus to displayed FormulaTextBox
    7. Type =s in FormulaTextBox
    8. Microsoft framework will raise the following exception:



    Exception Raised:


    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.


    ************** Exception Text **************
    System.NullReferenceException: Object reference not set to an instance of an object.
       at FarPoint.Win.Spread.FormulaTextBox.b(Int32 A_0, Int32 A_1, Boolean A_2)
       at FarPoint.Win.Spread.FormulaTextBox.f()
       at FarPoint.Win.Spread.FormulaTextBox.a(String A_0, Boolean A_1)
       at FarPoint.Win.Spread.FormulaTextBox.a(Boolean A_0)
       at FarPoint.Win.Spread.FormulaTextBox.OnTextChanged(EventArgs e)
       at System.Windows.Forms.TextBoxBase.WmReflectCommand(Message& m)
       at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
       at System.Windows.Forms.RichTextBox.WmReflectCommand(Message& m)
       at System.Windows.Forms.RichTextBox.WndProc(Message& m)
       at FarPoint.Win.Spread.FormulaTextBox.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
        CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    UtdTest_SS_Formula
        Assembly Version: 0.0.0.0
        Win32 Version: 0.0.0.0
        CodeBase: file:///C:/My%20Documents/Visual%20Studio%202008/Projects/Com_SS/UtdTest_SS_Formula/UtdTest_SS_Formula/bin/Debug/UtdTest_SS_Formula.DLL
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    Accessibility
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
    ----------------------------------------
    FarPoint.Win.Spread
        Assembly Version: 4.0.2001.2005
        Win32 Version: 4.0.2001.2005
        CodeBase: file:///C:/My%20Documents/Visual%20Studio%202008/Projects/Com_SS/UtdTest_SS_Formula/UtdTest_SS_Formula/bin/Debug/FarPoint.Win.Spread.DLL
    ----------------------------------------
    FarPoint.Win
        Assembly Version: 4.0.2001.2005
        Win32 Version: 4.0.2001.2005
        CodeBase: file:///C:/My%20Documents/Visual%20Studio%202008/Projects/Com_SS/UtdTest_SS_Formula/UtdTest_SS_Formula/bin/Debug/FarPoint.Win.DLL
    ----------------------------------------
    System.Xml
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    System.Data
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
    ----------------------------------------
    FarPoint.CalcEngine
        Assembly Version: 4.0.2001.2005
        Win32 Version: 4.0.2001.2005
        CodeBase: file:///C:/My%20Documents/Visual%20Studio%202008/Projects/Com_SS/UtdTest_SS_Formula/UtdTest_SS_Formula/bin/Debug/FarPoint.CalcEngine.DLL
    ----------------------------------------
    Microsoft.mshtml
        Assembly Version: 7.0.3300.0
        Win32 Version: 7.0.3300.0
        CodeBase: file:///C:/WINDOWS/assembly/GAC/Microsoft.mshtml/7.0.3300.0__b03f5f7f11d50a3a/Microsoft.mshtml.dll
    ----------------------------------------


    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.


    For example:


    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>


    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.


    2008/10/UtdTest_SS_Formula.zip
  • Replied 8 September 2017, 1:33 pm EST

    The "Copy to output directory" property is for the UtdTest_SS_Formula.cs file. 


    There is also a post build event in the project where you can automatically register the dll as com.  It usually doesn't work until after you have created the tlb once manually.  "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe" "$(TargetDir)\UtdTest_SS_Formula.dll" /codebase /tlb:UtdTest_SS_Formula.tlb


     


     

  • Replied 8 September 2017, 1:33 pm EST

    Another thing to look at is the object class id in the html page.  The html guid should match up with the guid in UtdTest_SS_Formula.cs.  They matched up with the source that was uploaded, but is a spot that would cause the object not to load if missing.


    Also, here is the list of files in the bin:


    FarPoint.CalcEngine.dll, FarPoint.Excel.dll, FarPoint.PluginCalendar.WinForms.dll, FarPoint.Win.dll, FarPoint.Win.Spread.dll, Text_ClassId.htm, UtdTest_SS_Formula.cs, UtdTest_SS_Formula.dll, UtdTest_SS_Formula.dll.config, UtdTest_SS_Formula.pdb, UtdTest_SS_Formula.resx, UtdTest_SS_Formula.tlb


     

  • Replied 8 September 2017, 1:33 pm EST

    I've installed the 4.0.2005.2005 version and applied it to my local copy of the project and received the icon in the browser also.  Corrected this by changing the project property "Copy to Output Directory" = Copy Always.  This then placed a copy of the farpoint dll into the debug folder.


    The "Object reference" error occurs with this version also.

  • Replied 8 September 2017, 1:33 pm EST

    When it shows up with the icon, that's the component not being registered as a com object.  I've include a register bat file in the project: UtdTest_Formula_RegAsm.bat.


     You will need to change the paths to match up with the locations of your projects and RegAsm on your local.  There is also a unregister bat you can customize to unreg the component when done. 


    Here is a snipit of the bat: 


    "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe"


    "C:\My Documents\Visual Studio 2008\Projects\Com_SS\UtdTest_SS_Formula\UtdTest_SS_Formula\bin\Debug\UtdTest_SS_Formula.dll"  /codebase /tlb:UtdTest_SS_Formula.tlb


    Thanks,


    Ed

  • Replied 8 September 2017, 1:33 pm EST

    Ed,


    I run through #5, but the control does not show up in the browser. Could you let me know what step I may be missing to get the control into the browser? Also, I would suggest upgrading to the latest maintenance release (version 4.0.2005).

  • Replied 8 September 2017, 1:33 pm EST

    Hello,


    I do not see this option for Copy to OutputDirectory in my project properties. WHen I build though all the Spread assemblies and the custom dll you created are copied in the debug directory of the project. The Regasm tool is working to register the assembly. However, when I double click the html file in the debug directory, nothing is loaded. Is there another step I am missing?

  • Replied 8 September 2017, 1:33 pm EST

    Scott,


    My dev box is running IE 7.  I'm trying this now on a VM and am getting the same results as you even though the component registers fine (did no build, just registered with bat).  Trying different settings on IE to see if the browser is blocking it.  Took a look in the event log but did not see warnings/errors though.


     Ed Ostrowski

  • Replied 8 September 2017, 1:33 pm EST

    Ed,


    I am not sure what is going on. I made the change in the batch files to register and unregister the assembly being built to point to my directory. When I do a rebuild, everything builds correctly and the post build step of registering is succedding. When I double click the htm file to open it in Internet Explorer 7, I get the message about running an ActiveX control and I accept this, but the control still does not load. I then looked at the files in the bin\debug folder and I did not have Com_SS_Formula.cs or Com_SS_Formula.resx as you listed in your previous post. I put these files in and got the same issue.


    Do I need to add the directory into IIS in order to run it correctly? Should this work in IE7? What am I missing to run this page?

  • Replied 8 September 2017, 1:33 pm EST

    Ed,


    I made my debug directory a virtual directory in IIS and ran the htm through localhost and now the page loads correctly. I tested the rest of your steps and the formula textbox did not throw an exceptino and worked correctly. I was using a debug build I made to debug this, so I tested with the 4.0.2005 release you are using and I was able to reproduce the problem. So lastly, I tested with the latest internal build to see if this is a fixed issue already done for the next maintenance release or is an issue between an obfuscated build and unonfuscated build. With the latest interanl build, everything is working correctly, so this must be an issue that has been fixed in the source already and will be in the next maintenance release.

  • Replied 8 September 2017, 1:33 pm EST

    Scott,


    With the trouble you are having with the uploaded project, I've made up a new version of the project called Com_SS_Formula.  This one works the same but has been cleaned up some and has new guids assigned.  While testing this, I was able to get the component not to display by unreg'ing it and then to work by running the reg bat.


    How to reproduce:
    1. Copy Farpoint binaries to folder Com_SS_Formula\Com_SS_Formula\SS_Binaries
     FarPoint.CalcEngine.dll
     FarPoint.Excel.dll
     FarPoint.PluginCalendar.WinForms.dll
     FarPoint.Win.dll
     FarPoint.Win.Spread.dll


    2. Build attached project
     This will generate the dll Com_SS_Formula.dll in the debug folder.
     The post build event will create and register the Com_SS_Formula.tlb.


    3. Browse to the project's debug folder
    4. Double click on Text_ClassId.htm
    5. Accept the running of an ActiveX component in the browser
    6. Set focus to displayed FormulaTextBox
    7. Type =s in FormulaTextBox to generate the framework error mentioned earlier.



    The Com_Formulat_RegAsm.bat and Com_Formulat_UnRegAsm.bat can also be updated to manually register this component.  And below is the build output when compiling the project.


    ------ Build started: Project: Com_SS_Formula, Configuration: Debug Any CPU ------
    Com_SS_Formula -> C:\Temp\Com_SS_Formula\Com_SS_Formula\bin\Debug\Com_SS_Formula.dll
    "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe" "C:\Temp\Com_SS_Formula\Com_SS_Formula\bin\Debug\\Com_SS_Formula.dll" /codebase /tlb:Com_SS_Formula.tlb
    Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.1433
    Copyright (C) Microsoft Corporation 1998-2004.  All rights reserved.


    RegAsm : warning RA0000: Registering an unsigned assembly with /codebase can cause your assembly to interfere with other applications that may be installed on the same computer. The /codebase switch is intended to be used only with signed assemblies. Please give your assembly a strong name and re-register it.
    Types registered successfully
    Assembly exported to 'C:\Temp\Com_SS_Formula\Com_SS_Formula\bin\Debug\Com_SS_Formula.tlb', and the type library was registered successfully
    Done building project "Com_SS_Formula.csproj".
    ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========


     


    Thank you for your help,


    Ed Ostrowski


    2008/10/Com_SS_Formula.zip
  • Replied 8 September 2017, 1:33 pm EST

    Scott,


     As to IIS, my dev box is running IIS 6 (svchost 5.2.3790.3959).  The VM looks to be 5 (svchost 5.1.2600.2180).  Will now try this now on another VM.


     Ed Ostrowski

  • Replied 8 September 2017, 1:33 pm EST

    Scott,


     This is great news!  We have been building a custom solution for some months now and had started on the last environment test when this exception came up last week.


    Do you have an estimate on when the build with the newest fixes will be available?  This is a very important fix for us so if there is a chance to download a advance copy it would be greatly appreciated (we purchased the Spread for .NET Bundle this past May).


     And thank you for working on this issue with me. It was hard work to get it to replicate but well worth the effort <img src="/emoticons/emotion-1.gif" alt="Smile" />


    Ed Ostrowski

  • Replied 8 September 2017, 1:33 pm EST

    Scott,


    I'm running into versioning issues with FarPoint.PluginCalendar.WinForms.  Can you include the latest version of this one in your hotfix?


    Thanks,


    Ed

  • Replied 8 September 2017, 1:33 pm EST

    Scott,


    Our project is scheduled to be complete soon, so if we could have access to your current internal build it would be greatly appreciated.  We understand it is not completely tested, but with this issue basically being a show stopper for us, we would like to apply it to our project as soon as possible.  Once the full maintenance release is available, then we will apply that to our setup. 


    Thank you,


    Ed Ostrowski

  • Replied 8 September 2017, 1:33 pm EST

    Scott,


    Thanks for the Hotfix.  I'm testing against it now and it does fix the exception from occurring in the sample project.  But the formula popup window positions in the upper left hand corner of the screen and not under the formula textbox.  This does position correctly when the component is on a winform.  (This type of bug is completely understandable in a fix that hasn't gone through QA, just wanted to bring it to your attention.)


    But I have not yet tried this in our main test environment.  We have made a number of unrelated changes there that need to be addressed before I can proceed.  Will keep you posted on my progress and thank you once again for the superb support. 


    Ed Ostrowski 


     

  • Replied 8 September 2017, 1:33 pm EST

    Ed,


    We are working on having the maintenance release available before the end of the month. I think it would be better to wait for the ful maintenance release than to take the internal build we have now that is not fully tested, if you are able to wait a couple of weeks.

  • Replied 8 September 2017, 1:33 pm EST

    Thanks Scott.  When do you think the fix will be available?
  • Replied 8 September 2017, 1:33 pm EST

    Ed,


     I checked the zip file and this time it is correct. I reported the other issues as bugs (#23326 and #23327) for the development team to fix for the mainetnance release.

  • Replied 8 September 2017, 1:33 pm EST

    Scott,


    Thanks for the update, but FarPoint.PluginCalendar.WinForms.dll is missing from the zip.  Could you repost please? 


    Also, running into an issue with Formulas in the sample project.  The formula is not being applied against the cells.  Instead it's displaying as text.  If you type in a value in A1 and B1, then place a formula in C1 of =A1+B1, it stays as the text instead of applying the formula.  This also acts in the same manner when you select a formula from the drop down list, say =SUM(A1:B1).


    Thanks again,


    Ed

  • Replied 8 September 2017, 1:33 pm EST

    Ed,


     


    I appologize. I posted the wrong zip. It is now updated.

  • Replied 8 September 2017, 1:33 pm EST

    Hello,


    We are working to release ths as soon as possible. Hopefully in the next couple of weeks.

  • Replied 8 September 2017, 1:33 pm EST

    Scott,


    Any release date set on the maintenance update?  This is a very important fix for us, so any additional information would be appreciated.


     Thanks,


     Ed Ostrowski

  • Replied 8 September 2017, 1:33 pm EST

    Ed,


    The maintenance release on 10/29 was not a full maintenance release. We were working on doing an early maintenance release of Spread for Windows Forms, but some code was introduced that was found to cause a lot of issues. At the same time, another bug was found in uor core source that could be a data integrity issue for users, so the management decided to role back the code to the last maintenance release on the build machine, and by hand make the changes to fix the issues fixed in the 2 hot fixes we had since then and this bug and release this product.


    We are doing the same for Spread for ASP.NET and trying to release version 8 of the Spread ActiveX product. We will then be doing the full maintenance releases for the .NET product. We expect this to be toward the end of the month, which is only a couple of weeks off the original schedule for the release.

  • Replied 8 September 2017, 1:33 pm EST

    Hello,


    After installing "Spread for Windows Forms for 2.0 Framework 4" dated 10/29/2008 the exception is still occurring.  The dll installed are dated 10/29/2008 with version of 4.0.2008.2005.  Did I get the wrong release?  And I do not see the issue numbers #23326 and #23327 in the release notes as being addressed. 


    It appears that even the fix that was made in the hot fix on 10/17/2008 (popup displayed but was in the wrong position) was not included since the exception is the same as from 8/7/2008's release.


    Can you find out the status of these fixes?


    Thank you,


    Ed Ostrowski


     


     

  • Replied 8 September 2017, 1:33 pm EST

    Ed -

    We released it yesterday.  it should be on our website.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels