Below is a snippet of code that I'm having problems with. When I reach the line containing the foreach loop, I get a casting exception. Here's what's going on... First, I am certain that the objects contained in the commissions ArrayList implement the ICalcuTreeCommission interface. Second, the call creating the ICalcuTreeCalculator uses reflection to obtain a reference to an object implementing this interface. The problem, I think, lies within the following article:
However, my question is this: how can I get around this? We are using this code to view commissions produced by different types of commission calculators. Although each commission is different, they all have certain things in common, such as when they were run and their amount. It is these kinds of things that I am looking to display using the interface and the reflection.
Finally, here's one final bizarre twist: the code below runs just fine when I put it into a console application. It only fails when I have it in an ASCX control in an ASP.NET web page. Any thoughts? Any solutions? Thanks!
ICalcuTreeCalculator calc = calculator.GetCalculator()
ArrayList commissions = calc.GetCommissions( distributor.Id );
foreach( ICalcuTreeCommission commission in commissions )