question

OLIVIERSTEINBERG-1132 avatar image
0 Votes"
OLIVIERSTEINBERG-1132 asked OLIVIERSTEINBERG-1132 published

Could not load file or assembly 'Microsoft.ReportViewer.Common' version=15.0.0.0 winforms powershell

Hi, I'm trying to run a Reportviwer RDLC report, rendering data from a SQL Server DB to Excel from Powershell 5.1.

When I run the PS script report with Reportviewer runtime 2015 v14 or runtime 2017 v15 I get this error: "Could not load file or assembly 'Microsoft.ReportViewer.Common' version=15.0.0.0 Winforms Powershell."

Échec du chargement de l'assembly hôte d'expressions. Détails: Impossible de charger le fichier ou l'assembly 'Microsoft.ReportViewer.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' ou une de ses dépendances.
Le fichier spécifié est introuvable.
à Microsoft.ReportingServices.RdlExpressions.ReportRuntime.ProcessLoadingExprHostException(ObjectType assemblyHolderObjectType, Exception e, ProcessingErrorCode errorCode)
à Microsoft.ReportingServices.RdlExpressions.ReportRuntime.LoadCompiledCode(IExpressionHostAssemblyHolder expressionHostAssemblyHolder, Boolean includeParameters, Boolean parametersOnly, ObjectModelImpl reportObjectModel, ReportRuntimeSetup runtimeSetup)
à Microsoft.ReportingServices.OnDemandProcessing.Merge.Init(Boolean includeParameters, Boolean parametersOnly)
à Microsoft.ReportingServices.OnDemandProcessing.Merge.Init(ParameterInfoCollection parameters)
à Microsoft.ReportingServices.ReportProcessing.Execution.ProcessReportOdp.CreateReportInstance(OnDemandProcessingContext odpContext, OnDemandMetadata odpMetadata, ReportSnapshot reportSnapshot, Merge& odpMerge)
à Microsoft.ReportingServices.ReportProcessing.Execution.ProcessReportOdp.Execute(OnDemandProcessingContext& odpContext)
à Microsoft.ReportingServices.ReportProcessing.Execution.RenderReportOdpInitial.ProcessReport(ProcessingErrorContext errorContext, ExecutionLogContext executionLogContext, UserProfileState& userProfileState)
à Microsoft.ReportingServices.ReportProcessing.Execution.RenderReport.Execute(IRenderingExtension newRenderer)
à Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension newRenderer, DateTime executionTimeStamp, ProcessingContext pc, RenderingContext rc, IChunkFactory yukonCompiledDefinition)
à Microsoft.Reporting.LocalService.Render(String format, String deviceInfo, String paginationMode, Boolean allowInternalRenderers, IEnumerable dataSources, CreateAndRegisterStream createStreamCallback)
à Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMod

What is absolutely weird is:

  • The same PS script running with Reportviewer Runtime 2012 works fine.

  • The PS script running with Reportviewer Runtime 2015 or runtime 2017 get the error. My RDLC report contains some expression e.g: = "xxx" + DateTime.Now. If I remove all the report expressions, the PS script works fine.

I've made a console test program with C# VS2017 that runs exactly the same statements as the PS script. The console app runsfine.
I run the PS script in the same debug folder as the console app and load automatically all the present DLLs :

Microsoft.MSXML.dll
Microsoft.ReportViewer.Common.dll
Microsoft.ReportViewer.Common.resources.dll
Microsoft.ReportViewer.DataVisualization.dll
Microsoft.ReportViewer.DataVisualization.resources.dll
Microsoft.ReportViewer.Design.dll
Microsoft.ReportViewer.Design.resources.dll
Microsoft.ReportViewer.ProcessingObjectModel.dll
Microsoft.ReportViewer.WebDesign.dll
Microsoft.ReportViewer.WebDesign.resources.dll
Microsoft.ReportViewer.WebForms.dll
Microsoft.ReportViewer.WebForms.resources.dll
Microsoft.ReportViewer.WinForms.dll
Microsoft.ReportViewer.WinForms.resources.dll
Microsoft.SqlServer.Types.dll

But still the same error.

I don't want continuing using the VS2013 2012 runtime, because it is to old and is not support by the report bulder designer.

I have no idea of which DLL from Reportviewer.Common could miss. I've try every dll from GAC which depend on, with no succes.

I'm running out of ideas!

Any help much appreciated.

Thank you.


Olivier







windows-server-powershellsql-server-reporting-services
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered

Hi,

Please try updating Microsoft.ReportingServices.ReportViewerControl.WebForms to the latest version.

https://forums.asp.net/t/2162439.aspx?Microsoft+Reporting+RDLC+Report

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OLIVIERSTEINBERG-1132 avatar image
0 Votes"
OLIVIERSTEINBERG-1132 answered OLIVIERSTEINBERG-1132 published

Hi, unfortunately after updating the reportviewer nuget package to the latest version 150.1449.0 I still get the same erorr

I say again, from my C# program it works fine, even with previous reportviewer version.

The problem arise when I run the code from a Powershell script which does strictly the same as the C# program.
What is weird is that Powershell relies on the same dotnet libraries, that I load before render:


 $BasePath = Get-Location
 Get-ChildItem ("$BasePath\*") -Include *.dll | ForEach-Object { 
         #[void]@{rvDll = $_.fullname} 
         @{rvDll = $_.fullname} 
         Add-Type -Path $_.fullname
         #(Get-Command ($_.fullname)).FileVersionInfo.FileVersion
     }
    
 try
 {    
     ForEach ($rvDll in $rvDlls) {    
         # Add assembly DLL                    
         Add-Type -Path ("$BasePath\$rvDll")
     }
     #(Get-Command ($assemblyPath)).FileVersionInfo.FileVersion
 }
 Catch {
     $error[0].Exception.GetBaseException().LoaderExceptions
 }



But if I remove the following expression = "Echéances dues au : " + Format(Now(), "dd/MM/yyyy") from the textbox in the report, the PS script runs fine.

Output from Powershell console:

Exception levéé durant render :
Exception lors de l'appel de « Render » avec « 1 » argument(s) : « Une erreur s'est produite lors du traitement du rapport local. »
à System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
à System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
à System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
à System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception inner :
Une erreur s'est produite lors du traitement du rapport local.
à Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
à Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
à Microsoft.Reporting.WinForms.LocalReport.Render(String format, String deviceInfo, PageCountMode pageCountMode, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
à CallSite.Target(Closure , CallSite , Object , String )
Exception inner inner:
Échec du chargement de l'assembly hôte d'expressions. Détails : Impossible de charger le fichier ou l'assembly 'Microsoft.ReportViewer.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' ou une de ses dépendances. Le fichier spécifié est introuvable.
à Microsoft.ReportingServices.RdlExpressions.ReportRuntime.ProcessLoadingExprHostException(ObjectType assemblyHolderObjectType, Exception e, ProcessingErrorCode errorCode)
à Microsoft.ReportingServices.RdlExpressions.ReportRuntime.LoadCompiledCode(IExpressionHostAssemblyHolder expressionHostAssemblyHolder, Boolean includeParameters, Boolean parametersOnly, ObjectModelImpl reportObjectModel, ReportRuntimeSetup runtimeSetup)
à Microsoft.ReportingServices.OnDemandProcessing.Merge.Init(Boolean includeParameters, Boolean parametersOnly)
à Microsoft.ReportingServices.OnDemandProcessing.Merge.Init(ParameterInfoCollection parameters)
à Microsoft.ReportingServices.ReportProcessing.Execution.ProcessReportOdp.CreateReportInstance(OnDemandProcessingContext odpContext, OnDemandMetadata odpMetadata, ReportSnapshot reportSnapshot, Merge& odpMerge)
à Microsoft.ReportingServices.ReportProcessing.Execution.ProcessReportOdp.Execute(OnDemandProcessingContext& odpContext) à Microsoft.ReportingServices.ReportProcessing.Execution.RenderReportOdpInitial.ProcessReport(ProcessingErrorContext errorContext, ExecutionLogContext executionLogContext, UserProfileState& userP
rofileState)
à Microsoft.ReportingServices.ReportProcessing.Execution.RenderReport.Execute(IRenderingExtension newRenderer)
à Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension newRenderer, DateTime executionTimeStamp, ProcessingContext pc, RenderingContext rc, IChunkFactory yukonCompiledDefinition)
à Microsoft.Reporting.LocalService.CreateSnapshotAndRender(ReportProcessing repProc, IRenderingExtension renderer, ProcessingContext pc, RenderingContext rc, SubreportCallbackHandler subreportHandler, ParameterInfoCollection parameters, DatasourceCredentialsCollection credentials)
à Microsoft.Reporting.LocalService.Render(String format, String deviceInfo, String paginationMode, Boolean allowInternalRenderers, IEnumerable dataSources, CreateAndRegisterStream createStreamCallback)
à Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)


Olivier

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.