Unable to cast object of type 'WhereEnumerableIterator`1 exception thrown

Posts   
 
    
kievBug
User
Posts: 105
Joined: 09-Jan-2009
# Posted on: 18-Jan-2011 22:45:06   

Hi guys,

I'm using llblgen 3 with LlblgenPro Runtime Framework for SQL Server. In the new project I've added several entities like User and Group. And now I want to create a new relation between them M:N.

I select relationships node in the tree and do right click and select New Many to Many relatioship.

and it throws this exception:

Exception information.

LLBLGen Pro version: v3.0. Build: January 3rd, 2011

Exception details:

Message: Unable to cast object of type 'WhereEnumerableIterator`1[SD.LLBLGen.Pro.ApplicationCore.EntityModel.RelationshipEdge]' to type 'SD.LLBLGen.Pro.ApplicationCore.EntityModel.RelationshipEdge'. Source: LLBLGenPro Stack trace: at SD.LLBLGen.Pro.Gui.Forms.IndirectRelationshipEditor.HandleFirstRelationshipSelected() at SD.LLBLGen.Pro.Gui.Forms.IndirectRelationshipEditor.FillFirstRelationships() at SD.LLBLGen.Pro.Gui.Forms.IndirectRelationshipEditor.HandleStartEntityComboBoxSelected() at SD.LLBLGen.Pro.Gui.Forms.IndirectRelationshipEditor.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Inner exception: <null>

Can you help me?

Thanks, Anton

kievBug
User
Posts: 105
Joined: 09-Jan-2009
# Posted on: 18-Jan-2011 22:50:31   

Ohh, the problem is that I didn't have any M:1 relations created.

Ok, thanks.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 18-Jan-2011 23:16:38   

Probably shouldn't get an exception though...! We'll take a look.

Matt

kievBug
User
Posts: 105
Joined: 09-Jan-2009
# Posted on: 19-Jan-2011 01:38:41   

Yeah, there is something wrong with many to many relations. I converted my 2.6 project to 3.0. And when I'm trying to edit M:N relation it is throwing the same exception, but there are a lot of different M:1 relations in the project and in the entity too.

Exception information.

LLBLGen Pro version: v3.0. Build: January 3rd, 2011

Exception details:

Message: Unable to cast object of type 'WhereEnumerableIterator`1[SD.LLBLGen.Pro.ApplicationCore.EntityModel.RelationshipEdge]' to type 'SD.LLBLGen.Pro.ApplicationCore.EntityModel.RelationshipEdge'. Source: LLBLGenPro Stack trace: at SD.LLBLGen.Pro.Gui.Forms.IndirectRelationshipEditor.HandleFirstRelationshipSelected() at SD.LLBLGen.Pro.Gui.Forms.IndirectRelationshipEditor.FillFirstRelationships() at SD.LLBLGen.Pro.Gui.Forms.IndirectRelationshipEditor.HandleStartEntityComboBoxSelected() at SD.LLBLGen.Pro.Gui.Forms.IndirectRelationshipEditor.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Inner exception: <null>

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 19-Jan-2011 09:09:59   

It would be great if we could have a repro project to reproduce it, as our own test projects don't throw this error. Could you mail us at support AT llblgen DOT com the .llblgenproj so we can reproduce it? (with the description which m:n you edited / steps you took?) Thanks!

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jan-2011 10:01:57   

We store a linq query result in the datasource which is bound to the combobox. It seems in your situation it's not iterated yet, and therefore there's just 1 object, the iterator.

What's odd is that whatever I do, I can't reproduce it. While that's great, there is apparently a situation which makes it fail...

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Jan-2011 09:06:22   

Projects received throw email. We'll look into the matter.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Jan-2011 09:50:10   

The cause of this is a breaking change in .NET 4 apparently:

bindingSource.DataSource = <linq to objects query>;

If the linq to objects query results in 0 elements, the binding source is empty in .NET 3.5, but it's not empty in .NET 4. In .NET 4 a WhereEnumerator is present in the bindingsource, instead of the expected item or nothing at all.

We'll review other places where we do similar things to see if we can prevent this from happening.

Fixed in next build. (January 21st, released later today)

Frans Bouma | Lead developer LLBLGen Pro