JamTay317
JamTay317

Reputation: 1017

Populating Crystal Report using DataSet and Entity Framework

I have a report and a DataSet. The DataSet has 2 tables one called Projects and the other called ShipListItems. What I am trying to do is populate my report data source using the dataset.

I am not sure where I can going wrong. I have found this but I really do not see the difference that i am doing.

        private async void ChangeReport(ReportType reportType)
    {
        var ds = new ShipListDataset();
        await LoadDataSet(ds);
        
        var path = GetReportPath(reportType); //Just returns correct path for different reports
        var report = new ReportDocument();
        report.Load(path);

        report.SetDataSource(ds);
        ReportsViewer.ViewerCore.ReportSource = report;
    }//Change Report


        private async Task LoadDataSet(ShipListDataset ds)
    {
        var data = await _dataProvider.ProjectAsync();
        var projects = data.Select(x => new
        {
            Client = x.Client, JobNumber = x.JobNumber, Event = x.Event, Booth = x.Booth
        });
        
        projects.ForEach(x => ds.Projects.AddProjectsRow(x.Client, x.JobNumber, x.Event, x.Booth));

        foreach (var project in data.Select(x => x.ShipListItems))
        {
            foreach (var shipListItem in project)
            {
                ds.ShipListItem.AddShipListItemRow(Trailer: shipListItem.Trailer, Crate: shipListItem.CrateNumber, PartCode: shipListItem.PartNumber, Description: shipListItem.ItemDescription, Notes: shipListItem.Notes, ShippedOut: shipListItem.Out, Rented: !shipListItem.CustomItem, Custom: shipListItem.CustomItem, SaveGraphics: (shipListItem.SaveGraphics == SavedGraphics.Saved), GraphicsDisposed: (shipListItem.SaveGraphics == SavedGraphics.Disposed), Inbound: Convert.ToInt32(shipListItem.Inbound), InboundNotes: shipListItem.Notes, ColorScheme: shipListItem.ColorScheme, Quantity: shipListItem.Quantity, parentProjectsRowByProjects_ShipListItem: ds.Projects.FirstOrDefault(x => x.JobNumber == shipListItem.JobNumber));
            } //foreach ShipListItem
        } //foreach Project
        ds.AcceptChanges();
    } //Load DataSet

I do get 2 exceptions saying

Additional information: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

and

Additional information: Could not load file or assembly 'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.

The exceptions happen on report.SetDataSource(ds);.

thank you for your help!

Upvotes: 1

Views: 652

Answers (2)

LJPung
LJPung

Reputation: 1

As everybody says: You simply add the following to the app.config file.

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
  <NetFx40_LegacySecurityPolicy enabled="true"/>
</runtime>

The REAL TRICK is to find the app that your tool is using when Power Shell is a plugin:

With only your programming tool Running (In my example Visual Studio with a PS solution loaded):

  • Open Task Manager and locate Powershell process (There will be two...so you will have to create two "app.config" files below.
  • Right-click process and select "open file location". (PowerShellToolsProcessHost.exe and PowerShellToolsProcessHostConsole.exe where both in a randomly generated Extensions folder in my case)
  • Create a TWO files with the above xml
    • PowerShellToolsProcessHost.exe.config
    • PowerShellToolsProcessHostConsole.exe.config
  • Then you should probably restart your application (in my case VS)

Note: You have to have permission to edit your ProgramFiles(x86) folder. However I did have these files already in my USERS directory except they were under a different randomly generated folder. To improve on my post: You MIGHT try simply making sure that your USERS path matches the one in your ProgramFiles folder.

  • What my application was referencing: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions*mhoykkws.b1d*

vs

  • Where my useless orphan files were: C:\Users\Userme\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\43kbvqc0.xoo

Upvotes: 0

JamTay317
JamTay317

Reputation: 1017

My anwser was that I had to add to config file.

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

Upvotes: 1

Related Questions