Monday, February 20, 2012

Pasing parameter-value to method in .dll

Hello,
I have a class in a .dll wich I instantiate in reporting services on
the References tab. The instance is called "Myinstance". I also have a
parameter called "parm1".
>From custom code I have:
Protected Overrides Sub OnInit()
MyInstance.company(Parameters!parm1.value)
End Sub
The method company is declared "public void company(string _company)".
My problem is, that I get the error:
"... The definition of the report "/MyReport" is invalid. There is an
error on line 1 of custom code: [BC30469] Reference to a non-shared
member requires an object reference."
If, in custom code, I hard-code the parameter to the method company
instead of trying to get it from a parameter, it works, so it look as
if I try to access the parameter-value before the parameter is
available or I'm accessing the parameter in a wrong way.
I need to pass the value of the parameter "parm1" to a method
"company(string _company)" before the report is build, as fields in
the report will call other functions in the .dll and what they return
depends on the value of "parm1" passed to the method "company".
So, any suggestion? What am I doing wrong?
Thanks in advance
/PeterHey Peter.
Add a variable to your assembly call such as:
Protected Overrides Sub OnInit(parm1 as string)
MyInstance.company(Parameters!parm1.value)
End Sub
Then call you custom code like:
=code.oninit(parameters!parm1.value)
Michael
"Peter" wrote:
> Hello,
> I have a class in a .dll wich I instantiate in reporting services on
> the References tab. The instance is called "Myinstance". I also have a
> parameter called "parm1".
> >From custom code I have:
> Protected Overrides Sub OnInit()
> MyInstance.company(Parameters!parm1.value)
> End Sub
> The method company is declared "public void company(string _company)".
> My problem is, that I get the error:
> "... The definition of the report "/MyReport" is invalid. There is an
> error on line 1 of custom code: [BC30469] Reference to a non-shared
> member requires an object reference."
> If, in custom code, I hard-code the parameter to the method company
> instead of trying to get it from a parameter, it works, so it look as
> if I try to access the parameter-value before the parameter is
> available or I'm accessing the parameter in a wrong way.
> I need to pass the value of the parameter "parm1" to a method
> "company(string _company)" before the report is build, as fields in
> the report will call other functions in the .dll and what they return
> depends on the value of "parm1" passed to the method "company".
> So, any suggestion? What am I doing wrong?
> Thanks in advance
> /Peter
>|||Oops one small change
"Michael C" wrote:
Protected Overrides Sub OnInit(parm1 as string)
MyInstance.company(parm1)
End Sub
Michael
> Hey Peter.
> Add a variable to your assembly call such as:
> Protected Overrides Sub OnInit(parm1 as string)
> MyInstance.company(Parameters!parm1.value)
> End Sub
> Then call you custom code like:
> =code.oninit(parameters!parm1.value)
> Michael
> "Peter" wrote:
> > Hello,
> >
> > I have a class in a .dll wich I instantiate in reporting services on
> > the References tab. The instance is called "Myinstance". I also have a
> > parameter called "parm1".
> >
> > >From custom code I have:
> >
> > Protected Overrides Sub OnInit()
> > MyInstance.company(Parameters!parm1.value)
> > End Sub
> >
> > The method company is declared "public void company(string _company)".
> >
> > My problem is, that I get the error:
> >
> > "... The definition of the report "/MyReport" is invalid. There is an
> > error on line 1 of custom code: [BC30469] Reference to a non-shared
> > member requires an object reference."
> >
> > If, in custom code, I hard-code the parameter to the method company
> > instead of trying to get it from a parameter, it works, so it look as
> > if I try to access the parameter-value before the parameter is
> > available or I'm accessing the parameter in a wrong way.
> >
> > I need to pass the value of the parameter "parm1" to a method
> > "company(string _company)" before the report is build, as fields in
> > the report will call other functions in the .dll and what they return
> > depends on the value of "parm1" passed to the method "company".
> >
> > So, any suggestion? What am I doing wrong?
> >
> > Thanks in advance
> > /Peter
> >
> >|||On 19 Jul., 18:20, Michael C <Micha...@.discussions.microsoft.com>
wrote:
> Oops one small change
> "Michael C" wrote:
> Protected Overrides Sub OnInit(parm1 as string)
> MyInstance.company(parm1)
> End Sub
> Michael
>
> > Hey Peter.
> > Add a variable to your assembly call such as:
> > Protected Overrides Sub OnInit(parm1 as string)
> > MyInstance.company(Parameters!parm1.value)
> > End Sub
> > Then call you custom code like:
> > =code.oninit(parameters!parm1.value)
> > Michael
> > "Peter" wrote:
> > > Hello,
> > > I have a class in a .dll wich I instantiate in reporting services on
> > > the References tab. The instance is called "Myinstance". I also have a
> > > parameter called "parm1".
> > > >From custom code I have:
> > > Protected Overrides Sub OnInit()
> > > MyInstance.company(Parameters!parm1.value)
> > > End Sub
> > > The method company is declared "public void company(string _company)".
> > > My problem is, that I get the error:
> > > "... The definition of the report "/MyReport" is invalid. There is an
> > > error on line 1 of custom code: [BC30469] Reference to a non-shared
> > > member requires an object reference."
> > > If, in custom code, I hard-code the parameter to the method company
> > > instead of trying to get it from a parameter, it works, so it look as
> > > if I try to access the parameter-value before the parameter is
> > > available or I'm accessing the parameter in a wrong way.
> > > I need to pass the value of the parameter "parm1" to a method
> > > "company(string _company)" before the report is build, as fields in
> > > the report will call other functions in the .dll and what they return
> > > depends on the value of "parm1" passed to the method "company".
> > > So, any suggestion? What am I doing wrong?
> > > Thanks in advance
> > > /Peter
Hello Michael,
Thanks for your reply.
There are two issues:
1) I forgot to mention, that pam1 gets its values from a query, so I
cannot call my custom code as "=code.oninit(parameters!parm1.value)"
2) When I tried the custom code in your message, I got this error:
"... There is an error on line 0 of custom code: [BC30284] sub
'OnInit' cannot be declared 'Overrides' because it does not override a
sub in a base class."
What should I do from here ?
Thanks
/Peter|||hey Peter,
Well ...
1) The "Parmameter!Parm1.Value" could be "Fields!MyField.value", or if it is
not generated from the dataset that drives the report (i.e. a secondary
query) then you can use First(Fields!MyField.Value,"MyParmQuery")
2) I haven't worked with Overrides, are you required to have 'Protected
Overrides' in the call, or can you simply state Protected Sub
OnInit(strParm1) or even Public Sub OnInit?
Michael
"Peter" wrote:
> On 19 Jul., 18:20, Michael C <Micha...@.discussions.microsoft.com>
> wrote:
> > Oops one small change
> >
> > "Michael C" wrote:
> >
> > Protected Overrides Sub OnInit(parm1 as string)
> > MyInstance.company(parm1)
> > End Sub
> >
> > Michael
> >
> >
> >
> > > Hey Peter.
> >
> > > Add a variable to your assembly call such as:
> >
> > > Protected Overrides Sub OnInit(parm1 as string)
> > > MyInstance.company(Parameters!parm1.value)
> > > End Sub
> >
> > > Then call you custom code like:
> >
> > > =code.oninit(parameters!parm1.value)
> >
> > > Michael
> >
> > > "Peter" wrote:
> >
> > > > Hello,
> >
> > > > I have a class in a .dll wich I instantiate in reporting services on
> > > > the References tab. The instance is called "Myinstance". I also have a
> > > > parameter called "parm1".
> >
> > > > >From custom code I have:
> >
> > > > Protected Overrides Sub OnInit()
> > > > MyInstance.company(Parameters!parm1.value)
> > > > End Sub
> >
> > > > The method company is declared "public void company(string _company)".
> >
> > > > My problem is, that I get the error:
> >
> > > > "... The definition of the report "/MyReport" is invalid. There is an
> > > > error on line 1 of custom code: [BC30469] Reference to a non-shared
> > > > member requires an object reference."
> >
> > > > If, in custom code, I hard-code the parameter to the method company
> > > > instead of trying to get it from a parameter, it works, so it look as
> > > > if I try to access the parameter-value before the parameter is
> > > > available or I'm accessing the parameter in a wrong way.
> >
> > > > I need to pass the value of the parameter "parm1" to a method
> > > > "company(string _company)" before the report is build, as fields in
> > > > the report will call other functions in the .dll and what they return
> > > > depends on the value of "parm1" passed to the method "company".
> >
> > > > So, any suggestion? What am I doing wrong?
> >
> > > > Thanks in advance
> > > > /Peter
> Hello Michael,
> Thanks for your reply.
> There are two issues:
> 1) I forgot to mention, that pam1 gets its values from a query, so I
> cannot call my custom code as "=code.oninit(parameters!parm1.value)"
> 2) When I tried the custom code in your message, I got this error:
> "... There is an error on line 0 of custom code: [BC30284] sub
> 'OnInit' cannot be declared 'Overrides' because it does not override a
> sub in a base class."
> What should I do from here ?
> Thanks
> /Peter
>|||On 20 Jul., 18:56, Michael C <Micha...@.discussions.microsoft.com>
wrote:
> hey Peter,
> Well ...
> 1) The "Parmameter!Parm1.Value" could be "Fields!MyField.value", or if it is
> not generated from the dataset that drives the report (i.e. a secondary
> query) then you can use First(Fields!MyField.Value,"MyParmQuery")
> 2) I haven't worked with Overrides, are you required to have 'Protected
> Overrides' in the call, or can you simply state Protected Sub
> OnInit(strParm1) or even Public Sub OnInit?
> Michael
Thanks again Michael,
I have to declared it 'Protected' otherwise it will complain that I
use a different access level.
If I declared it Protected Overrides Sub OnInit(DataArea As String),
that is, with one parameter, I get the error:
sub 'OnInit' cannot be declared 'Overrides' because it does not
override a sub in a base class.
If I declare it without any parameters as Protected Overrides Sub
OnInit(), I get the error
Reference to a non-shared member requires an object reference
If I declare it without 'Overrides' (with and without a parameter) I
get the error
Reference to a non-shared member requires an object reference
So I'm stuck again. I need to use a function that is executed before
the report is generated. I need it to call a method i my .dll with an
argument which is based on a selection from a parameter which in turn
is based on a dataset.
What should I try from here?
Thanks
/Peter

No comments:

Post a Comment