Connection dinamically with jsonDataConnection

I'm trying to create connection dinamically with jsonDataConnection, but the following error appears when adding the connection in the report.

JsonDataConnection connection = new JsonDataConnection();
connection.Json = @C:\Users\MACIEL\Documents\GitHub\Virtual-Boleto\DataBase\Caixa\db - Copia.json;
report.Dictionary.Connections.Add(connection);

The "DataConnectionBase" type is defined in an assembly that is not referenced. You must add a reference to the assembly "FastReport, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = db7e5ce63278458c"



If someone can help, I'm grateful.

Comments

  • edited 9:10AM
    have you followed the readme file?
    How to register this dll in FastReport:
    ---------------------------------------
    
    You can do it in several ways:
    
    1) register using the FastReport IDE
    - open the report designer;
    - go "View|Options..." menu;
    - on the "Plugins" tab, add the FastReport.Json.dll;
    - restart FastReport. If you are working in the Visual Studio IDE, restart 
    it as well;
    
    2) edit manually the FastReport.config file
    - by default, this file is located in the "C:\Documents and Settings\user_name\
    Local Settings\Application Data\FastReport" folder;
    - close any running instances of FastReport.Net;
    - open the config file in any text editor and modify it in the following way:
      <?xml version="1.0" encoding="utf-8"?>
      <Config>
        ...
        <Plugins>
          <Plugin Name="c:\.....\FastReport.Json.dll"/>
        </Plugins>
      </Config>
    
    3) register the dll programmatically
    - add the "FastReport.Json.dll" reference to your project;
    - execute the following code once at the application start:
    FastReport.Utils.RegisteredObjects.AddConnection(typeof(JsonDataConnection));
    
  • edited April 2018
    Was not followed step three, where do I specifically need to register JsonDataConnection?

    Because I run it here
            public MainWindow()
            {
                RegisteredObjects.AddConnection(typeof(JsonDataConnection));
                InitializeComponent();
            }
    

    the project is not compiled.
  • edited 9:10AM
    add the "FastReport.Json.dll" reference to your project, then you can use type 'JsonDataConnection'
  • edited 9:10AM

    The project is not yet compiled. The following message is displayed when using the code.

    Your application has entered an interrupt state, but there is no code to show because all threads have executed external code (usually system code or structure).
  • edited April 2018
    i use json data in a different way, create a business object then pass it to fastreport, see my attachment
  • edited 9:10AM
    Thanks, but for this project to create the report as you gave me in the last post, it would be difficult for future maintenances
  • edited 9:10AM
    i deliberately not using frx file [img]style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> after creating business object, just:[/img]
    FastReport.Report report = new FastReport.Report();
    report.RegisterData(data, "Instagram", 10);
    report.Design();
    


  • edited 9:10AM
    this version doesnt need visual studio, open the frx file with designer.exe and make sure that you have Newtonsoft.Json.dll along with designer.exe in the same folder, then preview

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.