The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

sachinladdha (24) [Avatar] Offline
I have written a report whose OnInit() calls a custom assembly code.
Following error is thrown by report manager application when I try to view the report.

An error occurred while executing OnInit: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. (rsErrorInOnInit) .

The assembly is registered in policy file with 'FullTrust' persmission. The assembly is not signed and is registered using Url.

The same report (and same assembly) works well with RS 2000.
One behaviour that I observed is: View a report which is NOT having OnInit() on RS 2005. The report gets rendered properly. Then click on a report having OnInit() then this report ALSO works properly. If I first click on a report having OnInit() then I get above error.

Please help.
manoj_chaudhari (12) [Avatar] Offline
Re: MSRS 2005, getting error in OnInit()
added following assembly info tag to the custom assembly [assembly: AllowPartiallyTrustedCallers].

Here are the excerpts from the article that I found after goggling out which tells the reason why this needs to be done.

“Mark the custom assembly with the AllowPartiallyTrustedCallersAttribute. This is required because custom assemblies are called from a report expression that is a part of the report expression host assembly, which by default is not granted FullTrust, thus is a 'partially trusted' caller. You can do this in your assembly attribute file AssemblyInfo.cs in C# before doing this add.”

For more information here is the