views:

472

answers:

1

Hello:

I am designing a report that will be used in local mode (an RDLC file) in a Winform app. I have a custom assembly with a static class that has some functions that I want to use inside of the report (as expressions).

I have found all sorts of help for doing this with RDL reports, but I'm running into a permissions problem with my RDLC report.

I get the following error at runtime: "The report references the code module (my module), which is not a trusted assembly".

I know that this is some kind of a code security issue, but I'm not sure what to do to fix it. The documentation that I have seen online is aimed at RDL reports, and it instructs me to edit a SQL Server-specific policy file. I'm using RDLC, so there is no sql server involved. What do I need to do to acquire the appropriate permissions?

+3  A: 

Try using the AddTrustedCodeModuleInCurrentAppDomain method of the ReportViewer.LocalReport Property (reportViewer.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("your assembly")).

Also make sure you use the AllowPartiallyTrustedCallers attribute with your assembly ([assembly:AllowPartiallyTrustedCallers]).

kzen
That was the trick! I had the AllowPartiallyTrustedCallers, but I missed the call to AddTrustedCodeModuleInCurrentAppDomain. Incidentally, that method has been deprecated for .Net 4.0, and there is a new method for doing it. Thanks for the help!
JMarsch