'Could not load file or assembly 'Microsoft.ReportViewer.WinForms .net core calling framework vb

I have the following code working in VB framework 4.7.2

Using adapter As SqlDataAdapter = New SqlDataAdapter(cmd)
    Dim ds As DataSet = New DataSet()
    adapter.Fill(ds, TableName)
    Dim rds As ReportDataSource = New ReportDataSource("DataSource1", ds.Tables(TableName))  
    Dim local As LocalReport = New Microsoft.Reporting.WinForms.LocalReport()
    local.ReportPath = reportFilename
    ' needed for pics
    local.EnableExternalImages = True
    local.DataSources.Add(rds)
    Dim warnings As Warning() = Nothing
    Dim streamids As String() = Nothing
    Dim mimeType As String = Nothing
    Dim encoding As String = Nothing
    Dim extension As String = Nothing
    Dim bytes As Byte()
    bytes = local.Render(RenderType, Nothing, mimeType, encoding, extension, streamids, warnings)
    If My.Computer.FileSystem.FileExists(outputFilename) Then
        My.Computer.FileSystem.DeleteFile(outputFilename)
    End If
    File.WriteAllBytes(outputFilename, bytes)
    Return bytes.Length
End Using

The project has package references

  <ItemGroup>
    <PackageReference Include="Microsoft.Report.Viewer">
      <Version>11.0.0</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.ReportViewer.WinForms.VS2010">
      <Version>10.0.40219.1</Version>
    </PackageReference>
  </ItemGroup>

This works fine in a library called from .net framework 4.7.2 However if I call the library from a .net core 6 library I get the following error.

Could not load file or assembly 'Microsoft.ReportViewer.WinForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified

The same relevant files are present, in particular

Microsoft.ReportViewer.Winforms.dll
Microsoft.ReportViewer.Common.dll
Microsoft.ReportViewer.ProcessingObjectModel.dll

I have asked this related question.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source