My BussinessObject does not exist in the current context

Tale MasinovTale Masinov Skopje, Macedonia
edited 6:35PM in FastReport .NET
Hi... [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I'm using FastReport.NET. I am creating a report all from code and I have the following error. My data source is a bussiness object, actually a list of objects, that are in another .dll which I'm referencing in my project. Example:[/img]
public class Test
{
  public string TestField1
  { get; set; }
}
List<Test> testList = new List<Test>();

If the class definition is in the same namespace with the report it works fine, but in my case it throws me the error
"The name 'Test' does not exist in the current context"

The definition of the class Test is in another project, and I'm adding a reference to it in my FastReport project.

Can someone help ?

Thanks.

Comments

  • Tale MasinovTale Masinov Skopje, Macedonia
    edited 6:35PM
    I noticed also this :
    public class Test1
    {
        public string TestField1 { get; set;}
    }
    
    public class Test2 : Test1
    {
        public string TestField2 { get; set;} 
    }
    
    //in my FastReport code
    List<Test2> testList = new List<Test2>();
    // .... add objects ....
    
    report.RegisterData(testList,"Test");
    report.GetDataSource("Test").Enabled=true;
    
    //... later in TextObject t
    t.Text = "[Test.TestField2]";
    

    report.Prepare() throws the error "The name 'Test' does not exist in the current context"
  • edited 6:35PM
    Hello,

    Did you register the data source in a report using the report.RegisterData call? Please look at the demos to see how to do this:
    Demos\C#\DataFromBusinessObject
    Demos\C#\Main
  • Tale MasinovTale Masinov Skopje, Macedonia
    edited 6:35PM
    AlexTZ wrote: »
    Hello,

    Did you register the data source in a report using the report.RegisterData call? Please look at the demos to see how to do this:
    Demos\C#\DataFromBusinessObject
    Demos\C#\Main

    Yes I did that... but.... [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> Here is my class hierarchy : I have a base class (for example Base) with some public properties. I inherit from Base class into class Derived in which I have other public properties. My Data Source is a List<Derived> generic list, which I register and I still get the same error. But if Derived does not inherit from Base it works properly. The code example I gave earlier explains it.[/img]
  • edited 6:35PM
    Could you make a simple demo for me and send it to tz@fast-report.com? Your code example is close to what we have in the demo, which is working fine.
  • Tale MasinovTale Masinov Skopje, Macedonia
    edited February 2010
    I found what the problem was.
    FastReport interprets differently between IEnumerable types. I used generic list of objects ( List<T> ).
    I tried it with ArrayList and it works.
    Thanks anyway >
  • edited 6:35PM
    Hello,

    The problem is that you are using List<TestClass>, which contains TestClass2 instances. Either use List<TestClass2>, or ArrayList.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.