Metoda LocalReport.AddTrustedCodeModuleInCurrentAppDomain —
Uwaga: ten interfejs API jest teraz nieaktualny.
Adds the supplied assembly to the list of assemblies that are trusted to execute in the current AppDomain.
Przestrzeń nazw: Microsoft.Reporting.WebForms
Zestaw: Microsoft.ReportViewer.WebForms (w Microsoft.ReportViewer.WebForms.dll)
Składnia
'Deklaracja
<ObsoleteAttribute("This method requires Code Access Security policy, which is deprecated. For more information please go to https://go.microsoft.com/fwlink/?LinkId=160787.")> _
Public Sub AddTrustedCodeModuleInCurrentAppDomain ( _
assemblyName As String _
)
[ObsoleteAttribute("This method requires Code Access Security policy, which is deprecated. For more information please go to https://go.microsoft.com/fwlink/?LinkId=160787.")]
public void AddTrustedCodeModuleInCurrentAppDomain(
string assemblyName
)
[ObsoleteAttribute(L"This method requires Code Access Security policy, which is deprecated. For more information please go to https://go.microsoft.com/fwlink/?LinkId=160787.")]
public:
void AddTrustedCodeModuleInCurrentAppDomain(
String^ assemblyName
)
[<ObsoleteAttribute("This method requires Code Access Security policy, which is deprecated. For more information please go to https://go.microsoft.com/fwlink/?LinkId=160787.")>]
member AddTrustedCodeModuleInCurrentAppDomain :
assemblyName:string -> unit
public function AddTrustedCodeModuleInCurrentAppDomain(
assemblyName : String
)
Parametry
- assemblyName
Typ: String
The name of the assembly to be added.
Uwagi
![]() |
---|
This method is deprecated for .NET Framework 4 because the code access security (CAS) feature it relies on is deprecated in .NET Framework 4.Instead, the ReportViewer control always executes in the sandboxed application domain.You should use AddFullTrustModuleInSandboxAppDomain and SetBasePermissionsForSandboxAppDomain.If you want to continue to use this method with .NET Framework 4, you must use the <NetFx40_LegacySecurityPolicy> configuration element in the Web.config file of your ASP.NET application.Otherwise, this method will throw an InvalidOperationException. This method will continue to work with .NET Framework 3.5. Aby uzyskać więcej informacji, zobacz Zgodność i migracja zasad zabezpieczenia dostępu kodu. |
Expressions in the report will be executed in the current AppDomain with only the Execution security permission flag.By default, custom assemblies are not allowed in this mode.The AddTrustedCodeModuleInCurrentAppDomain method can be used to allow the use of custom assemblies in the current AppDomain.
The name of the assembly passed in the assemblyName parameter should match that specified in the CodeModule element of the report definition file.
Przykłady
In this example, a custom assembly containing a simple utility function that calculates factorials is used as an expression in a report.
public class Util
{
public static int Factorial(int n)
{
return ((n <= 1) ? 1 : (n * Factorial(n - 1)));
}
}
The following code is used to add the custom assembly to the current AppDomain.
reportViewer.LocalReport.ReportPath = "Report1.rdlc";
reportViewer.LocalReport.AddTrustedCodeModuleInCurrentAppDomain(
"Contoso.Utilities,
Version=1.0.271.0, Culture=neutral,
PublicKeyToken=89012dab8080cc90");
For more information on custom assemblies, see "Using Custom Assemblies with Reports" in the SQL Server Books Online.