none
Catastrophic failure in <my:DataGrid>

    Question

  • Hey guys!  Can someone tell me what is wrong with this? I get this error in VS2008 IDE everytime I write "AutoGenerateColumns" for <my:DataGrid> ?

    Thanks. 

    Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))at MS.Internal.XcpImports.CreateObjectByTypeIndex(UInt32 typeIndex) at System.Windows.DependencyObject..ctor(UInt32 nativeTypeIndex) at System.Windows.Media.MatrixTransform..ctor() at MS.Internal.Silverlight.Host.RuntimeInterop.SetRootTransformMatrix(Int32 rootInstanceIdentifier, Double scaleX, Double scaleY, Double offsetX, Double offsetY) at MS.Internal.Silverlight.Host.Interop.SetRootTransformMatrix(Int32 rootInstanceIdentifier, Double scaleX, Double scaleY, Double offsetX, Double offsetY) at MS.Internal.Silverlight.Host.CiderSilverlightImageHost.CiderInternalImage.UpdateBitmap() at MS.Internal.Silverlight.Host.CiderSilverlightImageHost.CiderInternalImage.UpdateTree() at MS.Internal.Silverlight.Host.CiderSilverlightImageHost.CiderInternalImage.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at MS.Internal.Silverlight.Host.CiderSilverlightImageHost.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg) at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork() at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

    Wednesday, April 23, 2008 9:56 PM

Answers

  • There are a few issues here.  First, you'll need to add a reference to the System.Windows.Controls.Data assembly to get at the DataGrid (which is what I think you mean).  Also it should be <my:DataGrid not Grid.  And for the my: namespace to be used, it need to be added to the top of the XAML file (like xmlns:my="clr-namespace:System.Windows.Controls.Data;assembly=System.Windows.Controls.Data").

    Thursday, April 24, 2008 4:28 AM
  • Hi:

      A simple option is to create a web page to provide the images and then use WebClient in Silverlight to download that image. The first step is to create that page. It's not difficult to do so. If you're using Asp.net, for example, you can refer to:

    http://support.microsoft.com/kb/326502

      You can use querystring to pass the image id.

      The second step is to use WebClient to download the image and assign it to image control in Silverlight. Here's the sample demonstrates how to do this:

            public Page()
            {
                InitializeComponent();
                WebClient wc = new WebClient();
                wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
                wc.OpenReadAsync(new Uri("http://ll.atdmt.com/b/NMMRTUMISINF/180x150_Office_2007_Trials___System1_12152007_001.jpg"));
            }

            void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
            {
                BitmapImage bmp = new BitmapImage();
                bmp.SetSource(e.Result);
                this.Image1.Source = bmp;
            }

           <Image x:Name="Image1" Width="200" Height="200"></Image>

      You just have to replace the uri with your own one.

      You can refer to this article for more details:

    http://msdn2.microsoft.com/en-us/library/cc189021(vs.95).aspx

    Regards

    Thursday, April 24, 2008 9:55 PM
  • Hi:

      Our requirement for that page is, given a image uri, return relevant image stream. In your case you may change this line

    Dim da As New SqlDataAdapter("Select * From pub_info", con)

      to:

    Dim da As New SqlDataAdapter("Select * From pub_info where image_id=image_id_retrieved_from_querystring", con)

      And the uri to request the image should be something like:http://YourWebSite/Default.aspx?imageid=image_id_retrieved_from_querystring

      To get the image_id_retrieved_from_querystring you can try: 

    Request.QueryString("imageid")

      in aspx.cs.

     

      When it's done you can just try this in xaml:

     <Image x:Name="img1" Width="50" Height="50" Source="http://YourWebSite/Default.aspx?imageid=imageid1"></Image>

      It will then show the image whose imageid is imageid1 in the DataBase. Or you can use WebClient to download that image as I mentioned before.

    Regards

     

     

    Friday, April 25, 2008 1:40 AM

All replies

  • Hard to tell, can we see the XAML?

    Thursday, April 24, 2008 4:02 AM
  • Thanks for the reply.  Well there not much content in the XAML file.  Actually, the project that I created was a new one. The Page.xaml file contains these default lines of XAML codes:

     

    <UserControl x:Class="DiggSample.Page"

    xmlns="http://schemas.microsoft.com/client/2007"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    </UserControl>.

     

    When I tried to code <my:Grid x:Name="dd" AutoGenerateColumns="" >  in between the <UserControl> tag, the error I mentioned from my previous post displayed in the Design pane (or the IDE part where you can see the canvas.

    Thursday, April 24, 2008 4:22 AM
  • There are a few issues here.  First, you'll need to add a reference to the System.Windows.Controls.Data assembly to get at the DataGrid (which is what I think you mean).  Also it should be <my:DataGrid not Grid.  And for the my: namespace to be used, it need to be added to the top of the XAML file (like xmlns:my="clr-namespace:System.Windows.Controls.Data;assembly=System.Windows.Controls.Data").

    Thursday, April 24, 2008 4:28 AM
  • Thanks. That sould resolve it.

    By the way, can you recommend me some link to follow (tutorials) on where I could get to display images stored in my SQL Server 2005 database and render it on a silverlight datagird.

     Thanks again.

    Thursday, April 24, 2008 4:40 AM
  • I don't know of any offhand.  I did this in my SL Alpha 1.1 example but that was using some nasty old database format.  How are you storing them in the DB?

    Thursday, April 24, 2008 6:21 AM
  • good day!

     i am currently using sql server 2005. the images are stored as varbinary (BLOB). i cant jumpstart my project in silverlight since i am having the hard time what method to use in establishing a connection to my database. frankly, i dont where to start. i hope you can lend a hand in giving a brief tutorial on how to do this.  i am a novice in silverlight. i've exhausted google so much and i find it very confusing following their samples.

     thanks in advance.

    Thursday, April 24, 2008 8:52 PM
  • Hi:

      A simple option is to create a web page to provide the images and then use WebClient in Silverlight to download that image. The first step is to create that page. It's not difficult to do so. If you're using Asp.net, for example, you can refer to:

    http://support.microsoft.com/kb/326502

      You can use querystring to pass the image id.

      The second step is to use WebClient to download the image and assign it to image control in Silverlight. Here's the sample demonstrates how to do this:

            public Page()
            {
                InitializeComponent();
                WebClient wc = new WebClient();
                wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
                wc.OpenReadAsync(new Uri("http://ll.atdmt.com/b/NMMRTUMISINF/180x150_Office_2007_Trials___System1_12152007_001.jpg"));
            }

            void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
            {
                BitmapImage bmp = new BitmapImage();
                bmp.SetSource(e.Result);
                this.Image1.Source = bmp;
            }

           <Image x:Name="Image1" Width="200" Height="200"></Image>

      You just have to replace the uri with your own one.

      You can refer to this article for more details:

    http://msdn2.microsoft.com/en-us/library/cc189021(vs.95).aspx

    Regards

    Thursday, April 24, 2008 9:55 PM
  • Sir Allen,

    Thanks for your reply. I believe this would help me a lot. What I am worried about is how to use WebClient if i am using SQL Server 2005 as the source for images?

     Thanks!

    Thursday, April 24, 2008 10:06 PM
  • Hi:

      We cannot query DataBase directly from Silverlight. As I mentioned we can use a web site to query DataBase (please check out that link I've provided), then use WebClient to download images from that page.

    Regards

    Thursday, April 24, 2008 11:22 PM
  • hi.

    what do you mean via website? through web services?

    Thursday, April 24, 2008 11:42 PM
  • Hi:

      If you're using Asp.Net you can just create a Web Site project. May I know have you read this article?

    http://support.microsoft.com/kb/326502

    Regards

    Friday, April 25, 2008 12:22 AM
  • hi. i've already read the article.if i'm not mistaken it's a vb.net code for retrieving the records from the database and using filestream to read and write BLOB in the database. Although i'm using c# for my code-behind i think it would not be an issue for me.  My project will be using ASP.NET. If I will be creating a web site, would this refer to and contain the query string that i should formulate based from my understanding of your post? (please refer below). Sorry, but my idea is somehow blurred as where to start of.

    Thanks.

    A simple option is to create a web page to provide the images and then use WebClient in Silverlight to download that image. The first step is to create that page. It's not difficult to do so. If you're using Asp.net, for example, you can refer to:

    http://support.microsoft.com/kb/326502

      You can use querystring to pass the image id.

      The second step is to use WebClient to download the image and assign it to image control in Silverlight. Here's the sample demonstrates how to do this:

            public Page()
            {
                InitializeComponent();
                WebClient wc = new WebClient();
                wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
                wc.OpenReadAsync(new Uri("http://ll.atdmt.com/b/NMMRTUMISINF/180x150_Office_2007_Trials___System1_12152007_001.jpg"));
            }

            void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
            {
                BitmapImage bmp = new BitmapImage();
                bmp.SetSource(e.Result);
                this.Image1.Source = bmp;
            }

           <Image x:Name="Image1" Width="200" Height="200"></Image>

      You just have to replace the uri with your own one.

      You can refer to this article for more details:

    http://msdn2.microsoft.com/en-us/library/cc189021(vs.95).aspx

     

    Friday, April 25, 2008 1:16 AM
  • Hi:

      Our requirement for that page is, given a image uri, return relevant image stream. In your case you may change this line

    Dim da As New SqlDataAdapter("Select * From pub_info", con)

      to:

    Dim da As New SqlDataAdapter("Select * From pub_info where image_id=image_id_retrieved_from_querystring", con)

      And the uri to request the image should be something like:http://YourWebSite/Default.aspx?imageid=image_id_retrieved_from_querystring

      To get the image_id_retrieved_from_querystring you can try: 

    Request.QueryString("imageid")

      in aspx.cs.

     

      When it's done you can just try this in xaml:

     <Image x:Name="img1" Width="50" Height="50" Source="http://YourWebSite/Default.aspx?imageid=imageid1"></Image>

      It will then show the image whose imageid is imageid1 in the DataBase. Or you can use WebClient to download that image as I mentioned before.

    Regards

     

     

    Friday, April 25, 2008 1:40 AM
  • now that's what i am talking about.

    thanks so much.this would greatly help me to start of with my project.

    thanks again.

    Friday, April 25, 2008 2:11 AM
  • Sir,  I have done the following code in my Default.aspx.cs file, and from here I am lost. Would you have time to help where to go from here? Thanks.

     

    using System;

    using System.Configuration;

    using System.Data;

    using System.Linq;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.HtmlControls;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Xml.Linq;

    using System.Data.SqlClient;

     

    public partial class _Default : System.Web.UI.Page

    {

    private string imageTypeID;protected void Page_Load(object sender, EventArgs e)

    {

    imageTypeID = GetImageID();

    }

    public string GetImageID()

    {

    string imageID = string.Empty;

    SqlConnection sqlConnection = new SqlConnection(

    ConfigurationManager.ConnectionStrings["PalawanPearlsProduction"].ConnectionString);

    // prepare command

    SqlCommand sqlCommand = new SqlCommand("Material_GetItem_B", sqlConnection);

    sqlCommand.CommandType = CommandType.StoredProcedure;

    //sqlCommand.Parameters.AddWithValue("@ShapeTypeID", shapeTypeID);

    // execute command

    sqlConnection.Open();

    SqlDataReader myReader = sqlCommand.ExecuteReader();if (myReader.Read())

    {

    imageID = myReader[
    "ImageTypeID"].ToString();

    }

    return imageID;

    }

    }

    Sunday, April 27, 2008 10:48 PM
  • Hello:

      Here's an article demonstrates how to do this in C#:

      http://www.odetocode.com/Articles/172.aspx

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    Hope it helps.

    Monday, April 28, 2008 1:47 AM
  • Sir,

    Here's the scenario. I have SQL Server 2005 database table containing images that are stored as varbinary. What I would need exactly to happen is to retrieve this images and display them through a Silverlight application. The link you provided be only retrieves images from a database and render it on an ASP.NET Datagrid.  In detail, is there any link you can provide me to help me through the step-by-step process that includes establishing connection to a database whether it be by web service or webclient and render it ono a Silverlight application.

    Thanks.

    Monday, April 28, 2008 2:04 AM
  • Hello:

      You can see in asp.net we can get an image via:

     <img runat="server"   src='http://yourserver/Default.aspx?ID=imageid1' ID="Img1"/>

     

      Then in Silverlight it's similar:

                <Image 'http://yourserver/Default.aspx?ID=imageid1" Width="500" Height="500"></Image>

      Or you can manually download image as I mentioned before.

    Regards

    Monday, April 28, 2008 2:31 AM
  • Yes, I do get this part. But from the code that I have in Default.aspx.cs, I was able to retrieve an imageid. My problem is how can I pass this imageid that I retrieved to Page.xaml file? Where does the Request.QueryString enters/used?

    Thanks.

     

    Monday, April 28, 2008 2:50 AM
  • Hello:

      Do you mean Silverlight don't know the image id initially? If so you can pass the information to client side via hidden value, cookie, InitParameter, etc.

    http://silverlight.net/forums/p/12481/41895.aspx#41895

    Regards

    Monday, April 28, 2008 3:14 AM
  • hello again,

    i am always having this problem popped on my screen. what seems to the problem? can you help me out with this?

    An exception of type 'System.Security.SecurityException' occurred in System.Windows.dll but was not handled in user code

    Monday, April 28, 2008 5:12 AM
  • This error also occurred:

    An exception of type 'System.Xml.XmlException' occurred in System.Xml.dll but was not  handled in user code

    Additional information:[Xml_MissingRoot]

    Arguments:

    Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.Xml.dll&Key=Xml_MissingRoot

     

    Thanks.

    Monday, April 28, 2008 5:19 AM
  • Hi:

      Do you have any cross domain access?

      Please refer to this post first to see if it's the culprit.

    http://silverlight.net/forums/t/10944.aspx

    Regards

    Monday, April 28, 2008 5:20 AM
  • Hi:

    This error also occurred:

    An exception of type 'System.Xml.XmlException' occurred in System.Xml.dll but was not  handled in user code

    Additional information:[Xml_MissingRoot]

    Arguments:

    Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.Xml.dll&Key=Xml_MissingRoot

     

    Thanks.

      Not sure how your code looks like but from the description it seems you need to add a root to your xml. Something like:

    <RootElement>

    <Others>

    .....

    </RootElement>

    Regards

    Monday, April 28, 2008 5:22 AM
  • where and how would i do that?

    thanks.

    Monday, April 28, 2008 5:36 AM
  • Hi:

      It would be better if you could paste your current code. And have you checked the cross domain access issue?

    Regards

    Monday, April 28, 2008 5:48 AM
  • No. The silverlight should know the image id initially because it would be displayed on the page once the site is launched/opened just like a home page.  What i mean by passing the imageid is how will it be retrieved from Default.aspx.cs and be called by Page.xaml.cs?

    Default.aspx.cs contains these line of codes:

    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Data.SqlClient;


    public partial class _Default : System.Web.UI.Page
    {
        private string imageTypeID;

        protected void Page_Load(object sender, EventArgs e)
        {
            imageTypeID = GetImageID();
        }

        public string GetImageID()
        {
            string imageID = string.Empty;

            SqlConnection sqlConnection = new SqlConnection(
                ConfigurationManager.ConnectionStrings["PalawanPearlsProduction"].ConnectionString);

            SqlCommand sqlCommand = new SqlCommand("Material_GetItem_B", sqlConnection);
            sqlCommand.CommandType = CommandType.StoredProcedure;
           
            sqlConnection.Open();
            SqlDataReader myReader = sqlCommand.ExecuteReader();

            if (myReader.Read())
            {
                imageID = myReader["ImageTypeID"].ToString();
            }

            return imageID;
        }
    }

    =============================================================================

    Page.xaml.cs contains these lines of codes:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Xml;
    using System.Xml.Linq;

    namespace SilverlightApplication1
    {
        public partial class Page : UserControl
        {
            public Page()
            {
                InitializeComponent();
            }

        }
    }

    =================================================================

    Where should i put my Request.QueryString(imageid)?

    Monday, April 28, 2008 9:24 PM
  • Hi:

      First we should know what is query string:

    http://en.wikipedia.org/wiki/Query_string

      So the uri to request the image should be something like:

    http://server/Default.aspx?imageid=1

      Then in Default.aspx.cs:

    protected void Page_Load(object sender, EventArgs e)
        {

    //We can retrieve the image id via Request.QueryString["imageid"]

    //Query DataBase here to send back image, please refer to the links I provided before
          

        }

      In xaml try something like this:

       <Image "http://server/Default.aspx?imageid=1" Width="500" Height="500"></Image>

    Regards

     

    Monday, April 28, 2008 9:37 PM
  • Sir,

    Is my code in Default.aspx.cs incorrect?

    Monday, April 28, 2008 9:48 PM
  • Hi:

      It's incorrect. In Page_Load We should retrieve the image id via Request.Querystring and query database, then send back the image. You can refer to the two links I've provided.

    Regards

    Monday, April 28, 2008 11:13 PM
  • Hi,

    My SLApp working fine with default localization, and with en-US culture. I am using datgrid with AutoGenrateColumns 'False', means i am adding the columns in the constructor, I am specifying the variable widths for the columns during their creation.

    If i change the culture of the browser(means by changing the Language of the Browser to German 'de-DE'). The application getting crashed with Catstrophic Failure, with below stacktrace:  

    bei MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       bei MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       bei System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       bei System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)

    Do any one let me know where exactly, i am doing mistake.

     Application is working fine with default, and en-US cultures, but not in Germany(de-DE).

    Thanks in advcance for your suggestions

    Regards

    Ashok

    Thursday, June 17, 2010 4:40 AM