Error while loading code module srsresources

Error:

Error while loading code module srsresources
Error while loading code module: 'MyDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Details: Could not load file or assembly 'MyDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Resolution:

If you use custom DLL in your SSRS reports, make sure the DLL is copied over to the shared DLL folder.

For VS2017 Community Edition, copy over the DLL to this folder…

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\SSRS

Other Locations:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\SSRS
C:\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\bin

Sources:

https://stackoverflow.com/questions/43520437/ssrs-custom-assemblies-could-not-be-loaded-under-visual-studio-2017

J O

I do not have it in the GAC right now. In code I have assigned all permissions and also the asp.net account has full permission (it is a DNN application). I have also have added allowpartialtrusted...blahah to the assembly, granted file i/o permissions...I really do not get it. I have next code:

public class ReportControlBase
{
protected ReportViewer _reportViewer;
protected DataSet _reportDataSet;
//protected string _filePathOfOutputFile;
public ReportControlBase(DataSet reportDataSet, string reportRDLCFileName, string userLocale, string regionLocale, string outputFile)
{
_reportDataSet = reportDataSet;

_reportViewer = new ReportViewer ();

_reportViewer.ProcessingMode = ProcessingMode.Local;
_reportViewer.LocalReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence);

_reportViewer.LocalReport.DisplayName = "#V4A";// clsConversions.DateTimeToStringUTCNoSeparatorSymbols (DateTime.Now);
_reportViewer.LocalReport.ReportPath = reportRDLCFileName;

//Not needed probably.
_reportViewer.ShowBackButton = false;
_reportViewer.ShowDocumentMapButton = false;
_reportViewer.ShowExportControls = false;
_reportViewer.ShowFindControls = false;
_reportViewer.ShowPageNavigationControls = false;
_reportViewer.ShowParameterPrompts = false;
_reportViewer.ShowRefreshButton = false;
_reportViewer.ShowToolBar = false;

//FileIOPermission fileReadPerm = new FileIOPermission(FileIOPermissionAccess.Read, reportRDLCFileName);
//fileReadPerm.Assert();

string strCustomAssemblyPath = System.IO.Directory.GetCurrentDirectory() + @"\V4A.DNN.Modules.Store.PaymentGateway.Reports.Resources.dll";
FileIOPermission filePerm = new FileIOPermission(FileIOPermissionAccess.AllAccess, strCustomAssemblyPath);
filePerm.Assert();

//_reportViewer.LocalReport.AddTrustedCodeModuleInCurrentAppDomain(typeof(V4A.DNN.Modules.Store.Components.Reports.Resources.OrderLocalization).FullName);
_reportViewer.LocalReport.AddTrustedCodeModuleInCurrentAppDomain(typeof(V4A.DNN.Modules.Store.Components.Reports.Resources.OrderLocalization).Assembly.FullName);
_reportViewer.LocalReport.AddTrustedCodeModuleInCurrentAppDomain(System.Reflection.Assembly.GetAssembly(typeof(System.Security.Permissions.FileIOPermission)).FullName);

_reportViewer.ShowRefreshButton = false;
_reportViewer.LocalReport.EnableHyperlinks = true;

System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(userLocale);

//set default parameters.
ReportParameter[] reportParameters = new ReportParameter[2];
reportParameters[0] = new ReportParameter(ModuleConstants.Par + ModuleConstants.RegionLocale, regionLocale);
reportParameters[1] = new ReportParameter(ModuleConstants.Par + ModuleConstants.UserLocale, userLocale);

if (reportParameters != null)
{
_reportViewer.LocalReport.SetParameters(reportParameters);
}

////Report page settings.
//ReportPageSettings _reportPageSettings = this.Viewer.LocalReport.GetDefaultPageSettings();
////_reportPageSettings.Margins.Bottom = '0.5';
////_reportPageSettings.Margins.Left = 0.5;
////_reportPageSettings.Margins.Right= 0.5;
////_reportPageSettings.Margins.Top = 0.5;
//_reportPageSettings.PaperSize.RawKind = (int) System.Drawing.Printing.PaperKind.A4Rotated;

//Load actual data
_reportViewer.LocalReport.DataSources.Clear();
foreach (System.Data.DataTable dataTable in _reportDataSet.Tables)
{
_reportViewer.LocalReport.DataSources.Add(
new ReportDataSource (_reportDataSet.DataSetName + "_" + dataTable.TableName, dataTable));
}

_reportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);

//http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=241256&SiteID=1

Warning[] warnings = null;
string[] streams = null;
string mimeType = null;
string encoding = null;
string fileNameExtension = null;

byte[] bytes = _reportViewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

//outputFile += "test.pdf";
FileStream fs = new FileStream (outputFile, FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close ();

}
//public string FilePathOfOutputFile
//{
// get { return _filePathOfOutputFile; }
//}
void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
foreach (System.Data.DataTable dataTable in _reportDataSet.Tables)
{
e.DataSources.Add(new ReportDataSource(_reportDataSet.DataSetName + "_" + dataTable.TableName, dataTable));
}
}