다음을 통해 공유


Accessing Custom Assemblies Through Expressions

Once you have created a custom assembly, made it available to Report Designer or the report server, added the appropriate security policy, and added a reference to your custom assembly in your report definition, you can access the members of the classes in your assembly using report expressions. To refer to custom code in an expression, you must call the member of a class within the assembly. How you do this depends on whether the method is static or instance-based.

Calling Static Members from a Report Definition File

Static members belong to the class or type itself and not to an instantiated object. These members can be accessed by directly calling them from the class. You should use static members to call custom functions in a report whenever possible, because static members perform best. To call a static member, you need to reference it as an expression that takes the form =Namespace.Class.Method.

To call static members

  • To call a static member, set your expression equal to the fully qualified name of the member, which includes the namespace, class name, and member name. The following example calls the ToGBP method, which converts the StandardCost field value from dollars to pounds sterling and displays it in a report:

    =CurrencyConversion.DollarCurrencyConversion.ToGBP(Fields!StandardCost.Value)
    

Important Information Regarding Static Fields and Properties

Currently, all reports are executed in the same application domain. This means that reports with user-specific, static data expose this data to other instances of the same report. This condition might make it possible for the static data of one user to be available to all users currently running a particular report. For this reason, it is highly recommended that you not use static fields or properties in custom assemblies or in the Code element; instead, use instance fields or properties in your reports. Static methods can still be used, because they do not store state or data.

Calling Instance Members from a Report Definition File

If your custom assembly contains instance members that you need to access in a report definition, you must add an instance name for your class to the report. You can add an instance name for a class using the Code tab of the Report Properties dialog. For more information about adding instances of classes to a report, see 식에 사용자 지정 코드 참조 사용(Reporting Services).

To call a static member, you need to reference it as an expression that takes the form =Code*.InstanceName.Method*.

To call instance members

  • To call an instance member of a custom assembly, you must reference the Code keyword followed by the instance name and the method. The following example calls an instance method ToEUR which converts the StandardCost field value from dollars to euros and displays it in a report:

    =Code.m_myDollarCoversion.ToEUR(Fields!StandardCost.Value)
    

참고 항목

관련 자료

Using Custom Assemblies with Reports

도움말 및 정보

SQL Server 2005 지원 받기