views:

27

answers:

1

Would like to know if methods need to be static in a C# assemble to be access from SSRS?

+1  A: 

No, you can use both public methods and static methods in a c# class library and reference them from your SSRS report.

You do need to add static methods in a different way than your public instance methods though. You should check out this MS article on custom code use in SSRS. Here is the gist of how to add a static method:

The Classes section is only for instance-based members. It is not for static members. Static (also referred to as "shared" in some of our Reporting Services documentation) means that the member is available to every instance of the class and every instance uses the same storage location. Static members are declared by using the shared keyword in Microsoft Visual Basic and the static keyword in C#. This can be a bit confusing. What this means is, if your custom assembly contains instance members that you need to access, you will have to specify the class name and instance name in the Classes section. Because the method I will be calling from Reporting Services was defined as static by using the shared keyword in Visual Basic, I'll use the References section instead of the Classes section.

So, if you want to do an instance method, make sure to add the refrence, but also specify a "Class" and "Instance name" in the Classes section of Report Properties for every method you need. Then call them using an expression of =Code. Like so:

=Code.InstanceName.Method

Hope that will help you out.

Tj Kellie
This is on the right track for me, but article talks mainly about static methods and I need to implement instance-based members. can't seem to find any info on instance-based members.
BillTetrault
Missing something namespace MyTest { public class MyGetInfo { public string GetInfo() { return "Hello, World!"; } } } Under Report Properties [Tab] References which is [Class Name] and [Instance Name] think I tried all combinations but does not build clean
BillTetrault

related questions