Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I developed C# app and I used report viewer to print reports and I used smart assemply to merge all DLL File in an exe file
the app work fine when play from VB.NET but when using smart assemply to merge dll files the app works fine but when trying to print any report error displayed:

"
Error occurred during local report processing
"

i think exe file cant see report file >> how can i solve this problem

What I have tried:

string dt = DateTime.Now.ToShortDateString();

                var traAmount = 54533.77;
                var from_acc = "45646456434";
                var from_name = "Wess hjg Marko";
                var to_acc = "8686783234";
                var to_name = "Sarah";
                var user_name = "Sarah";
                //====================================================

                string tafq = "";
                Hoorof.clsHoorofArabic horof = new Hoorof.clsHoorofArabic();
                if (float.Parse(traAmount.ToString()) > 999999999.99)
                {
                    tafq = "";
                }
                else if (float.Parse(traAmount.ToString()) <= 0)
                {
                    tafq = "";
                }
                else
                {
                    tafq = horof.تحويل_الأرقام_الى_حروف(Convert.ToDecimal(traAmount.ToString()), 2, "جنيه مصري", " قرش", true, true);
                }
                //====================================================
                DateTime x = Convert.ToDateTime(dt);
                ReportParameter p1 = new ReportParameter("dt", x.ToString("yyyy/MM/dd"));
                ReportParameter p2 = new ReportParameter("amt", traAmount.ToString());
                ReportParameter p3 = new ReportParameter("from_name", from_name);
                ReportParameter p4 = new ReportParameter("from_num", from_acc);
                ReportParameter p5 = new ReportParameter("to_num", to_acc);
                ReportParameter p6 = new ReportParameter("to_name", to_name);
                ReportParameter p7 = new ReportParameter("user_nm", user_name);
                ReportParameter p8 = new ReportParameter("amt_tafkit", tafq);

                rep_view.ProcessingMode = ProcessingMode.Local;
                rep_view.LocalReport.DataSources.Clear();
                rep_view.LocalReport.ReportEmbeddedResource = "FCUBS_Remapping_Tool.Transfer_App.rdlc";

                rep_view.LocalReport.SetParameters(p1);
                rep_view.LocalReport.SetParameters(p2);
                rep_view.LocalReport.SetParameters(p3);
                rep_view.LocalReport.SetParameters(p4);
                rep_view.LocalReport.SetParameters(p5);
                rep_view.LocalReport.SetParameters(p6);
                rep_view.LocalReport.SetParameters(p7);
                rep_view.LocalReport.SetParameters(p8);

                rep_view.LocalReport.Refresh();
                rep_view.RefreshReport();
                rep_view.RenderingComplete += new RenderingCompleteEventHandler(Print_Report);`
Posted
Updated 5-Jun-17 2:08am
v2

You need to exclude the problematic method or class from obfuscation.
If I remember well, SmartAssembly offers several methods for merging dll's, you can also try another method.
If that does not work exclude the misbehaving dll from SmartAssembly.
Alternatives are using ILmerge utility or Fody Costura:
Mike Barnett at Microsoft Research[^]
GitHub - Fody/Fody: Extensible tool for weaving .net assemblies[^]

ILmerge example:
C#
ilmerge /target:winexe /out:SelfContainedProgram.exe Program.exe ClassLibrary1.dll ClassLibrary2.dll
Also see: Merging .NET assemblies using ILMerge[^]

----------------------------------------------------------------------------------
Another example which keeps the name of the .exe the same:

Put ILMerge in a folder ILMerge in your solution.

Define a Post-Build event:
On the Project menu, click Properties.
Select the Build Events tab.
In the Post-build event command line box, type your commands

Example:
"$(SolutionDir)\ILMerge\ILMerge.exe" /target:winexe /out:wessam.exe WindowsFormsApplication1.exe Microsoft.ReportViewer.Common.dll Microsoft.ReportViewer.DataVisualization.dll Microsoft.ReportViewer.ProcessingObjectModel.dll Microsoft.ReportViewer.WinForms.dll
DEL WindowsFormsApplication1.exe 
REN wessam.exe WindowsFormsApplication2.exe
----------------------------------------------------------------------------------

I think this article has a solution for your ILMerge problem: Adding DOC, RTF, and OOXML Export Formats to the Microsoft Report Viewer Control[^]
 
Share this answer
 
v8
Comments
weswes88 3-Jun-17 13:43pm    
thank you RickZeeland for replaying
can y help me and tell me how can i use ILmerge to merge report viewer on my exe file
weswes88 3-Jun-17 14:08pm    
i am using this code before but the output file cant open
ilmerge /target:winexe /out:SelfContainedProgram.exe Program.exe ClassLibrary1.dll ClassLibrary2.dll
RickZeeland 3-Jun-17 14:13pm    
No, you have to use the post-build event if you want to do it from Visual Studio.
You have to replace the file names by the names of your files.
weswes88 3-Jun-17 16:02pm    
i used code above in .csproj file like this here
and when save it and reload project this message appear THIS
sorry .. can you tell me how can do this by steps >> i am not do this before .. Mercy
this is my code
<PostBuildEvent>
    if $(ConfigurationName) == Release ("$(SolutionDir)\..\VMS\3rdParty libs\ILMerge\ILMerge.exe" /target:winexe /out:Wessam.exe FCUBS_Remapping_Tool_By_Wessam.exe clsHoorof.dll Microsoft.ReportViewer.Common.dll Microsoft.ReportViewer.WinForms.dll Microsoft.ReportViewer.DataVisualization.dll Microsoft.ReportViewer.ProcessingObjectModel.dll
    DEL FCUBS_Remapping_Tool_By_Wessam.exe
    REN Wessam.exe FCUBS_Remapping_Tool_By_Wessam.exe)
  </PostBuildEvent>
weswes88 3-Jun-17 17:12pm    
is this code is right
"$(SolutionDir)\ILMerge\ILMerge.exe" /target:winexe /out:wessam.exe FCUBS_Remapping_Tool_By_Wessam.exe clsHoorof.dll Microsoft.ReportViewer.Common.dll Microsoft.ReportViewer.DataVisualization.dll Microsoft.ReportViewer.ProcessingObjectModel.dll Microsoft.ReportViewer.WinForms.dll
DEL FCUBS_Remapping_Tool_By_Wessam.exe 
REN wessam.exe FCUBS_Remapping_Tool_By_Wessam.exe

i did strps above and build project after save code
but this error apper when compile app
THIS
Finally got it working, download here: WindowsFormsApplication2[^]
I used Fody Costura, with the normal Microsoft Reportviewer dll's it would not work (wrong reference path probably).
So I installed Microsoft Reportviewer 2010 NuGet packages:
- Microsoft Report Viewer 2010 SP1 Common Libraries
- Microsoft Report Viewer 2010 SP1 Windows Forms

I did not test on a "bare" system where the Reportviewer dll's are not present, but I'm pretty sure it will work.
Let me know if everything works as expected !
 
Share this answer
 
Comments
weswes88 5-Jun-17 12:28pm    
thanks alot mr RickZeeland
you are right the program work well when tring to open it from PC have report viewer on it
but when tring to open it from antoer PC same message appear "Error occurred during local report processing"
can you explain to me the difference between the 2 report viewer and from where you are got it .. and how can we solve this problem
-----------
IMPORTANT NOTE ::
you Must Know mr RickZeeland that EXE file work well When Copy
Microsoft.ReportViewer.Common.dll And Microsoft.ReportViewer.ProcessingObjectModel.dll
beside it

RickZeeland 5-Jun-17 13:03pm    
I don't know exactly what the difference is between the "normal" Microsoft Reportviewer and the NuGet package, but apparently Fody Costura works better with NuGet packages. Although Fody Costura should have less problems with signed libraries than ILMerge. Maybe you can try adding other Microsoft Reportviewer NuGet packages, like 2012 and 2015 until it works on your other PC.
Of course your resulting .exe size will grow a bit :)
weswes88 5-Jun-17 13:10pm    
you Must Know mr RickZeeland that EXE file work well When Copy
Microsoft.ReportViewer.Common.dll And Microsoft.ReportViewer.ProcessingObjectModel.dll
beside it
How Can I Get NutGet Packages 2015
RickZeeland 5-Jun-17 13:26pm    
To get Reportviewer 2015 packages from NuGet, in Visual Studio goto Tools - NuGet Package Manager and search for "Microsoft Reportviewer 2015".
For questions about Fody Costura maybe you can create an "issue" on https://github.com/Fody/Costura, or contact one of the developers, I don't think they have a forum.
weswes88 5-Jun-17 13:39pm    
can i use crystal report instead of report viewer ??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900