More custom code questions

I've been through Brian Likes's custom code blog entries and I can get code to work but only the easiest of examples. I'm using a local report rather than SQL reporting services so I think that a custom assembly might be easier in my case, and hopefully the deployment code (likely ClickOnce) will understand that there is a referenced assembly.

But using a custom assembly or even just local code, I can get Hello World to work but I can't figure out how to pass the report variables such as Field!MyPerson.Value to the code in order to do anything useful. If anyone has a suggestion as the the passing mechanism I would greatly appreciate an example. I'm getting a compile error about an instance requiring an object reference. I declared my function (in local code) as shared and it still happens so any idea what is occurring would be greatly appreciated.

Thanks.



Answer this question

More custom code questions

  • Knight99

    Thanks. Glad to know that old threads never die. I'll give it a try.
  • Terry7

    Long Xue, do you have a project you could post somewhere so I could see some working code Thanks!

  • n0n4m3

    Step 1. Put your assembly to GAC ( I've tried /Bin, it didn't work ).

    Step 2. Add the reference to Report Properties' References, add the class name you want to use, and add a instance name ( say the instance is myClass ). ( class WITHOUT parameters works for sure, I couldn't figure how to make the class WITH parameters work )

    Step 3. Under the Code tab, make a function in VB, in the function, you can assign parameters. Say you have:

    Public Function GetMyString(ByVal _string As String) As String

    myClass .SetSomething(_string)

    Return myClass .SomeStringPropertity

    End Function

    Then you can pass your parameter like this:

    Code.GetMyString(Field!MyPerson.Value.ToString())

    Hope that helps,

    Good Luck,

    Long


  • Bill Miller

    Code magazine has a good article on it this month:

    http://www.code-magazine.com/Article.aspx quickid=0701061


  • More custom code questions