Hello,
I created a custom assembly with some business logic and attachted it to a
report.
A class in the assemby has an indexer defined which should return a string.
When I call the indexer from the code block I alway get an "Specified cast is
not valid" error back.
I created a test program in VS to test the classes and the indexer there
everything works fine.
What am I missing?
QSolved it.
I called a method on my class like the following:
wga.Attributes.Add("BG_CODE", Report.Parameters("Conc_BG").Value)
The definition for the Add method is:
public void Add(string databaseColumnName, string value)
But I have also another Add method which is:
public void Add(object key, object value)
I have to implement this method because my class inherits from IDictionary
I was under the impression that when I am adding strings the method with the
strings signature would be taken. But this was not the case. Instead the Add
method with the object signature was taken. Therefore my collection was
filled with objects and the indexer expected strings.
To solve this I had to rewrite it like the following:
wga.Attributes.Add("BG_CODE".ToString,
Report.Parameters("Conc_BG").Value.ToString)
Now the Add method with the strings signature is called.
Long live VS debugging!
Q
"Qbee" wrote:
> Hello,
> I created a custom assembly with some business logic and attachted it to a
> report.
> A class in the assemby has an indexer defined which should return a string.
> When I call the indexer from the code block I alway get an "Specified cast is
> not valid" error back.
> I created a test program in VS to test the classes and the indexer there
> everything works fine.
> What am I missing?
> Q
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment