Folks, while building a new release I noticed the method
LocalReport.AddTrustedCodeModuleInCurrentAppDomain(string) is obsolete, so I
decided to try and replace it with modern code according to various
recommendations on web sites. The advice and sample code is slightly
contradictory, but I tried dozens of combinations to find the best one that
works. After two hours of suffering (what a surprise!!) I find that nothing
works. My simplest code looks like the following:
 
PermissionSet permissions = new PermissionSet(PermissionState.Unrestricted);
locrep.SetBasePermissionsForSandboxAppDomain(permissions);
AssemblyName an =
typeof(MyCompany.Myproduct.ReportCustom.Class1).Assembly.GetName();
byte[] pkblob = an.GetPublicKeyToken();
StrongName sn = new StrongName(new StrongNamePublicKeyBlob(pkblob), an.Name,
an.Version);
locrep.AddFullTrustModuleInSandboxAppDomain(sn);
 

I tried different combinations of Permissions, but absolutely nothing I do
makes any difference and all I get at runtime is "The report references the
code module X which is not a trusted assembly". I had to back out and revert
to the deprecated method and it all works.

 

Has anyone been through this problem and got it to work? What is your code?
These projects are in Framework 3.5.

 

Greg

 

-- "Everything doesn't work"

Reply via email to