This is a migrated thread and some comments may be shown as answers.

3D-Chart crashes but 2D works...

3 Answers 126 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Dimi
Top achievements
Rank 1
Dimi asked on 12 Oct 2009, 01:39 PM
Hi,

i try to render WPF content with telerik chart-controls in VB6. This is possible if you are using the Microsoft Interop Forms Toolkit (http://msdn.microsoft.com/en-us/vbasic/bb419144.aspx). If i'm using the 2D controls everiting is fine. But if I switch to 3D I get a OutOfMemoryException or NullReferenceException.

Here is my XAML:
<UserControl x:Class="UserControl1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:charts="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting">  
    <Grid> 
        <charts:RadChart x:Name="MyChart"/>  
    </Grid> 
</UserControl> 
 

This is the code-behind from the 2D version:
    Public Sub New()  
 
        ' This call is required by the Windows Form Designer.  
        InitializeComponent()  
 
        ' Add any initialization after the InitializeComponent() call.  
        MyChart.DefaultSeriesDefinition = New BarSeriesDefinition  
 
        Dim itemSource As Double() = {5, 9, 17, 10, 11, 3, 12}  
        MyChart.ItemsSource = itemSource  
 
    End Sub 
 

And here is the code-behind from the 3D version:
    Public Sub New()  
 
        ' This call is required by the Windows Form Designer.  
        InitializeComponent()  
 
        ' Add any initialization after the InitializeComponent() call.  
        MyChart.DefaultSeriesDefinition = New Bar3DSeriesDefinition  
 
        Dim itemSource As Double() = {5, 9, 17, 10, 11, 3, 12}  
        MyChart.ItemsSource = itemSource  
 
        AddHandler MyChart.DefaultView.ChartArea.Loaded, AddressOf Me.RadChart_Loaded  
 
    End Sub 
 
    Private Sub RadChart_Loaded(ByVal sender As ObjectByVal e As RoutedEventArgs)  
 
        Dim camera As New CameraExtension  
        camera.SpinAxis = SpinAxis.XY  
        camera.ZoomEnabled = True 
 
        MyChart.DefaultView.ChartArea.Extensions.Add(camera)  
 
    End Sub 

The same code works in a normal .NET-project and also in a WinForms-project on the ElementHost.

Best regards,
Dimi

3 Answers, 1 is accepted

Sort by
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 15 Oct 2009, 08:32 AM
Hello Dimi,

This is one exotic setup you have here. It seems quite odd that your managed application is crashing with different kinds of exceptions on consecutive runs (NullReferenceException vs OutOfMemoryException). Also, as you have noted the same setup works seamlessly on the officially supported platforms (pure WPF setup and WinForms-hosted one) so I would suspect there is some problem with this particular toolkit when rendering 3D content. Have you verified the toolkit is capable of rendering generic WPF 3D content at all?


Greetings,
Bart.
0
Dimi
Top achievements
Rank 1
answered on 15 Oct 2009, 08:52 AM
Hello Bart,

the toolkit has no problems with other 3D staff. Everything I've tested works well. It only crashes with the 3D-charts.

Best regards,
Dimi
0
Dimi
Top achievements
Rank 1
answered on 04 Feb 2010, 03:11 PM
Hello Everyone,

I've solved the problem above. The .NET-Framework can't find the "Telerik.Windows.Controls.Charting.dll" in my setup. It works only if you put the assembly in the gac or if you're using the following methods at the beginning of your program (before using any chart):

    Private Sub LoadDependentAssemblies()  
        Try 
            Dim currentDomain As AppDomain = AppDomain.CurrentDomain  
 
            AddHandler currentDomain.AssemblyResolve, AddressOf MyResolveEventHandler  
 
            InstantiateTelerikAssemblies(currentDomain)  
 
            RemoveHandler currentDomain.AssemblyResolve, AddressOf MyResolveEventHandler  
        Catch ex As Exception  
            'some error handling...  
        End Try 
    End Sub 
 
    Private Sub InstantiateTelerikAssemblies(ByVal domain As AppDomain)  
        Try 
            ' create a dummy instance  
            domain.CreateInstance("Telerik.Windows.Controls.Charting, Version=2009.3.1208.35, Culture=neutral, PublicKeyToken=5803cfa389c90ce7""Telerik.Windows.Controls.RadChart")  
        Catch e As Exception  
        End Try 
    End Sub 
 
    Private Function MyResolveEventHandler(ByVal sender As ObjectByVal args As ResolveEventArgs) As [Assembly]  
        Dim assemblyPath as String = "[the path of the assembly]" 
        Return Assembly.LoadFrom(assemblyPath & "Telerik.Windows.Controls.Charting.dll"))  
    End Function 
 

Best regards,
Dimi
Tags
Chart
Asked by
Dimi
Top achievements
Rank 1
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
Dimi
Top achievements
Rank 1
Share this question
or