views:

666

answers:

2

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?

A: 

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.

John Saunders
right. as I said above, that doesn't work either. creating an instance still gives the same message.Both calling the static methods OR calling it through an instance works fine at the texbox level, just not through a wrapper function in the custom code window.
ericvg
Please show the "instance" code and the error message or exception you received. I find it very hard to believe you'd get the same error, or that you'd get an error saying "Shared" when "Shared" was not the case. Also, I'm not sure but maybe your change to "instance" was not seen, and SSRS was still using the old version.
John Saunders
closing/reopening VS did the trick -- the ide loads the assembly once only, on load. both static and class instances work fine from embdeded code, e.g,:Function TestInstance() as String return Instance.GetString()End FunctionFunction TestStatic() as String return WR.StaticTest.GetString()End Function
ericvg
A: 

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
ericvg