Folks, after migrating some code that uses
Microsoft.Reporting.WinForms.LocalReport
<http://msdn.microsoft.com/en-us/library/ms255056>  up to Framework 4 I fell
into a security trap. The processing of the RDLC file into a report happens
in a "sandboxed" AppDomain. You wouldn't normally notice this or care, but
if you have custom code in an assembly that helps generate the report then
you might be worried. My code looks up resources and database tables and is
glued to the infrastructure of my app, but now it loads and runs in a new
AppDomain and its lifetime and references are broken.

 

I thought I could use an MarshalByRef class to make proxy calls back to the
primary AppDomain to get the data I want, but I can't find any way of
getting a reference to the primary AppDomain from inside the sandboxed one.
This is the reverse of the usual easy situation where you create the
AppDomain and load an MBR class inside it.

 

I have given-up on the MBR idea and will use a named pipe to allow my
sandboxed code to ask for data from the app in the primary AppDomain. I just
thought I'd mention this whole scenario as a warning to others who might
fall for this trap.

 

Related to this: back in Feb-2011 I asked if anyone had working sample code
to replace the deprecated LocalReport AddTRustedCodeModuleInAppDomain method
and I failed to get replacement code working. I finally found a working
sample HERE <http://devcoma.blogspot.com.au/2010_05_01_archive.html>  (but
there is a bug because the first PermissionState.None needs to be
Unrestricted). Also, your assembly must not use allow partially trusted
callers.

 

Greg

Reply via email to