从报告服务中的报告中调用C#程序集

时间:2021-11-11 07:41:54

I added a reference to a custom assembly in a report services (2008) report. It works great when I call from a textbox (e.g, =Assembly.Class.Function() ), but when I wrap it in a custom code block:

我在report services(2008)报告中添加了对自定义程序集的引用。当我从文本框(例如,= Assembly.Class.Function())调用时,它工作得很好,但当我将它包装在自定义代码块中时:

Function GetString(ByVal key as String) as String

return Willow.Reporting.Localization.Resource.Get(User!Language, "WAR", "Title", key)

end function

I get the build error "Reference to a non-shared member requires an object reference.".

我得到构建错误“对非共享成员的引用需要对象引用。”。

The C# class and functions are static.

C#类和函数是静态的。

as a test, I also created a non-static vrsion of the class, created an instance, and accessed it through the instance name in the custom code, but no luck either.

作为测试,我还创建了一个类的非静态版本,创建了一个实例,并通过自定义代码中的实例名称访问它,但也没有运气。

is it possible to call a custom assembly from the code block in reporting services?

是否可以从报告服务中的代码块调用自定义程序集?

2 个解决方案

#1


Perhaps you're a C# programmer? "Shared" in VB means static. The message means you need to create an instance of the class in order to call an (instance) method of the class.

也许你是C#程序员? VB中的“共享”意味着静态。该消息意味着您需要创建该类的实例才能调用该类的(实例)方法。

#2


the VS IDE loads the assembly only once, on load -- so you have to close/reopen VS each time you make an assembly change (removing the reference and resetting didn't work either)

VS IDE仅在加载时加载程序集一次 - 因此每次进行程序集更改时都必须关闭/重新打开VS(删除引用并重置也不起作用)

you can use both static calls and instance methods too and it works fine from embeded code, e.g,:

你也可以同时使用静态调用和实例方法,它可以从嵌入代码中正常工作,例如:

Function Test() as String
    return Instance.GetString()
End Function

Function Test2() as String
    return WR.StaticTest.GetString()
End Function

#1


Perhaps you're a C# programmer? "Shared" in VB means static. The message means you need to create an instance of the class in order to call an (instance) method of the class.

也许你是C#程序员? VB中的“共享”意味着静态。该消息意味着您需要创建该类的实例才能调用该类的(实例)方法。

#2


the VS IDE loads the assembly only once, on load -- so you have to close/reopen VS each time you make an assembly change (removing the reference and resetting didn't work either)

VS IDE仅在加载时加载程序集一次 - 因此每次进行程序集更改时都必须关闭/重新打开VS(删除引用并重置也不起作用)

you can use both static calls and instance methods too and it works fine from embeded code, e.g,:

你也可以同时使用静态调用和实例方法,它可以从嵌入代码中正常工作,例如:

Function Test() as String
    return Instance.GetString()
End Function

Function Test2() as String
    return WR.StaticTest.GetString()
End Function