Page view counter
Using Datagrid with LINQ crashes the browser? Subscribe to this thread
Last post 04-11-2008 4:07 AM by Yi-Lun Luo - MSFT. 4 replies.
Sort Posts:
03-10-2008 10:56 AM
Using Datagrid with LINQ crashes the browser?

Hello,

I'm having some problems in using DataGrid with LINQ. 

The following code makes crashing the IE7. 

                     XDocument xmlProducts = XDocument.Parse(xmlContent);

                    var products = from product in xmlProducts.Descendants("Product")
                                   select new
                                   {
                                       ProductID = Convert.ToInt32(product.Element("ProductId").Value),
                                       ProductName = (string)product.Element("ProductName").Value
                                   };

                    datagrid1.ItemsSource = products;

Env:

1) Vista Home Premium (32)
2) VS 2008  + SL2 (beta1)
3) IE7

Let me know if you need more details.  

Note:

If you are using class and List<T> like the example from doc, it's working fine. but why not work with LINQ and implicitly-typed variable?

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Microsoft WPF & Silverlight Insider
Blog : http://michaelsync.net


mchlSync

Loading...
Joined on 09-16-2005
Singapore
Posts 2,478
03-12-2008 12:49 AM
Marked as Answer
Re: Using Datagrid with LINQ crashes the browser?

Hello, actually the problem is: Anonymous Types are internal. Currently data binding doesn't support binding to non-public classes. Try to use a ListBox to bind to an internal class, you'll find a similar problem.

The root cause seems to be: Data binding uses reflection, and reflection needs high security permissions. Silverlight runs in a sand box, where such security permissions are not granted.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

Yi-Lun Luo - MSFT

Loading...
Joined on 10-29-2007
Posts 2,747
03-12-2008 2:25 AM
Re: Using Datagrid with LINQ crashes the browser?

Thanks a lot for your answer. Yi-Lun.  

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Microsoft WPF & Silverlight Insider
Blog : http://michaelsync.net


mchlSync

Loading...
Joined on 09-16-2005
Singapore
Posts 2,478
04-01-2008 10:56 AM
Re: Using Datagrid with LINQ crashes the browser?

Yi-Lun Luo - MSFT:
Try to use a ListBox to bind to an internal class, you'll find a similar problem.
 

Hello Yi-lun,

I just tired to use ListBox instead of Datagrid. it's working fine. Could you please review this issue?  

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Microsoft WPF & Silverlight Insider
Blog : http://michaelsync.net


mchlSync

Loading...
Joined on 09-16-2005
Singapore
Posts 2,478
04-11-2008 4:07 AM
Re: Using Datagrid with LINQ crashes the browser?

Hi Michael, sorry for the late response. But I really don't see how you get it to work with ListBox. This is a known bug. swildermuth (The ADO Guy) already reported this issue on a ListBox from the Jolt private connect. Any ItemsControl bound to internal types will cause this problem. While data binding to internal types such as anonymous types are not supported, we understand we should not hang the browser. Our developers are investigating this issue.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

Yi-Lun Luo - MSFT

Loading...
Joined on 10-29-2007
Posts 2,747
Microsoft Communities