【问题标题】:Custom Assembly for SSRS 2008SSRS 2008 的定制组装
【发布时间】:2011-05-09 19:00:26
【问题描述】:

我正在尝试将我在多个报告中的嵌入式代码整合到一个自定义程序集中。我在 VS 2008 中创建了一个名为 BalancingReportsLibrary 的 C# 库项目。这是我库中的代码:

使用系统; 使用 System.Collections.Generic; 使用 System.Linq; 使用 System.Text;

命名空间 BalancingReportsLibrary { 公共类平衡 { 公共字符串 ComingledPounds(字符串 CoPounds) { if (CoPounds == null || CoPounds == "") { 返回 ””; }

        //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;

    }

我已构建此解决方案并将 DLL 放置在此路径中: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies

我创建了一个带有报告的报告项目。在 Report>Properties>References 下,我在程序集下选择了我的 DLL。我在表单上有一个引用类的文本框,如下所示: =BalancingReportsLibrary.Balancing.ComingledPounds(LAST(Fields!ComingledGroup.Value))

我在尝试预览报告时收到以下错误: “表达式的值失败。对非共享成员的引用需要对象引用。”

我该如何解决这个问题?

【问题讨论】:

    标签: ssrs-2008


    【解决方案1】:

    如果您实际上不需要实例化 Balancing 类,而只是想调用 ComingledPounds 方法,则将其设为静态,如下所示:

    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;
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2012-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-05
      • 1970-01-01
      • 1970-01-01
      • 2011-04-18
      相关资源
      最近更新 更多