calling a C# assembly from a report in reporting services
-
06-07-2019 - |
Question
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:
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.
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?
Solution 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)
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
OTHER TIPS
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.