[RESOLVED] Object reference not set to an instance of an object.-VBForums
Results 1 to 17 of 17

Thread: [RESOLVED] Object reference not set to an instance of an object.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Resolved [RESOLVED] Object reference not set to an instance of an object.

    Hi all,

    here's one for you:

    I download and install the WPF toolkit for Feb 2010 that has the chart control in it, i add a reference to that chart control in my app, then I create a window and drag a chart control on to it - it defaults to a name of chart1.

    if i call that window i get an "Object reference not set to an instance of an object." error - in my case i'm trying to drag a column chart on to the window.

    Any thoughts?

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    Re: Object reference not set to an instance of an object.

    What do you mean by "if I call that window" ... Are you saying this exception is thrown as soon as you show the window or what? Also is this in the designer or when you actually launch the program?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Re: Object reference not set to an instance of an object.

    correct - when i show the window from my main window:

    Code:
    dim f2 as new window1
    f2.show()
    if i delete the chart, the window loads fine. It happens in both an F5 build or CTRL-F5 build....i can see and work with the chart on the window in design mode no problem, can also access the xaml and codebehind - i'm trying to use a datatable as a data source for a column chart - at first i thought it was the format of the data table that was the problem but eventually in going through the process of elimination i finally decided to create a blank form and just drop a chart control on it and see what happens and it still errored out.
    Last edited by trevorjeaton; Oct 5th, 2010 at 07:51 PM.

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    Re: Object reference not set to an instance of an object.

    Wrap the call in a Try/Catch and post the full stack trace here, i.e:

    vb Code:
    1. Try
    2.    Dim f2 As New Window1
    3.    f2.Show()
    4. Catch ex As Exception
    5.    SomeTextBox.Text = ex.ToString 'Now copy the text that is placed in SomeTextBox and post it here
    6. End Try
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Re: Object reference not set to an instance of an object.

    okay done:

    Code:
    System.NullReferenceException: Object reference not set to an instance of an object.
    Further info is that my dev machine is 64 bit windows 7 - would that affect the added on wpf toolkit and its install location? I may have run across that in one of my previous posts but will have to check them - will post my findings on that as well.
    Last edited by trevorjeaton; Oct 6th, 2010 at 08:10 AM.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Re: Object reference not set to an instance of an object.

    the 64 bit issue was with RIA services, so nevermind on that one, but the chart issue remains...

    can you duplicate it? my order of operations was this:

    - install the wpf toolkit
    - create a new project
    - add a reference to the wpftoolkit.dll to your project
    - drop a button on to the main form
    - add a new window to the project called window1
    - drag a chart control on to that window
    - in the codebehind on the button on the main window add this:

    Code:
    dim f2 as new window1
    f2.show
    press f5 to build, then click the button on the main form to see if it launches window1 with a blank chart. If successfull, then i may have to take a look at my visual studio installation. also, as stated above, the dev machine is 64 bit win 7 ultimate and VS 2010

  7. #7
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    Re: Object reference not set to an instance of an object.

    Quote Originally Posted by trevorjeaton View Post
    okay done:

    Code:
    System.NullReferenceException: Object reference not set to an instance of an object.
    Further info is that my dev machine is 64 bit windows 7 - would that affect the added on wpf toolkit and its install location? I may have run across that in one of my previous posts but will have to check them - will post my findings on that as well.
    There should be much more info than that - you might need to make sure whatever textbox you made it output to is able to hold more than one line (cant remember if the WPF textbox has a multiline property like the winforms one does). The kind of output I'm looking for is what you see in the bottom textbox in this image:
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Re: Object reference not set to an instance of an object.

    yep, i know exactly what you're talking about, and was what i was expecting to see too, hence my head scratching on this one - will try a textblock instead of a textbox.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Re: Object reference not set to an instance of an object.

    textblock did the trick:

    Code:
    System.NullReferenceException: Object reference not set to an instance of an object.
       at System.Windows.Controls.DataVisualization.Charting.ColumnSeries.<>c__DisplayClass8.<GetAxes>b__4() in C:\dd\WPF_1\src\wpf\src\ControlsPack\WPFToolkit\DataVisualization\Charting\Series\ColumnSeries.cs:line 47
       at System.Windows.Controls.DataVisualization.Charting.DataPointSeriesWithAxes.GetAxes(DataPoint firstDataPoint, Func`2 independentAxisPredicate, Func`1 independentAxisFactory, Func`2 dependentAxisPredicate, Func`1 dependentAxisFactory) in C:\dd\WPF_1\src\wpf\src\ControlsPack\WPFToolkit\DataVisualization\Charting\Series\DataPointSeriesWithAxes.cs:line 482
       at System.Windows.Controls.DataVisualization.Charting.ColumnSeries.GetAxes(DataPoint firstDataPoint) in C:\dd\WPF_1\src\wpf\src\ControlsPack\WPFToolkit\DataVisualization\Charting\Series\ColumnSeries.cs:line 35
       at System.Windows.Controls.DataVisualization.Charting.DataPointSeriesWithAxes.GetAxes() in C:\dd\WPF_1\src\wpf\src\ControlsPack\WPFToolkit\DataVisualization\Charting\Series\DataPointSeriesWithAxes.cs:line 394
       at System.Windows.Controls.DataVisualization.Charting.DataPointSeriesWithAxes.OnDataPointsChanged(IList`1 newDataPoints, IList`1 oldDataPoints) in C:\dd\WPF_1\src\wpf\src\ControlsPack\WPFToolkit\DataVisualization\Charting\Series\DataPointSeriesWithAxes.cs:line 319
       at System.Windows.Controls.DataVisualization.Charting.DataPointSingleSeriesWithAxes.OnDataPointsChanged(IList`1 newDataPoints, IList`1 oldDataPoints) in C:\dd\WPF_1\src\wpf\src\ControlsPack\WPFToolkit\DataVisualization\Charting\Series\DataPointSingleSeriesWithAxes.cs:line 277
    interesting - looks like a bug - the references to the .cs extesions is what caught my eye - this app is vb 2010 lol - and i have no folder in the root of my C: named 'dd'

    Going to download the toolkit and install it again......weird......

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Re: Object reference not set to an instance of an object.

    same issue with a newly installed wpf toolkit - one thing i am noticing is that the toolkit is version 3.5.50211.1 - would it be safe to assume it targets the .net 3.5 framework? my app specifically targets 4.0

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Re: Object reference not set to an instance of an object.

    okay, also, i just finished changing my target framework and recompiling each time from the 4.0 client profile to the 4.0 full framework and then in turn to the 3.5 client profile, and finally the 3.5 full framework - same error as above on all targeted frameworks with a freshly installed wpf toolkit (feb 2010 version)
    .

  12. #12
    PowerPoster
    Join Date
    May 2002
    Posts
    25,755

    Re: Object reference not set to an instance of an object.

    "System.Windows.Controls" < -- Umm.... is the chart control a WPF control? Or a WinForms control? .... I know it's possible to use WPF controls in a WinForm app with the appropriate container... but I'm not sure it works the other way around.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Re: Object reference not set to an instance of an object.

    the wpf toolkit (from what i'm reading about it anyway) is a 100&#37; wpf control for the chart

    here's the link - looks like charts are still in the preview quality band though:

    http://wpf.codeplex.com/releases/view/40535

  14. #14
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    Re: Object reference not set to an instance of an object.

    Quote Originally Posted by techgnome View Post
    "System.Windows.Controls" < -- Umm.... is the chart control a WPF control? Or a WinForms control? .... I know it's possible to use WPF controls in a WinForm app with the appropriate container... but I'm not sure it works the other way around.

    -tg
    System.Windows.Controls is a WPF namespace... I think you might have misread it and seen System.Windows.Forms

    Trevorjeaton - if I get chance tonight I'll try installing it and see if I have the same problem
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Re: Object reference not set to an instance of an object.

    its just trev by the way guys :-)

    Thanks for the assistance - its highly appreciated.
    Last edited by trevorjeaton; Oct 6th, 2010 at 01:52 PM.

  16. #16
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    Re: Object reference not set to an instance of an object.

    Just tried and I get the same problem and also the very first time I tried it I got prompted to select the location of DataPointSeries.cs... on subsequent runs I get the same thing you get in the stack trace where it is looking for 'C:\dd\WPF_1\src\wpf\src\ControlsPack\WPFToolkit\DataVisualization\Charting\Series\DataPointSeries.c s'

    I know its in the Preview quality band (which they say is equivalent to Alpha stage) but you would at least expect the thing to actually be able to be displayed on a form! I've never been very impressed with anything in the WPF Toolkit to be honest, I see lots of people reporting lots of bugs and it looks like MS dont put that much effort into it really. I'd rather just wait until controls make it into the official versions of the framework, which hopefully the Chart control will in the next version... but thats not much use to you right now. I'm afraid you might have to just shell out for a third party charting component or try and build your own. I know at work some of our developers use the DevExpress controls but I've no experience with them myself so cant say how good they are - they have a WPF charting control here: http://www.devexpress.com/Products/N.../WPF/Charting/
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Re: Object reference not set to an instance of an object.

    okay, thanks for the confirmation - i guess patience is a virtue and i'll hurry up and wait on this one....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.