开发者

Custom Assembly for SSRS 2008

I am trying to consolidate my embedded code across multiple reports into a custom assembly. I created a C# Library project in VS 2008 called BalancingReportsLibrary. Here is the code in my library:

using System; using System.Collections.Generic; us开发者_开发技巧ing System.Linq; using System.Text;

namespace BalancingReportsLibrary { public class Balancing { public string ComingledPounds(string CoPounds) { if (CoPounds == null || CoPounds == "") { return ""; }

        //Column One
        int index = CoPounds.IndexOf(";");
        int length = CoPounds.Length;

        if (index > 0)
        {
            string CoPounds1 = CoPounds.Substring(0, index);
            return CoPounds1;
        }

        //There was just one comingled pound, so just return the value that was passed in
        return CoPounds;

    }

I have built this solution and place the DLL in this path: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies

I created a report project with a report. Under Report>Properties>References, I selected my DLL under assemblies. I have a text box on the form that references the class like so: =BalancingReportsLibrary.Balancing.ComingledPounds(LAST(Fields!ComingledGroup.Value))

I get the following error when I try to preview the report: "Value for the expression failed. Reference to a non-shared member requires an object reference."

How can I resolve this issue?


If you don't actually need to instantiate your Balancing class, but just want to call the ComingledPounds method then make it static like this:

namespace BalancingReportsLibrary 
{ 
    public class Balancing 
    {
        public static string ComingledPounds(string CoPounds) 
        {
            if (CoPounds == null || CoPounds == "") 
                return "";

            //Column One
            int index = CoPounds.IndexOf(";");
            int length = CoPounds.Length;

            if (index > 0) {
                string CoPounds1 = CoPounds.Substring(0, index);
                return CoPounds1;
            }

            //There was just one comingled pound, so just return the value that was passed in
            return CoPounds;
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜