I'm getting a strange error on the "in" of a "foreach(var x in y)" statement. The code throws and exception saying the call is ambiguous between two UmbracoHelper methods. A screen shot of the error and the copied code is below. Any help would be most appreciated.
I have verified that categories is a vanilla C# array with 2 items that are strings. The strange thing is that the foreach loop will iterate through the two items and then it tries to iterate again (and should pop out of the loop) it throws the error. Also, if I copy that entire code block and put it before the erroring block (with different variable name) it works fine.
I wanted to solve this issue for those of you out there that might run into this too. The problem was an ambiguous call, but the error location highlighted by Visual Studio was a red herring.
If you look at the image you see the exception hitting on the line with the foreach loop, specifically on the "in" keyword. However the error is a few lines down on a different line. Follow the red arrow to the actual exception location. This drove me crazy, but adding a .ToString() method to that parameter of the Umbraco.Content call fixes things.
Runtime Binder Exception/Ambiguous call
Hi,
I'm getting a strange error on the "in" of a "foreach(var x in y)" statement. The code throws and exception saying the call is ambiguous between two UmbracoHelper methods. A screen shot of the error and the copied code is below. Any help would be most appreciated.
I have verified that categories is a vanilla C# array with 2 items that are strings. The strange thing is that the foreach loop will iterate through the two items and then it tries to iterate again (and should pop out of the loop) it throws the error. Also, if I copy that entire code block and put it before the erroring block (with different variable name) it works fine.
Hi Jeremy.
Have you tried to .ToString() the parameter you pass in to the Umbraco.Content() method?
Hi guys,
In perfect world its better to use strongly typed objects -
Thanks,
Alex
I wanted to solve this issue for those of you out there that might run into this too. The problem was an ambiguous call, but the error location highlighted by Visual Studio was a red herring.
If you look at the image you see the exception hitting on the line with the foreach loop, specifically on the "in" keyword. However the error is a few lines down on a different line. Follow the red arrow to the actual exception location. This drove me crazy, but adding a .ToString() method to that parameter of the Umbraco.Content call fixes things.
is working on a reply...