Thursday, July 10, 2014

Adding custom code or external assembly to Local Reports .RDLC in Visual Studio.NET causes error

Today i was working on console application which is generating automatic notices using .rdlc file. I was adding barcode into each page of dynamic generated N number of pages. which i have decided to accomplish by referencing external assembly which has one function from where i can pass the parameter and it's give me barcode in terms of bytes. but while adding that assembly i got following error.

"Error while loading code module: ‘Neodynamic.SDK.Barcode, Version=4.0.2000.0, Culture=neutral, PublicKeyToken=c6b33c3093a0d4cd’. Details: Could not load file or assembly 'Neodynamic.SDK.Barcode, Version=4.0.2000.0, Culture=neutral, PublicKeyToken=c6b33c3093a0d4cd' or one of its dependencies. The system cannot find the file specified. "

There are lots of options to solve on internet like adding into "private assemblies" folder of visual studio program files, or add localreport.AddTrustedCodeModuleInCurrentAppDomain etc....

but nothing works. finally i got the solution and it's very simple.

To solve, just do following:

Step 1. Add your external assembly into bin directory of your application, in my case, i am using console application so i moved there.

Step 2. Right click on your "xyz.rdlc" file and click on properties and change "Build Action: None" and "Copy to Output Directory: Do not copy".

That's it.
You can run the application and it will generate report smoothly.
some of the screen shots which i would like to share, so you can see and understand it visually as well.





1 comment:

  1. Good morning,
    In my case, I couldn't change the rdlc's "Build Action=Embedded Resource" because we customized the loading process:
    reportAssembly = Assembly.Load(reportAssemblyName);
    var templateStream = reportAssembly.GetManifestResourceStream(reportTemplatePath);

    But, we manage to make it work by setting rdlc's "Copy to Output Directory=Copy if newer".
    I hope it's a good way to do things and it can help!
    Davy

    ReplyDelete

React-select is very slow on larger list - Found solution - using react-window

 I had more than 4000 items in searchable dropdownlist. I have used react-select but it was very slow. finally I found complete solution to ...