Friday, February 17, 2012

Custom assembly call in footer looses property values.

Custom assembly call in footer looses property values.
I have a custom assembly that uses a method in the body to pass in a data
field. When I fetch the data in the body I get my data back. When I do the
same in the footer I don't get any data. I have an active call in with
Microsoft so will also post there. I thought
we had working code, I was declaring the module scoped variable as static,
but that ends up with other peoples data on occassion when several people
are running reports. MS Support told me don't use static variables, but if
I don't then I can't access my properties in the footer.
I built a sample report and custom assembly to try to figure this out.
In the report I have something like this:
Body:
=Code.DataInFooter_NonStatic.ExpSet_MyData(First(Fields!LoginID.Value))
=Code.DataInFooter_NonStatic.MyData()
Footer:
=Code.DataInFooter_NonStatic.MyData()
What is displayed:
Body:
expected value
Footer:
empty and this is the problem.
Is it an execution order issue?
Here's my sample code:
using System;
using System.Collections.Generic;
using System.Text;
namespace DataInFooter_NonStatic
{
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Assert,
Unrestricted = true)]
public class DataInFooter_NonStatic
{
private string _MyData;
public string MyData
{
get
{
return _MyData;
}
set
{
_MyData = MyData;
}
}
public void WriteToFile(string Input)
{
//throw new System.NotImplementedException();
}
public string ExpSet_MyData(string Input)
{
_MyData = Input;
return _MyData;
}
}
}
Steve MunLeeuwDo this instead in your footer:
for the field that is displaying originally the
"=code.DataInFooter_NonStatic.MyData()" have it point to the
ReportItems!<name of control in body>.Value i.e. ReportItems!TextBox17.Value
(where textbox 17 in the body contains your call to
"=Code.DataInFooter_NonStatic.MyData()"
=-Chris
"Steve MunLeeuw" <smunson@.clearwire.net> wrote in message
news:Opk5KuF9GHA.5092@.TK2MSFTNGP04.phx.gbl...
> Custom assembly call in footer looses property values.
> I have a custom assembly that uses a method in the body to pass in a data
> field. When I fetch the data in the body I get my data back. When I do
> the
> same in the footer I don't get any data. I have an active call in with
> Microsoft so will also post there. I thought
> we had working code, I was declaring the module scoped variable as static,
> but that ends up with other peoples data on occassion when several people
> are running reports. MS Support told me don't use static variables, but
> if I don't then I can't access my properties in the footer.
> I built a sample report and custom assembly to try to figure this out.
> In the report I have something like this:
> Body:
> =Code.DataInFooter_NonStatic.ExpSet_MyData(First(Fields!LoginID.Value))
> =Code.DataInFooter_NonStatic.MyData()
> Footer:
> =Code.DataInFooter_NonStatic.MyData()
> What is displayed:
> Body:
> expected value
> Footer:
> empty and this is the problem.
> Is it an execution order issue?
> Here's my sample code:
> using System;
> using System.Collections.Generic;
> using System.Text;
> namespace DataInFooter_NonStatic
> {
> [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Assert,
> Unrestricted = true)]
> public class DataInFooter_NonStatic
> {
> private string _MyData;
> public string MyData
> {
> get
> {
> return _MyData;
> }
> set
> {
> _MyData = MyData;
> }
> }
> public void WriteToFile(string Input)
> {
> //throw new System.NotImplementedException();
> }
> public string ExpSet_MyData(string Input)
> {
> _MyData = Input;
> return _MyData;
> }
> }
> }
> Steve MunLeeuw
>|||Ok, thanks I will try that.
I think this causes and exception when you try to access the ReportItems
collection in a footer when the page doesn't have any data fields. For
example if you have a page in the middle of the report that has static text
in a textbox that spans a full page then there are no data rows in the page
and accessing the ReportItems causes the report to fail. Either that or the
ReportItem!MyHiddenFooterData.Value would not show up for that page in
PDF...or something like that. I'll try and experiment around.
Steve MunLeeuw
"Chris Conner" <Chris.Conner@.NOSPAMPolarisLibrary.com> wrote in message
news:u7HPquG9GHA.1492@.TK2MSFTNGP02.phx.gbl...
> Do this instead in your footer:
> for the field that is displaying originally the
> "=code.DataInFooter_NonStatic.MyData()" have it point to the
> ReportItems!<name of control in body>.Value i.e.
> ReportItems!TextBox17.Value (where textbox 17 in the body contains your
> call to "=Code.DataInFooter_NonStatic.MyData()"
> =-Chris
> "Steve MunLeeuw" <smunson@.clearwire.net> wrote in message
> news:Opk5KuF9GHA.5092@.TK2MSFTNGP04.phx.gbl...
>> Custom assembly call in footer looses property values.
>> I have a custom assembly that uses a method in the body to pass in a data
>> field. When I fetch the data in the body I get my data back. When I do
>> the
>> same in the footer I don't get any data. I have an active call in with
>> Microsoft so will also post there. I thought
>> we had working code, I was declaring the module scoped variable as
>> static,
>> but that ends up with other peoples data on occassion when several people
>> are running reports. MS Support told me don't use static variables, but
>> if I don't then I can't access my properties in the footer.
>> I built a sample report and custom assembly to try to figure this out.
>> In the report I have something like this:
>> Body:
>> =Code.DataInFooter_NonStatic.ExpSet_MyData(First(Fields!LoginID.Value))
>> =Code.DataInFooter_NonStatic.MyData()
>> Footer:
>> =Code.DataInFooter_NonStatic.MyData()
>> What is displayed:
>> Body:
>> expected value
>> Footer:
>> empty and this is the problem.
>> Is it an execution order issue?
>> Here's my sample code:
>> using System;
>> using System.Collections.Generic;
>> using System.Text;
>> namespace DataInFooter_NonStatic
>> {
>> [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Assert,
>> Unrestricted = true)]
>> public class DataInFooter_NonStatic
>> {
>> private string _MyData;
>> public string MyData
>> {
>> get
>> {
>> return _MyData;
>> }
>> set
>> {
>> _MyData = MyData;
>> }
>> }
>> public void WriteToFile(string Input)
>> {
>> //throw new System.NotImplementedException();
>> }
>> public string ExpSet_MyData(string Input)
>> {
>> _MyData = Input;
>> return _MyData;
>> }
>> }
>> }
>> Steve MunLeeuw
>|||Turns out the custom assembly gets loaded once in the body, then again in
the footer, that's why they don't share data so well.
Steve MunLeeuw
"Steve MunLeeuw" <smunson@.clearwire.net> wrote in message
news:Opk5KuF9GHA.5092@.TK2MSFTNGP04.phx.gbl...
> Custom assembly call in footer looses property values.
> I have a custom assembly that uses a method in the body to pass in a data
> field. When I fetch the data in the body I get my data back. When I do
> the
> same in the footer I don't get any data. I have an active call in with
> Microsoft so will also post there. I thought
> we had working code, I was declaring the module scoped variable as static,
> but that ends up with other peoples data on occassion when several people
> are running reports. MS Support told me don't use static variables, but
> if I don't then I can't access my properties in the footer.
> I built a sample report and custom assembly to try to figure this out.
> In the report I have something like this:
> Body:
> =Code.DataInFooter_NonStatic.ExpSet_MyData(First(Fields!LoginID.Value))
> =Code.DataInFooter_NonStatic.MyData()
> Footer:
> =Code.DataInFooter_NonStatic.MyData()
> What is displayed:
> Body:
> expected value
> Footer:
> empty and this is the problem.
> Is it an execution order issue?
> Here's my sample code:
> using System;
> using System.Collections.Generic;
> using System.Text;
> namespace DataInFooter_NonStatic
> {
> [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Assert,
> Unrestricted = true)]
> public class DataInFooter_NonStatic
> {
> private string _MyData;
> public string MyData
> {
> get
> {
> return _MyData;
> }
> set
> {
> _MyData = MyData;
> }
> }
> public void WriteToFile(string Input)
> {
> //throw new System.NotImplementedException();
> }
> public string ExpSet_MyData(string Input)
> {
> _MyData = Input;
> return _MyData;
> }
> }
> }
> Steve MunLeeuw
>|||Here's some sample code of a custom assembly that shows the instance is not
shared between the body of the report and the footer.
http://smunson.blogspot.com/2006/10/rs-custom-assembly-instance-gets-re.html
Steve MunLeeuw
"Steve MunLeeuw" <smunson@.clearwire.net> wrote in message
news:Opk5KuF9GHA.5092@.TK2MSFTNGP04.phx.gbl...
> Custom assembly call in footer looses property values.
> I have a custom assembly that uses a method in the body to pass in a data
> field. When I fetch the data in the body I get my data back. When I do
> the
> same in the footer I don't get any data. I have an active call in with
> Microsoft so will also post there. I thought
> we had working code, I was declaring the module scoped variable as static,
> but that ends up with other peoples data on occassion when several people
> are running reports. MS Support told me don't use static variables, but
> if I don't then I can't access my properties in the footer.
> I built a sample report and custom assembly to try to figure this out.
> In the report I have something like this:
> Body:
> =Code.DataInFooter_NonStatic.ExpSet_MyData(First(Fields!LoginID.Value))
> =Code.DataInFooter_NonStatic.MyData()
> Footer:
> =Code.DataInFooter_NonStatic.MyData()
> What is displayed:
> Body:
> expected value
> Footer:
> empty and this is the problem.
> Is it an execution order issue?
> Here's my sample code:
> using System;
> using System.Collections.Generic;
> using System.Text;
> namespace DataInFooter_NonStatic
> {
> [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Assert,
> Unrestricted = true)]
> public class DataInFooter_NonStatic
> {
> private string _MyData;
> public string MyData
> {
> get
> {
> return _MyData;
> }
> set
> {
> _MyData = MyData;
> }
> }
> public void WriteToFile(string Input)
> {
> //throw new System.NotImplementedException();
> }
> public string ExpSet_MyData(string Input)
> {
> _MyData = Input;
> return _MyData;
> }
> }
> }
> Steve MunLeeuw
>

No comments:

Post a Comment