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

Could not load type xxx from assembly when using chart

7 Answers 252 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 20 Apr 2009, 07:54 PM
Hi,
I'm trying to create a chart in my report but getting:
An error has occured while processing Chart 'chart1':
Could not load type 'DO.ReportBars' from assembly 'DO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.


The class is very simple:
namespace DO 
    public class ReportBars 
    { 
        public ReportBars() 
        { 
        } 
 
        public ReportBars(string name, int value) 
        { 
            _name = name; 
            _value = value; 
        } 
 
        private string _name; 
        public string Name 
        { 
            get { return _name; } 
            set { _name = value; } 
        } 
 
        private int _value; 
        public int Value 
        { 
            get { return _value; } 
            set { _value = value; } 
        } 
 
    } 

And the chart code:
private void chart1_NeedDataSource(object sender, EventArgs e) 
        { 
            Telerik.Reporting.Processing.Chart chart = (Telerik.Reporting.Processing.Chart)sender; 
            Telerik.Reporting.Chart chartDef = (Telerik.Reporting.Chart)chart.ItemDefinition; 
 
            List<DO.ReportBars> bars = new List<DO.ReportBars>(); 
            bars.Add(new DO.ReportBars("Parka L", 120)); 
            bars.Add(new DO.ReportBars("Parka M", 100)); 
            bars.Add(new DO.ReportBars("Parka S", 132)); 
            bars.Add(new DO.ReportBars("Wool Cap", 45)); 
            bars.Add(new DO.ReportBars("Mittens", 67)); 
 
            chartDef.Series.Clear(); 
            ChartSeries s = new ChartSeries(); 
            s.Type = ChartSeriesType.Bar; 
            chartDef.Series.Add(s); 
            s.DataYColumn = "Value"
            s.DataLabelsColumn = "Name"
 
            chart.DataSource = bars; 
        } 

The strange thing is that it works if I move the ReportBars class to the same namespace as the report so the ReportBars is not placed in a different assembly.
 




7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 21 Apr 2009, 12:25 PM
Hello Mattias,

This would happen only when you're trying to use the report designer previews, as when your business objects are in a different assembly, the designer does not know where to load them from. To be able to use the previews in this scenario, you can copy the DO assembly in the C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies folder, restart Visual Studio and open the project again.
Or you can simply add reference to your report class library from your web/win application and use win/web form to preview the result.

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mattias
Top achievements
Rank 1
answered on 21 Apr 2009, 02:20 PM
Thanks Steve for your reply,
Preview the report in the web application works!

But it's not very user friendly, first make some changes in the report, build the report project, publish the web application, browse to the report aspx page and see the result and then go back and start all over!

I hope and guess that this is something you will change in a hotfix, right?
it should be enough to add a reference to the entities project from the report project!


0
Steve
Telerik team
answered on 21 Apr 2009, 02:34 PM
Hi Mattias,

You're the first person to report this, so there is a chance that this is something specific to the chart report item only. Anyway we would look into that, but this issue is with low priority and our advice is to use one of the suggested workarounds for the time being.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
TonyG
Top achievements
Rank 1
answered on 07 Mar 2013, 08:32 AM
Wow, I know this is a moldy-old thread but I just had the same issue. So I look all over for "could not load type" and I find this thread. I copied my data assembly to PrivateAssemblies (for VS10), restarted VS, and yay, there's my data.

But as a test I changed my data assembly to return different values, and then went back to the report Preview, and the data was changed.

So at least in the current release the solution to this specific problem is to simply restart VS, without moving the data DLL to PrivateAssemblies.

Telerik Reporting: Q1 2013 build 7.0.13.220
Using ObjectDataSource for a report with columns, not a chart.

I hope that helps someone.
0
Ammar
Top achievements
Rank 1
answered on 17 Aug 2013, 01:53 PM
Hi
Steve same error was encountered in my same case as well.
But all provided solution are not working in my case please help me

also the report is not opening in ReportViewer But Got printed if exported in PDF

Regards,
Ammar Ahmed Khan
Software Engineer
NetSol
Pakistan
0
Peter
Telerik team
answered on 21 Aug 2013, 03:38 PM
Hello Ammar,

We will need additional information in order to pinpoint the root of the issue:
  • Do you use the ObjectDataSource component? 
  • How do you databind your report data items? 
  • Do you use the Chart item? 
  • Which Telerik Reporting version you use? 
  • Can you open a support thread and send us the problematic project or at least the report definition to review and debug on our end?
Regards,
Peter
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

0
Ammar
Top achievements
Rank 1
answered on 22 Aug 2013, 05:46 AM

First of all I want to say thanks to you as It was me doing wrong. I was populating my chart dynamically wich would not show any thing in preview. And second thing is very funny that I was not giving any height to my report viewer which was obviously showing nothing.

I got my problem fixed now

  • I did not used the ObjectDataSource or I dont know about it.
  • I am populating the series item by a DataTable (which is being populated by a WCF service).
  • I am preparing a series by populating it from DataTable (Helping code is provided below) and the adding it in chart.
  • The Telerik Reporting version I have is Q3
  • The code is as below


private void chart1_NeedDataSource(object sender, EventArgs e)
        {
            string[] xAxisLabels = new string[4];
            Color[] barColor = new Color[] { Color.SteelBlue, Color.Aqua, Color.Navy, Color.Blue };
            int itemValue = 0;
            int index = 0;

            DataTable dt = FillDataTable();

            Telerik.Reporting.Processing.Chart chart2 = sender as Telerik.Reporting.Processing.Chart;
            Telerik.Reporting.Charting.ChartSeries series2 = new Telerik.Reporting.Charting.ChartSeries();
            series2.Type = ChartSeriesType.Bar;
            Telerik.Reporting.Charting.ChartLegend legend = new Telerik.Reporting.Charting.ChartLegend();
            Telerik.Reporting.Charting.ChartSeriesItem seriesItem2;

            foreach (DataRow rowView in dt.Rows)
            {
                seriesItem2 = new Telerik.Reporting.Charting.ChartSeriesItem();

                //The chart Y value will be based on the Value amount
                seriesItem2.YValue = Convert.ToInt32(rowView[0]);
                seriesItem2.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
                //seriesItem2.Appearance.FillStyle.MainColor = System.Drawing.Color.AliceBlue;

                //The chart item label should be set to the Value amount
                itemValue = Convert.ToInt32(rowView[0]);
                seriesItem2.Label.TextBlock.Text = itemValue.ToString("##");
                seriesItem2.Label.Appearance.LabelLocation = Telerik.Reporting.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside;
                seriesItem2.Label.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.FromArgb(28, 58, 112);

                seriesItem2.Appearance.FillStyle.MainColor = barColor[index];

                series2.AddItem(seriesItem2);
                xAxisLabels[index] = rowView[1].ToString();

                index++;
            }

            //Display the legend
            series2.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
            series2.Appearance.Border.Color = System.Drawing.Color.White;
            series2.Appearance.Border.Visible = false;
            //series.Appearance.DiameterScale = .90;

            series2.Appearance.ExplodePercent = 10;

            chart1.Series.Clear();
            chart1.Series.Add(series2);

            chart1.PlotArea.XAxis.AutoScale = false;
            chart1.PlotArea.XAxis.AddRange(1, 4, 1);

            for (int i = 0; i < 4; i++)
            {
                chart1.PlotArea.XAxis[i].TextBlock.Text = xAxisLabels[i];
            }

            chart1.ChartTitle.Appearance.Position.X = 20;
            chart1.Legend.Appearance.Position.AlignedPosition = Telerik.Reporting.Charting.Styles.AlignedPositions.TopRight;
        }

Thanks Steve.
Tags
General Discussions
Asked by
Mattias
Top achievements
Rank 1
Answers by
Steve
Telerik team
Mattias
Top achievements
Rank 1
TonyG
Top achievements
Rank 1
Ammar
Top achievements
Rank 1
Peter
Telerik team
Share this question
or