Reputation: 1017
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
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):
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.
vs
Upvotes: 0
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