We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

System.InvalidCastException thrown by LINQ Reporting engine using .NET

hello,

in my template i have :
Util.OneMethod(ds.MyPropertyList.Where(p=>p.IsOk == true))

the method Util.OneMethod(object o) is raised, but i have problem casting o to IEnumerable. if I rename it to Util.OneMethod(IEnumerable) the report engine raises an exception saying the method OneMethod is unknown in Util class.

please see the project enclosed.
TestAspose.zip (187.1 KB)

@miniseb31

We have tested the scenario using the latest version of Aspose.Words for .NET 20.3 and have not faced any exception. So, please use Aspose.Words for .NET 20.3.

hello,
have you rename the Util.OneMethod as i mentionned in the previous post. see enclosed the project with exception, i used the latest aspose version.

TestAsposeWithException.zip (187.1 KB)

for my last post project enclosed my point was that the cast was not possible.

@miniseb31

We have logged this problem in our issue tracking system as WORDSNET-20141. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@miniseb31

It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue as ‘Not a Bug’.

Although the engine enables to use a subset of C# syntax in templates, its built-in extension methods may use object representations different from those used by real LINQ. This is one of the cases. An object returned by our Where built-in extension method does not implement generic IEnumerable<T> . Instead, it implements non-generic IEnumerable (which is semantically equivalent to IEnumerable<object> ). So you should use non-generic IEnumerable in Util.OneMethod , then everything works as expected.

Moreover, please note that such usages of our built-in extension methods are not recommended as their sole purpose is to support data manipulations similar to those of real LINQ, but passing of their results to external code is not an officially supported scenario, so more similar issues (that seem strange) may appear.